Skip to content

Commit

Permalink
store hash in depndencyTemplates Map instead of comparing identify
Browse files Browse the repository at this point in the history
This restores original performance on incremental builds

fixes #5289
fixes #5277
  • Loading branch information
sokra committed Jul 14, 2017
1 parent 981fd23 commit c1a0244
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/Compilation.js
Expand Up @@ -80,6 +80,7 @@ class Compilation extends Tapable {
this.children = [];
this.dependencyFactories = new Map();
this.dependencyTemplates = new Map();
this.dependencyTemplates.set("hash", "");
this.childrenCounters = {};
}

Expand Down
9 changes: 4 additions & 5 deletions lib/NormalModule.js
Expand Up @@ -54,6 +54,8 @@ class NonErrorEmittedError extends WebpackError {
}
}

const dependencyTemplatesHashMap = new WeakMap();

class NormalModule extends Module {

constructor(request, userRequest, rawRequest, loaders, resource, parser) {
Expand All @@ -74,7 +76,6 @@ class NormalModule extends Module {
this.assets = {};
this.built = false;
this._cachedSource = null;
this._dependencyTemplatesHashMap = new Map();
}

identifier() {
Expand Down Expand Up @@ -307,12 +308,10 @@ class NormalModule extends Module {
}

getHashDigest(dependencyTemplates) {
let dtId = this._dependencyTemplatesHashMap.get(dependencyTemplates);
if(dtId === undefined)
this._dependencyTemplatesHashMap.set(dependencyTemplates, dtId = this._dependencyTemplatesHashMap.size + 1);
let dtHash = dependencyTemplatesHashMap.get("hash");
const hash = crypto.createHash("md5");
this.updateHash(hash);
hash.update(`${dtId}`);
hash.update(`${dtHash}`);
return hash.digest("hex");
}

Expand Down
1 change: 1 addition & 0 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -301,6 +301,7 @@ class ConcatenatedModule extends Module {
this.rootModule,
moduleToInfoMap
));
innerDependencyTemplates.set("hash", innerDependencyTemplates.get("hash") + this.rootModule.identifier());

// Generate source code and analyse scopes
// Prepare a ReplaceSource for the final source
Expand Down

0 comments on commit c1a0244

Please sign in to comment.