* Updates the hash with the data contributed by this instance. * @param {Hash} hash hash that will be modified * @param {UpdateHashContext} updateHashContext context for updating hash
(hash, updateHashContext)
| 803 | * @param {UpdateHashContext} updateHashContext context for updating hash |
| 804 | */ |
| 805 | updateHash(hash, updateHashContext) { |
| 806 | const { module } = updateHashContext; |
| 807 | |
| 808 | if ( |
| 809 | /** @type {AssetModuleBuildInfo} */ |
| 810 | (module.buildInfo).dataUrl |
| 811 | ) { |
| 812 | hash.update("data-url"); |
| 813 | // this.dataUrlOptions as function should be pure and only depend on input source and filename |
| 814 | // therefore it doesn't need to be hashed |
| 815 | if (typeof this.dataUrlOptions === "function") { |
| 816 | const ident = /** @type {{ ident?: string }} */ (this.dataUrlOptions) |
| 817 | .ident; |
| 818 | if (ident) hash.update(ident); |
| 819 | } else { |
| 820 | const dataUrlOptions = |
| 821 | /** @type {AssetGeneratorDataUrlOptions} */ |
| 822 | (this.dataUrlOptions); |
| 823 | if ( |
| 824 | dataUrlOptions.encoding && |
| 825 | dataUrlOptions.encoding !== DEFAULT_ENCODING |
| 826 | ) { |
| 827 | hash.update(dataUrlOptions.encoding); |
| 828 | } |
| 829 | if (dataUrlOptions.mimetype) hash.update(dataUrlOptions.mimetype); |
| 830 | // computed mimetype depends only on module filename which is already part of the hash |
| 831 | } |
| 832 | } else { |
| 833 | hash.update("resource"); |
| 834 | |
| 835 | const { module, chunkGraph, runtime } = updateHashContext; |
| 836 | const runtimeTemplate = |
| 837 | /** @type {NonNullable<UpdateHashContext["runtimeTemplate"]>} */ |
| 838 | (updateHashContext.runtimeTemplate); |
| 839 | |
| 840 | const pathData = { |
| 841 | module, |
| 842 | runtime, |
| 843 | filename: AssetGenerator.getSourceFileName(module, runtimeTemplate), |
| 844 | chunkGraph, |
| 845 | contentHash: runtimeTemplate.contentHashReplacement |
| 846 | }; |
| 847 | |
| 848 | if (typeof this.publicPath === "function") { |
| 849 | hash.update("path"); |
| 850 | const assetInfo = {}; |
| 851 | hash.update(this.publicPath(pathData, assetInfo)); |
| 852 | hash.update(JSON.stringify(assetInfo)); |
| 853 | } else if (this.publicPath) { |
| 854 | hash.update("path"); |
| 855 | hash.update(this.publicPath); |
| 856 | } else { |
| 857 | hash.update("no-path"); |
| 858 | } |
| 859 | |
| 860 | const assetModuleFilename = |
| 861 | this.filename || runtimeTemplate.outputOptions.assetModuleFilename; |
| 862 | const { path: filename, info } = |
nothing calls this directly
no test coverage detected