use better hash for renderManifest to avoid unnecessary invalidation
add bootstrap code to content hash
This commit is contained in:
parent
6d813cadda
commit
56cb8f0686
|
@ -275,7 +275,7 @@ class JavascriptModulesPlugin {
|
|||
identifier: hotUpdateChunk
|
||||
? `hotupdatechunk${chunk.id}`
|
||||
: `chunk${chunk.id}`,
|
||||
hash: chunk.hash
|
||||
hash: chunk.contentHash.javascript
|
||||
});
|
||||
|
||||
return result;
|
||||
|
@ -286,7 +286,8 @@ class JavascriptModulesPlugin {
|
|||
(chunk, hash, context) => {
|
||||
hooks.chunkHash.call(chunk, hash, context);
|
||||
if (chunk.hasRuntime()) {
|
||||
const bootstrap = this.renderBootstrap(
|
||||
this.updateHashWithBootstrap(
|
||||
hash,
|
||||
{
|
||||
hash: "0000",
|
||||
chunk,
|
||||
|
@ -296,16 +297,6 @@ class JavascriptModulesPlugin {
|
|||
},
|
||||
hooks
|
||||
);
|
||||
for (const key of Object.keys(bootstrap)) {
|
||||
hash.update(key);
|
||||
if (Array.isArray(bootstrap[key])) {
|
||||
for (const line of bootstrap[key]) {
|
||||
hash.update(line);
|
||||
}
|
||||
} else {
|
||||
hash.update(JSON.stringify(bootstrap[key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -323,8 +314,22 @@ class JavascriptModulesPlugin {
|
|||
} = compilation;
|
||||
const hash = createHash(hashFunction);
|
||||
if (hashSalt) hash.update(hashSalt);
|
||||
hash.update(`${chunk.id} `);
|
||||
hash.update(chunk.ids ? chunk.ids.join(",") : "");
|
||||
if (chunk.hasRuntime()) {
|
||||
this.updateHashWithBootstrap(
|
||||
hash,
|
||||
{
|
||||
hash: "0000",
|
||||
chunk,
|
||||
chunkGraph: compilation.chunkGraph,
|
||||
moduleGraph: compilation.moduleGraph,
|
||||
runtimeTemplate: compilation.runtimeTemplate
|
||||
},
|
||||
hooks
|
||||
);
|
||||
} else {
|
||||
hash.update(`${chunk.id} `);
|
||||
hash.update(chunk.ids ? chunk.ids.join(",") : "");
|
||||
}
|
||||
hooks.chunkHash.call(chunk, hash, {
|
||||
chunkGraph,
|
||||
moduleGraph,
|
||||
|
@ -685,6 +690,25 @@ class JavascriptModulesPlugin {
|
|||
return iife ? new ConcatSource(finalSource, ";") : finalSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Hash} hash the hash to be updated
|
||||
* @param {RenderBootstrapContext} renderContext options object
|
||||
* @param {CompilationHooks} hooks hooks
|
||||
*/
|
||||
updateHashWithBootstrap(hash, renderContext, hooks) {
|
||||
const bootstrap = this.renderBootstrap(renderContext, hooks);
|
||||
for (const key of Object.keys(bootstrap)) {
|
||||
hash.update(key);
|
||||
if (Array.isArray(bootstrap[key])) {
|
||||
for (const line of bootstrap[key]) {
|
||||
hash.update(line);
|
||||
}
|
||||
} else {
|
||||
hash.update(JSON.stringify(bootstrap[key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {RenderBootstrapContext} renderContext options object
|
||||
* @param {CompilationHooks} hooks hooks
|
||||
|
|
|
@ -902,7 +902,7 @@ webpack x.x.x compiled with 2 warnings in X ms"
|
|||
`;
|
||||
|
||||
exports[`StatsTestCases should print correct stats for immutable 1`] = `
|
||||
"asset c30341ca2ed860460ce7.js 12.5 KiB [emitted] [immutable] (name: main)
|
||||
"asset 4612e1413cd58e88e146.js 12.5 KiB [emitted] [immutable] (name: main)
|
||||
asset b815a02217b4cae51059.js 884 bytes [emitted] [immutable]"
|
||||
`;
|
||||
|
||||
|
|
Loading…
Reference in New Issue