MCPcopy
hub / github.com/webpack/webpack / build

Method build

lib/ContextModule.js:476–608  ·  view source on GitHub ↗

* Builds the module using the provided compilation context. * @param {WebpackOptions} options webpack options * @param {Compilation} compilation the compilation * @param {ResolverWithOptions} resolver the resolver * @param {InputFileSystem} fs the file system * @param {BuildCallback} callb

(options, compilation, resolver, fs, callback)

Source from the content-addressed store, hash-verified

474 * @returns {void}
475 */
476 build(options, compilation, resolver, fs, callback) {
477 this._forceBuild = false;
478 /** @type {BuildMeta} */
479 this.buildMeta = {
480 exportsType: "default",
481 defaultObject: "redirect-warn"
482 };
483
484 // Respect the global module parser `overrideStrict` option
485 const overrideStrict =
486 options.module.parser &&
487 options.module.parser.javascript &&
488 options.module.parser.javascript.overrideStrict;
489
490 this.buildInfo = {
491 strict: overrideStrict ? overrideStrict === "strict" : undefined,
492 snapshot: undefined
493 };
494
495 this.dependencies.length = 0;
496 this.blocks.length = 0;
497 const startTime = Date.now();
498 /** @type {ResolveDependencies} */
499 (this.resolveDependencies)(fs, this.options, (err, dependencies) => {
500 if (err) {
501 return callback(
502 makeWebpackError(err, "ContextModule.resolveDependencies")
503 );
504 }
505
506 // abort if something failed
507 // this will create an empty context
508 if (!dependencies) {
509 callback();
510 return;
511 }
512
513 // enhance dependencies with meta info
514 for (const dep of dependencies) {
515 dep.loc = {
516 name: dep.userRequest
517 };
518 dep.request = this.options.addon + dep.request;
519 }
520 dependencies.sort(
521 concatComparators(
522 compareSelect((a) => a.loc, compareLocations),
523 keepOriginalOrder(this.dependencies)
524 )
525 );
526
527 if (this.options.mode === "sync" || this.options.mode === "eager") {
528 // if we have an sync or eager context
529 // just add all dependencies and continue
530 this.dependencies = dependencies;
531 } else if (this.options.mode === "lazy-once") {
532 // for the lazy-once mode create a new async dependency block
533 // and add that block to this context

Callers

nothing calls this directly

Calls 12

makeWebpackErrorFunction · 0.85
concatComparatorsFunction · 0.85
compareSelectFunction · 0.85
keepOriginalOrderFunction · 0.85
sortMethod · 0.80
toPathMethod · 0.80
createSnapshotMethod · 0.80
addDependencyMethod · 0.65
callbackFunction · 0.50
addBlockMethod · 0.45
testMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected