* 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)
| 474 | * @returns {void} |
| 475 | */ |
| 476 | build(options, compilation, resolver, fs, callback) { |
| 477 | this._forceBuild = false; |
| 478 | /** @type {BuildMeta} */ |
| 479 | this.buildMeta = { |
| 480 | exportsType: class="st">"default", |
| 481 | defaultObject: class="st">"redirect-warn" |
| 482 | }; |
| 483 | |
| 484 | class="cm">// 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 === class="st">"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, class="st">"ContextModule.resolveDependencies") |
| 503 | ); |
| 504 | } |
| 505 | |
| 506 | class="cm">// abort if something failed |
| 507 | class="cm">// this will create an empty context |
| 508 | if (!dependencies) { |
| 509 | callback(); |
| 510 | return; |
| 511 | } |
| 512 | |
| 513 | class="cm">// 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 === class="st">"sync" || this.options.mode === class="st">"eager") { |
| 528 | class="cm">// if we have an sync or eager context |
| 529 | class="cm">// just add all dependencies and continue |
| 530 | this.dependencies = dependencies; |
| 531 | } else if (this.options.mode === class="st">"lazy-once") { |
| 532 | class="cm">// for the lazy-once mode create a new async dependency block |
| 533 | class="cm">// and add that block to this context |
nothing calls this directly
no test coverage detected