mirror of https://github.com/webpack/webpack.git
Use for-of loops instead of forEachModule
This commit is contained in:
parent
9334fd8547
commit
9f9e730ff3
|
|
@ -16,11 +16,11 @@ class FlagInitialModulesAsUsedPlugin {
|
|||
if(!chunk.isInitial()) {
|
||||
return;
|
||||
}
|
||||
chunk.forEachModule((module) => {
|
||||
for(const module of chunk.modulesIterable) {
|
||||
module.used = true;
|
||||
module.usedExports = true;
|
||||
module.addReason(null, null, this.explanation);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -115,11 +115,11 @@ module.exports = class HotModuleReplacementPlugin {
|
|||
const currentChunk = compilation.chunks.find(chunk => chunk.id === chunkId);
|
||||
if(currentChunk) {
|
||||
const newModules = currentChunk.getModules().filter(module => module.hotUpdate);
|
||||
const allModules = {};
|
||||
currentChunk.forEachModule(module => {
|
||||
allModules[module.id] = true;
|
||||
});
|
||||
const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules[id]);
|
||||
const allModules = new Set();
|
||||
for(const module of currentChunk.modulesIterable) {
|
||||
allModules.add(module.id);
|
||||
}
|
||||
const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules.has(id));
|
||||
if(newModules.length > 0 || removedModules.length > 0) {
|
||||
const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, compilation.hash, compilation.moduleTemplates.javascript, compilation.dependencyTemplates);
|
||||
const filename = compilation.getPath(hotUpdateChunkFilename, {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class EnsureChunkConditionsPlugin {
|
|||
const handler = (chunks) => {
|
||||
let changed = false;
|
||||
chunks.forEach((chunk) => {
|
||||
chunk.forEachModule((module) => {
|
||||
for(const module of chunk.modulesIterable) {
|
||||
if(!module.chunkCondition) return;
|
||||
if(!module.chunkCondition(chunk)) {
|
||||
let usedChunks = triesMap.get(module);
|
||||
|
|
@ -30,7 +30,7 @@ class EnsureChunkConditionsPlugin {
|
|||
chunk.removeModule(module);
|
||||
changed = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if(changed) return true;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue