diff --git a/lib/Compilation.js b/lib/Compilation.js index e779be834..24c52d09d 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -2021,8 +2021,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si const unsafeCacheableModule = /** @type {ModuleWithRestoreFromUnsafeCache} */ (module); - for (let i = 0; i < dependencies.length; i++) { - const dependency = dependencies[i]; + for (const dependency of dependencies) { moduleGraph.setResolvedModule( connectOrigin ? originModule : null, dependency, @@ -2038,8 +2037,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si } } else { applyFactoryResultDependencies(); - for (let i = 0; i < dependencies.length; i++) { - const dependency = dependencies[i]; + for (const dependency of dependencies) { moduleGraph.setResolvedModule( connectOrigin ? originModule : null, dependency, @@ -3435,18 +3433,13 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o */ reportDependencyErrorsAndWarnings(module, blocks) { let hasProblems = false; - for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) { - const block = blocks[indexBlock]; + for (const block of blocks) { const dependencies = block.dependencies; - for (let indexDep = 0; indexDep < dependencies.length; indexDep++) { - const d = dependencies[indexDep]; - + for (const d of dependencies) { const warnings = d.getWarnings(this.moduleGraph); if (warnings) { - for (let indexWar = 0; indexWar < warnings.length; indexWar++) { - const w = warnings[indexWar]; - + for (const w of warnings) { const warning = new ModuleDependencyWarning(module, w, d.loc); this.warnings.push(warning); hasProblems = true; @@ -3454,9 +3447,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o } const errors = d.getErrors(this.moduleGraph); if (errors) { - for (let indexErr = 0; indexErr < errors.length; indexErr++) { - const e = errors[indexErr]; - + for (const e of errors) { const error = new ModuleDependencyError(module, e, d.loc); this.errors.push(error); hasProblems = true; @@ -4161,16 +4152,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o }; const blocks = block.blocks; - for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) { - const asyncBlock = blocks[indexBlock]; + for (const asyncBlock of blocks) { const chunkGroup = /** @type {ChunkGroup} */ (this.chunkGraph.getBlockChunkGroup(asyncBlock)); // Grab all chunks from the first Block's AsyncDepBlock const chunks = chunkGroup.chunks; // For each chunk in chunkGroup - for (let indexChunk = 0; indexChunk < chunks.length; indexChunk++) { - const iteratedChunk = chunks[indexChunk]; + for (const iteratedChunk of chunks) { chunkGroup.removeChunk(iteratedChunk); // Recurse this.removeChunkFromDependencies(block, iteratedChunk); @@ -4211,13 +4200,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o } summarizeDependencies() { - for ( - let indexChildren = 0; - indexChildren < this.children.length; - indexChildren++ - ) { - const child = this.children[indexChildren]; - + for (const child of this.children) { this.fileDependencies.addAll(child.fileDependencies); this.contextDependencies.addAll(child.contextDependencies); this.missingDependencies.addAll(child.missingDependencies);