Skip to content

Commit 2e687d0

Browse files
authored
Merge pull request webpack#6613 from brentwilton/improve-performance-of-module-concatenation-plugin
improve performance of ModuleConcatenationPlugin for loop
2 parents 3c5b104 + 39095ef commit 2e687d0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/optimize/ModuleConcatenationPlugin.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,16 @@ class ModuleConcatenationPlugin {
281281
for (const reason of newModule.reasons) {
282282
reason.dependency.module = newModule;
283283
}
284-
for (const dep of newModule.dependencies) {
284+
// TODO: remove when LTS node version contains fixed v8 version
285+
// @see https://github.com/webpack/webpack/pull/6613
286+
// Turbofan does not correctly inline for-of loops with polymorphic input arrays.
287+
// Work around issue by using a standard for loop and assigning dep.module.reasons
288+
for (let i = 0; i < newModule.dependencies.length; i++) {
289+
let dep = newModule.dependencies[i];
285290
if (dep.module) {
286-
for (const reason of dep.module.reasons) {
291+
let reasons = dep.module.reasons;
292+
for (let j = 0; j < reasons.length; j++) {
293+
let reason = reasons[j];
287294
if (reason.dependency === dep) reason.module = newModule;
288295
}
289296
}

0 commit comments

Comments
 (0)