Skip to content

Commit f2e5c1e

Browse files
committed
improve HotModuleReplacementPlugin performance
avoid unnessecary rehashing
1 parent 4dabf30 commit f2e5c1e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/HotModuleReplacementPlugin.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const ModuleHotDeclineDependency = require("./dependencies/ModuleHotDeclineDepen
1212
const ConstDependency = require("./dependencies/ConstDependency");
1313
const NullFactory = require("./NullFactory");
1414
const ParserHelpers = require("./ParserHelpers");
15-
const createHash = require("./util/createHash");
1615

1716
module.exports = class HotModuleReplacementPlugin {
1817
constructor(options) {
@@ -74,9 +73,7 @@ module.exports = class HotModuleReplacementPlugin {
7473
records.moduleHashs = {};
7574
for (const module of compilation.modules) {
7675
const identifier = module.identifier();
77-
const hash = createHash(compilation.outputOptions.hashFunction);
78-
module.updateHash(hash);
79-
records.moduleHashs[identifier] = hash.digest("hex");
76+
records.moduleHashs[identifier] = module.hash;
8077
}
8178
records.chunkHashs = {};
8279
for (const chunk of compilation.chunks) {
@@ -136,9 +133,7 @@ module.exports = class HotModuleReplacementPlugin {
136133
return;
137134
for (const module of compilation.modules) {
138135
const identifier = module.identifier();
139-
let hash = createHash(compilation.outputOptions.hashFunction);
140-
module.updateHash(hash);
141-
hash = hash.digest("hex");
136+
let hash = module.hash;
142137
module.hotUpdate = records.moduleHashs[identifier] !== hash;
143138
}
144139
const hotUpdateMainContent = {

0 commit comments

Comments
 (0)