Skip to content

Commit 502bfe4

Browse files
committed
improve hashing for wasm
1 parent b72e363 commit 502bfe4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎lib/wasm/WasmMainTemplatePlugin.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ class WasmMainTemplatePlugin {
214214
hash.update("1");
215215
hash.update(`${mainTemplate.outputOptions.webassemblyModuleFilename}`);
216216
});
217+
mainTemplate.hooks.hashForChunk.tap(
218+
"WasmMainTemplatePlugin",
219+
(hash, chunk) => {
220+
const chunkModuleMaps = chunk.getChunkModuleMaps(m =>
221+
m.type.startsWith("webassembly")
222+
);
223+
hash.update(JSON.stringify(chunkModuleMaps.id));
224+
const wasmModules = getAllWasmModules(chunk);
225+
for (const module of wasmModules) {
226+
hash.update(module.hash);
227+
}
228+
}
229+
);
217230
}
218231
}
219232

0 commit comments

Comments
 (0)