Skip to content

Commit 9f9e730

Browse files
committed
Use for-of loops instead of forEachModule
1 parent 9334fd8 commit 9f9e730

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/FlagInitialModulesAsUsedPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class FlagInitialModulesAsUsedPlugin {
1616
if(!chunk.isInitial()) {
1717
return;
1818
}
19-
chunk.forEachModule((module) => {
19+
for(const module of chunk.modulesIterable) {
2020
module.used = true;
2121
module.usedExports = true;
2222
module.addReason(null, null, this.explanation);
23-
});
23+
}
2424
});
2525
});
2626
});

lib/HotModuleReplacementPlugin.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ module.exports = class HotModuleReplacementPlugin {
115115
const currentChunk = compilation.chunks.find(chunk => chunk.id === chunkId);
116116
if(currentChunk) {
117117
const newModules = currentChunk.getModules().filter(module => module.hotUpdate);
118-
const allModules = {};
119-
currentChunk.forEachModule(module => {
120-
allModules[module.id] = true;
121-
});
122-
const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules[id]);
118+
const allModules = new Set();
119+
for(const module of currentChunk.modulesIterable) {
120+
allModules.add(module.id);
121+
}
122+
const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules.has(id));
123123
if(newModules.length > 0 || removedModules.length > 0) {
124124
const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, compilation.hash, compilation.moduleTemplates.javascript, compilation.dependencyTemplates);
125125
const filename = compilation.getPath(hotUpdateChunkFilename, {

lib/optimize/EnsureChunkConditionsPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class EnsureChunkConditionsPlugin {
1212
const handler = (chunks) => {
1313
let changed = false;
1414
chunks.forEach((chunk) => {
15-
chunk.forEachModule((module) => {
15+
for(const module of chunk.modulesIterable) {
1616
if(!module.chunkCondition) return;
1717
if(!module.chunkCondition(chunk)) {
1818
let usedChunks = triesMap.get(module);
@@ -30,7 +30,7 @@ class EnsureChunkConditionsPlugin {
3030
chunk.removeModule(module);
3131
changed = true;
3232
}
33-
});
33+
}
3434
});
3535
if(changed) return true;
3636
};

0 commit comments

Comments
 (0)