* Generates generated code for this runtime module. * @param {NormalModule} module module for which the code should be generated * @param {GenerateContext} generateContext context for generate * @returns {Source | null} generated code
(module, generateContext)
| 558 | * @returns {Source | null} generated code |
| 559 | */ |
| 560 | generate(module, generateContext) { |
| 561 | const { |
| 562 | type, |
| 563 | getData, |
| 564 | runtimeTemplate, |
| 565 | runtimeRequirements, |
| 566 | concatenationScope |
| 567 | } = generateContext; |
| 568 | |
| 569 | /** @type {string} */ |
| 570 | let content; |
| 571 | |
| 572 | const needContent = type === JAVASCRIPT_TYPE || type === ASSET_URL_TYPE; |
| 573 | const data = getData ? getData() : undefined; |
| 574 | |
| 575 | if ( |
| 576 | /** @type {AssetModuleBuildInfo} */ |
| 577 | (module.buildInfo).dataUrl && |
| 578 | needContent |
| 579 | ) { |
| 580 | const encodedSource = this.generateDataUri(module); |
| 581 | content = |
| 582 | type === JAVASCRIPT_TYPE |
| 583 | ? JSON.stringify(encodedSource) |
| 584 | : encodedSource; |
| 585 | |
| 586 | if (data) { |
| 587 | data.set("url", { ...data.get("url"), [type]: content }); |
| 588 | } |
| 589 | } else { |
| 590 | const [fullContentHash, contentHash] = AssetGenerator.getFullContentHash( |
| 591 | module, |
| 592 | runtimeTemplate |
| 593 | ); |
| 594 | |
| 595 | if (data) { |
| 596 | data.set("fullContentHash", fullContentHash); |
| 597 | data.set("contentHash", contentHash); |
| 598 | } |
| 599 | |
| 600 | /** @type {AssetModuleBuildInfo} */ |
| 601 | (module.buildInfo).fullContentHash = fullContentHash; |
| 602 | |
| 603 | const { originalFilename, filename, assetInfo } = |
| 604 | AssetGenerator.getFilenameWithInfo( |
| 605 | module, |
| 606 | { filename: this.filename, outputPath: this.outputPath }, |
| 607 | generateContext, |
| 608 | contentHash, |
| 609 | fullContentHash |
| 610 | ); |
| 611 | |
| 612 | if (data) { |
| 613 | data.set("filename", filename); |
| 614 | } |
| 615 | |
| 616 | let { assetPath, assetInfo: newAssetInfo } = |
| 617 | AssetGenerator.getAssetPathWithInfo( |
nothing calls this directly
no test coverage detected