MCPcopy
hub / github.com/webpack/webpack / asyncModuleFactory

Method asyncModuleFactory

lib/RuntimeTemplate.js:1519–1541  ·  view source on GitHub ↗

* Async module factory. * @param {object} options options * @param {AsyncDependenciesBlock} options.block the async block * @param {ChunkGraph} options.chunkGraph the chunk graph * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements * @

({ block, chunkGraph, runtimeRequirements, request })

Source from the content-addressed store, hash-verified

1517 * @returns {string} expression
1518 */
1519 asyncModuleFactory({ block, chunkGraph, runtimeRequirements, request }) {
1520 const dep = block.dependencies[0];
1521 const module = chunkGraph.moduleGraph.getModule(dep);
1522 const ensureChunk = this.blockPromise({
1523 block,
1524 message: "",
1525 chunkGraph,
1526 runtimeRequirements
1527 });
1528 const factory = this.returningFunction(
1529 this.moduleRaw({
1530 module,
1531 chunkGraph,
1532 request,
1533 runtimeRequirements
1534 })
1535 );
1536 return this.returningFunction(
1537 ensureChunk.startsWith("Promise.resolve(")
1538 ? `${factory}`
1539 : `${ensureChunk}.then(${this.returningFunction(factory)})`
1540 );
1541 }
1542
1543 /**
1544 * Sync module factory.

Callers 2

codeGenerationMethod · 0.80
codeGenerationMethod · 0.80

Calls 4

blockPromiseMethod · 0.95
returningFunctionMethod · 0.95
moduleRawMethod · 0.95
getModuleMethod · 0.45

Tested by

no test coverage detected