add additional arguments to updateHash

This commit is contained in:
Tobias Koppers 2018-07-17 16:42:05 +02:00
parent df204b8e35
commit f68c1f7ab6
20 changed files with 68 additions and 37 deletions

View File

@ -9,6 +9,7 @@ const DependenciesBlock = require("./DependenciesBlock");
/** @typedef {import("./ChunkGroup")} ChunkGroup */ /** @typedef {import("./ChunkGroup")} ChunkGroup */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./util/createHash").Hash} Hash */ /** @typedef {import("./util/createHash").Hash} Hash */
/** @typedef {TODO} GroupOptions */ /** @typedef {TODO} GroupOptions */
@ -54,9 +55,10 @@ module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update(JSON.stringify(this.groupOptions)); hash.update(JSON.stringify(this.groupOptions));
hash.update( hash.update(
(this.chunkGroup && (this.chunkGroup &&
@ -67,7 +69,7 @@ module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
.join(",")) || .join(",")) ||
"" ""
); );
super.updateHash(hash); super.updateHash(hash, compilation);
} }
/** /**

View File

@ -2159,7 +2159,7 @@ class Compilation {
for (let i = 0; i < modules.length; i++) { for (let i = 0; i < modules.length; i++) {
const module = modules[i]; const module = modules[i];
const moduleHash = createHash(hashFunction); const moduleHash = createHash(hashFunction);
module.updateHash(moduleHash); module.updateHash(moduleHash, this);
module.hash = moduleHash.digest(hashDigest); module.hash = moduleHash.digest(hashDigest);
module.renderedHash = module.hash.substr(0, hashDigestLength); module.renderedHash = module.hash.substr(0, hashDigestLength);
} }

View File

@ -138,12 +138,13 @@ class DelegatedModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update(this.type); hash.update(this.type);
hash.update(JSON.stringify(this.request)); hash.update(JSON.stringify(this.request));
super.updateHash(hash); super.updateHash(hash, compilation);
} }
} }

View File

@ -7,6 +7,7 @@
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */ /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
/** @typedef {import("./ChunkGroup")} ChunkGroup */ /** @typedef {import("./ChunkGroup")} ChunkGroup */
/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Dependency")} Dependency */ /** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./util/createHash").Hash} Hash */ /** @typedef {import("./util/createHash").Hash} Hash */
@ -54,11 +55,13 @@ class DependenciesBlock {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
for (const dep of this.dependencies) dep.updateHash(hash); for (const dep of this.dependencies)
for (const block of this.blocks) block.updateHash(hash); dep.updateHash(hash, compilation.moduleGraph);
for (const block of this.blocks) block.updateHash(hash, compilation);
} }
disconnect() { disconnect() {

View File

@ -10,6 +10,7 @@ const DependencyReference = require("./dependencies/DependencyReference");
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */ /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("./WebpackError")} WebpackError */ /** @typedef {import("./WebpackError")} WebpackError */
/** @typedef {import("./util/createHash").Hash} Hash */ /** @typedef {import("./util/createHash").Hash} Hash */
@ -101,9 +102,10 @@ class Dependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
hash.update((this.module && this.module.id) + ""); hash.update((this.module && this.module.id) + "");
} }

View File

@ -83,12 +83,13 @@ class DllModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update("dll module"); hash.update("dll module");
hash.update(this.name || ""); hash.update(this.name || "");
super.updateHash(hash); super.updateHash(hash, compilation);
} }
} }

View File

@ -221,13 +221,14 @@ class ExternalModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update(this.externalType); hash.update(this.externalType);
hash.update(JSON.stringify(this.request)); hash.update(JSON.stringify(this.request));
hash.update(JSON.stringify(Boolean(this.optional))); hash.update(JSON.stringify(Boolean(this.optional)));
super.updateHash(hash); super.updateHash(hash, compilation);
} }
} }

View File

