* Generates runtime code for this runtime module. * @returns {string | null} runtime code
()
| 25 | * @returns {string | null} runtime code |
| 26 | */ |
| 27 | generate() { |
| 28 | const compilation = /** @type {Compilation} */ (this.compilation); |
| 29 | const { runtimeTemplate } = compilation; |
| 30 | const fn = RuntimeGlobals.asyncModule; |
| 31 | const defer = this._deferInterop; |
| 32 | const cst = runtimeTemplate.renderConst(); |
| 33 | const lt = runtimeTemplate.renderLet(); |
| 34 | return Template.asString([ |
| 35 | `${cst} hasSymbol = typeof Symbol === "function";`, |
| 36 | `${cst} webpackQueues = hasSymbol ? Symbol("webpack queues") : "__webpack_queues__";`, |
| 37 | `${cst} webpackExports = ${ |
| 38 | defer ? `${RuntimeGlobals.asyncModuleExportSymbol}= ` : "" |
| 39 | }hasSymbol ? Symbol("webpack exports") : "${RuntimeGlobals.exports}";`, |
| 40 | `${cst} webpackError = hasSymbol ? Symbol("webpack error") : "__webpack_error__";`, |
| 41 | defer |
| 42 | ? Template.asString([ |
| 43 | `${cst} webpackDone = ${RuntimeGlobals.asyncModuleDoneSymbol} = hasSymbol ? Symbol("webpack done") : "__webpack_done__";`, |
| 44 | `${cst} webpackDefer = ${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol} = hasSymbol ? Symbol("webpack defer") : "__webpack_defer__";`, |
| 45 | `${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies} = ${runtimeTemplate.basicFunction( |
| 46 | "asyncDeps", |
| 47 | [ |
| 48 | Template.indent([ |
| 49 | `${cst} hasUnresolvedAsyncSubgraph = asyncDeps.some((id) => {`, |
| 50 | Template.indent([ |
| 51 | `${cst} cache = __webpack_module_cache__[id];`, |
| 52 | "return !cache || cache[webpackDone] === false;" |
| 53 | ]), |
| 54 | "});", |
| 55 | "if (hasUnresolvedAsyncSubgraph) {", |
| 56 | Template.indent([ |
| 57 | "return ({ then(onFulfilled, onRejected) { return Promise.all(asyncDeps.map(__webpack_require__)).then(onFulfilled, onRejected) } })" |
| 58 | ]), |
| 59 | "}" |
| 60 | ]) |
| 61 | ] |
| 62 | )}` |
| 63 | ]) |
| 64 | : "", |
| 65 | `${cst} resolveQueue = ${runtimeTemplate.basicFunction("queue", [ |
| 66 | `if(${runtimeTemplate.optionalChaining("queue", "d < 1")}) {`, |
| 67 | Template.indent([ |
| 68 | "queue.d = 1;", |
| 69 | `queue.forEach(${runtimeTemplate.expressionFunction( |
| 70 | "fn.r--", |
| 71 | "fn" |
| 72 | )});`, |
| 73 | `queue.forEach(${runtimeTemplate.expressionFunction( |
| 74 | "fn.r-- ? fn.r++ : fn()", |
| 75 | "fn" |
| 76 | )});` |
| 77 | ]), |
| 78 | "}" |
| 79 | ])}`, |
| 80 | `${cst} wrapDeps = ${runtimeTemplate.returningFunction( |
| 81 | `deps.map(${runtimeTemplate.basicFunction("dep", [ |
| 82 | 'if(dep !== null && typeof dep === "object") {', |
| 83 | Template.indent([ |
| 84 | defer |
nothing calls this directly
no test coverage detected