Repository: webpack/webpack
File: lib/NormalModule.js (JavaScript)

Code before:
		} catch (err) {
			processResult(/** @type {Error} */ (err));
			return;
		}

		if (this.loaders.length > 0) {
			/** @type {BuildInfo} */
			(this.buildInfo).buildDependencies = new LazySet();
		}

		runLoaders(
			{
				resource: this.resource,
				loaders: this.loaders,
				context: loaderContext,
				/**
				 * @param {LoaderContext<EXPECTED_ANY>} loaderContext the loader context
				 * @param {string} resourcePath the resource Path
				 * @param {(err: Error | null, result?: string | Buffer, sourceMap?: Result[1]) => void} callback callback
				 */
				processResource: (loaderContext, resourcePath, callback) => {
					const resource = loaderContext.resource;
					const scheme = getScheme(resource);
					hooks.readResource
						.for(scheme)
						.callAsync(loaderContext, async (err, result) => {
							if (err) return callback(err);
							if (typeof result !== "string" && !result) {
								return callback(
									new UnhandledSchemeError(
										/** @type {string} */
										(scheme),
										resource
									)
								);
							}
							if (
								this.extractSourceMap &&
								(this.useSourceMap || this.useSimpleSourceMap)
							) {
								try {
									const { source, sourceMap, fileDependencies } =
										await getExtractSourceMap()(result, resourcePath, fs);
									if (this.buildInfo && this.buildInfo.fileDependencies) {
										this.buildInfo.fileDependencies.addAll(fileDependencies);
									}
									return callback(null, source, sourceMap);
								} catch (err) {
									this.addWarning(
										new ModuleWarning(/** @type {Error} */ (err))
									);

Review comment (suggestion):
Maybe we should implement `processResourceAsync` in `loader-runner` in future, to migrate on async API, having `async` and `callback` is a little bit misleading, but let's postpone it and make it when we will move `loader-runner` into core

Code after:
				this,
				/** @type {LoaderContext<EXPECTED_ANY>} */
				(loaderContext)
			);
		} catch (err) {
			processResult(/** @type {Error} */ (err));
			return;
		}

		if (this.loaders.length > 0) {
			/** @type {BuildInfo} */
			(this.buildInfo).buildDependencies = new LazySet();
		}

		runLoaders(
			{
				resource: this.resource,
				loaders: this.loaders,
				context: loaderContext,
				/**
				 * @param {LoaderContext<EXPECTED_ANY>} loaderContext the loader context
				 * @param {string} resourcePath the resource Path
				 * @param {(err: Error | null, result?: string | Buffer, sourceMap?: Result[1]) => void} callback callback
				 * @returns {Promise<void>}
				 */
				processResource: async (loaderContext, resourcePath, callback) => {
					/** @type {ReadResource} */
					const readResource = (resourcePath, getLoaderContext) => {
						const scheme = getScheme(resourcePath);
						return new Promise((resolve, reject) => {
							hooks.readResource
								.for(scheme)
								.callAsync(getLoaderContext(resourcePath), (err, result) => {
									if (err) {
										reject(err);
									} else {
										if (typeof result !== "string" && !result) {
											return reject(
												new UnhandledSchemeError(
													/** @type {string} */
													(scheme),
													resourcePath
												)
											);
										}
										resolve(result);
									}
								});
						});
					};
					try {