Skip to content

Commit

Permalink
improve HotModuleReplacementPlugin performance
Browse files Browse the repository at this point in the history
avoid unnessecary rehashing
  • Loading branch information
sokra committed May 1, 2018
1 parent 4dabf30 commit f2e5c1e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/HotModuleReplacementPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const ModuleHotDeclineDependency = require("./dependencies/ModuleHotDeclineDepen
const ConstDependency = require("./dependencies/ConstDependency");
const NullFactory = require("./NullFactory");
const ParserHelpers = require("./ParserHelpers");
const createHash = require("./util/createHash");

module.exports = class HotModuleReplacementPlugin {
constructor(options) {
Expand Down Expand Up @@ -74,9 +73,7 @@ module.exports = class HotModuleReplacementPlugin {
records.moduleHashs = {};
for (const module of compilation.modules) {
const identifier = module.identifier();
const hash = createHash(compilation.outputOptions.hashFunction);
module.updateHash(hash);
records.moduleHashs[identifier] = hash.digest("hex");
records.moduleHashs[identifier] = module.hash;
}
records.chunkHashs = {};
for (const chunk of compilation.chunks) {
Expand Down Expand Up @@ -136,9 +133,7 @@ module.exports = class HotModuleReplacementPlugin {
return;
for (const module of compilation.modules) {
const identifier = module.identifier();
let hash = createHash(compilation.outputOptions.hashFunction);
module.updateHash(hash);
hash = hash.digest("hex");
let hash = module.hash;
module.hotUpdate = records.moduleHashs[identifier] !== hash;
}
const hotUpdateMainContent = {
Expand Down

0 comments on commit f2e5c1e

Please sign in to comment.