@ -405,12 +405,13 @@ class Module extends DependenciesBlock {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update(`${this.id}`); hash.update(`${this.id}`);
hash.update(JSON.stringify(this.usedExports)); hash.update(JSON.stringify(this.usedExports));
super.updateHash(hash); super.updateHash(hash, compilation);
} }
/** /**

View File

@ -77,12 +77,13 @@ class MultiModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update("multi module"); hash.update("multi module");
hash.update(this.name || ""); hash.update(this.name || "");
super.updateHash(hash); super.updateHash(hash, compilation);
} }
/** /**

View File

@ -575,11 +575,12 @@ class NormalModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update(this._buildHash); hash.update(this._buildHash);
super.updateHash(hash); super.updateHash(hash, compilation);
} }
} }

View File

@ -88,10 +88,11 @@ module.exports = class RawModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
hash.update(this.sourceStr); hash.update(this.sourceStr);
super.updateHash(hash); super.updateHash(hash, compilation);
} }
}; };

View File

@ -13,6 +13,7 @@ const NullDependency = require("./NullDependency");
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */ /** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -27,9 +28,10 @@ class CachedConstDependency extends NullDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
hash.update(this.identifier + ""); hash.update(this.identifier + "");
hash.update(this.range + ""); hash.update(this.range + "");
hash.update(this.expression + ""); hash.update(this.expression + "");

View File

@ -10,6 +10,7 @@ const NullDependency = require("./NullDependency");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -24,9 +25,10 @@ class ConstDependency extends NullDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
hash.update(this.range + ""); hash.update(this.range + "");
hash.update(this.expression + ""); hash.update(this.expression + "");
} }

View File

@ -17,6 +17,7 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
/** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */ /** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../Module")} Module */ /** @typedef {import("../Module")} Module */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../WebpackError")} WebpackError */ /** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -412,10 +413,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
super.updateHash(hash); super.updateHash(hash, moduleGraph);
const hashValue = this.getHashValue(this._module); const hashValue = this.getHashValue(this._module);
hash.update(hashValue); hash.update(hashValue);
} }

View File

@ -15,6 +15,7 @@ const ModuleDependency = require("./ModuleDependency");
/** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */ /** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../Module")} Module */ /** @typedef {import("../Module")} Module */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -70,10 +71,11 @@ class HarmonyImportDependency extends ModuleDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
super.updateHash(hash); super.updateHash(hash, moduleGraph);
const importedModule = this._module; const importedModule = this._module;
hash.update( hash.update(
(importedModule && (importedModule &&

View File

@ -13,6 +13,7 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../WebpackError")} WebpackError */ /** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -142,10 +143,11 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
super.updateHash(hash); super.updateHash(hash, moduleGraph);
const importedModule = this._module; const importedModule = this._module;
hash.update((importedModule && this._id) + ""); hash.update((importedModule && this._id) + "");
hash.update( hash.update(

View File

@ -12,6 +12,7 @@ const ModuleDependency = require("./ModuleDependency");
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */ /** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -24,10 +25,11 @@ class ModuleDecoratorDependency extends ModuleDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
super.updateHash(hash); super.updateHash(hash, moduleGraph);
hash.update("module decorator"); hash.update("module decorator");
} }
} }

View File

@ -11,6 +11,7 @@ const DependencyTemplate = require("../DependencyTemplate");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -22,9 +23,10 @@ class NullDependency extends Dependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) {} updateHash(hash, moduleGraph) {}
} }
NullDependency.Template = class NullDependencyTemplate extends DependencyTemplate { NullDependency.Template = class NullDependencyTemplate extends DependencyTemplate {

View File

@ -12,6 +12,7 @@ const ModuleDependency = require("./ModuleDependency");
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */ /** @typedef {import("../DependencyTemplate").TemplateContext} TemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../util/createHash").Hash} Hash */ /** @typedef {import("../util/createHash").Hash} Hash */
@ -35,10 +36,11 @@ class ProvidedDependency extends ModuleDependency {
/** /**
* Update the hash * Update the hash
* @param {Hash} hash hash to be updated * @param {Hash} hash hash to be updated
* @param {ModuleGraph} moduleGraph module graph
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, moduleGraph) {
super.updateHash(hash); super.updateHash(hash, moduleGraph);
hash.update(this.identifier); hash.update(this.identifier);
hash.update(this.path ? this.path.join(",") : "null"); hash.update(this.path ? this.path.join(",") : "null");
} }

View File

@ -1207,20 +1207,21 @@ class ConcatenatedModule extends Module {
/** /**
* @param {Hash} hash the hash used to track dependencies * @param {Hash} hash the hash used to track dependencies
* @param {Compilation} compilation the compilation
* @returns {void} * @returns {void}
*/ */
updateHash(hash) { updateHash(hash, compilation) {
for (const info of this._orderedConcatenationList) { for (const info of this._orderedConcatenationList) {
switch (info.type) { switch (info.type) {
case "concatenated": case "concatenated":
info.module.updateHash(hash); info.module.updateHash(hash, compilation);
break; break;
case "external": case "external":
hash.update(`${info.module.id}`); hash.update(`${info.module.id}`);
break; break;
} }
} }
super.updateHash(hash); super.updateHash(hash, compilation);
} }
} }