* 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)
| 309 | * @returns {void} |
| 310 | */ |
| 311 | build(options, compilation, resolver, fs, callback) { |
| 312 | this.buildInfo = { |
| 313 | active: this.active |
| 314 | }; |
| 315 | /** @type {BuildMeta} */ |
| 316 | this.buildMeta = {}; |
| 317 | this.clearDependenciesAndBlocks(); |
| 318 | const dep = new CommonJsRequireDependency(this.client); |
| 319 | this.addDependency(dep); |
| 320 | if (this.active) { |
| 321 | const dep = new LazyCompilationDependency(this); |
| 322 | const block = new AsyncDependenciesBlock({}); |
| 323 | block.addDependency(dep); |
| 324 | this.addBlock(block); |
| 325 | } else if (hasClosureLibrary(compilation.options.output)) { |
| 326 | // Reserve statically-declared externals as dependencies of the inactive |
| 327 | // proxy so the initial entry chunk's library wrapper already exposes |
| 328 | // their closure identifiers (e.g. `__WEBPACK_EXTERNAL_MODULE_react__`). |
| 329 | // Once the proxy activates and the lazily-built module references those |
| 330 | // externals, the identifiers resolve normally instead of throwing. |
| 331 | const requests = collectStaticExternalRequests( |
| 332 | options.externals, |
| 333 | this.layer |
| 334 | ); |
| 335 | for (const request of requests) { |
| 336 | this.addDependency(new CommonJsRequireDependency(request)); |
| 337 | } |
| 338 | } |
| 339 | callback(); |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Returns the source types this module can generate. |
nothing calls this directly
no test coverage detected