MCPcopy
hub / github.com/webpack/webpack / _doBuild

Method _doBuild

lib/NormalModule.js:1458–1683  ·  view source on GitHub ↗

* @param {WebpackOptions} options webpack options * @param {Compilation} compilation the compilation * @param {ResolverWithOptions} resolver the resolver * @param {InputFileSystem} fs the file system * @param {NormalModuleCompilationHooks} hooks the hooks * @param {BuildCallback} callback

(options, compilation, resolver, fs, hooks, callback)

Source from the content-addressed store, hash-verified

1456 * @returns {void}
1457 */
1458 _doBuild(options, compilation, resolver, fs, hooks, callback) {
1459 const loaderContext = this._createLoaderContext(
1460 resolver,
1461 options,
1462 compilation,
1463 fs,
1464 hooks
1465 );
1466
1467 /**
1468 * @param {Error | null} err err
1469 * @param {(Result | null)=} result_ result
1470 * @returns {void}
1471 */
1472 const processResult = (err, result_) => {
1473 if (err) {
1474 if (!(err instanceof Error)) {
1475 err = new NonErrorEmittedError(err);
1476 }
1477 const currentLoader = this.getCurrentLoader(loaderContext);
1478 const error = new ModuleBuildError(err, {
1479 from:
1480 currentLoader &&
1481 compilation.runtimeTemplate.requestShortener.shorten(
1482 currentLoader.loader
1483 )
1484 });
1485 return callback(error);
1486 }
1487 const result = hooks.processResult.call(
1488 /** @type {Result} */
1489 (result_),
1490 this
1491 );
1492 const source = result[0];
1493 const sourceMap = result.length >= 1 ? result[1] : null;
1494 const extraInfo = result.length >= 2 ? result[2] : null;
1495
1496 if (!Buffer.isBuffer(source) && typeof source !== "string") {
1497 const currentLoader = this.getCurrentLoader(loaderContext, 0);
1498 const err = new Error(
1499 `Final loader (${
1500 currentLoader
1501 ? compilation.runtimeTemplate.requestShortener.shorten(
1502 currentLoader.loader
1503 )
1504 : "unknown"
1505 }) didn't return a Buffer or String`
1506 );
1507 const error = new ModuleBuildError(err);
1508 return callback(error);
1509 }
1510
1511 const isBinaryModule =
1512 this.generatorOptions && this.generatorOptions.binary !== undefined
1513 ? this.generatorOptions.binary
1514 : this.binary;
1515

Callers 1

buildMethod · 0.95

Calls 6

_createLoaderContextMethod · 0.95
callbackFunction · 0.50
callMethod · 0.45
addWarningMethod · 0.45
addAllMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected