* Run all HTML dependency templates against the original module source and * return the rewritten HTML. When `undoPath` is a string, `[webpack/auto]` * placeholders left in by asset/url dependencies are resolved to that * undo path (use `""` to make URLs root-relative). When `undoPath` is *
(module, generateContext, undoPath)
| 379 | * @returns {string} the rewritten HTML |
| 380 | */ |
| 381 | _renderHtml(module, generateContext, undoPath) { |
| 382 | // The dependency-template pass is identical for both type passes (no |
| 383 | // template branches on `type` or writes `runtimeRequirements`), so |
| 384 | // compute the raw render once per `codeGeneration()` and reuse it; the |
| 385 | // passes diverge only in the `[webpack/auto]` substitution below. |
| 386 | const cacheKey = generateContext.runtimeRequirements; |
| 387 | let rawContent = this._rawRenderCache.get(cacheKey); |
| 388 | if (rawContent === undefined) { |
| 389 | const originalSource = /** @type {Source} */ (module.originalSource()); |
| 390 | const source = new ReplaceSource(originalSource); |
| 391 | /** @type {InitFragment<GenerateContext>[]} */ |
| 392 | const initFragments = []; |
| 393 | |
| 394 | this.sourceModule(module, initFragments, source, generateContext); |
| 395 | rawContent = /** @type {string} */ (source.source()); |
| 396 | this._rawRenderCache.set(cacheKey, rawContent); |
| 397 | } |
| 398 | |
| 399 | if (undoPath === undefined) { |
| 400 | // HTML output — leave sentinels and `[webpack/auto]` for renderManifest. |
| 401 | return rawContent; |
| 402 | } |
| 403 | |
| 404 | // JS-export path — resolve `[webpack/auto]` inline; chunk-URL sentinels |
| 405 | // stay for `HtmlModulesPlugin`'s `JavascriptModulesPlugin.render` tap. |
| 406 | return rawContent.split(PUBLIC_PATH_AUTO).join(undoPath); |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Generates generated code for this runtime module. |
no test coverage detected