* 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 })
| 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. |
no test coverage detected