webpack 5.109.0 → 5.109.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/bin/webpack.js +12 -0
  2. package/lib/ChunkGraph.js +17 -15
  3. package/lib/CompatibilityPlugin.js +31 -0
  4. package/lib/Compilation.js +9 -2
  5. package/lib/DefinePlugin.js +37 -11
  6. package/lib/ExportsInfo.js +22 -5
  7. package/lib/FileSystemInfo.js +126 -26
  8. package/lib/FlagDependencyUsagePlugin.js +33 -12
  9. package/lib/InitFragment.js +20 -32
  10. package/lib/NormalModule.js +6 -0
  11. package/lib/RuntimePlugin.js +40 -113
  12. package/lib/Template.js +23 -3
  13. package/lib/container/HoistContainerReferencesPlugin.js +47 -55
  14. package/lib/css/CssParser.js +135 -50
  15. package/lib/css/syntax.js +862 -765
  16. package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
  17. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
  18. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +17 -9
  19. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  20. package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -7
  21. package/lib/hmr/lazyCompilationBackend.js +19 -4
  22. package/lib/html/HtmlGenerator.js +23 -3
  23. package/lib/html/syntax.js +2485 -2399
  24. package/lib/ids/IdHelpers.js +24 -10
  25. package/lib/javascript/JavascriptParser.js +5 -2
  26. package/lib/javascript/syntax.js +700 -43
  27. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -2
  28. package/lib/node/ReadFileCompileWasmPlugin.js +10 -2
  29. package/lib/optimize/AggressiveMergingPlugin.js +19 -15
  30. package/lib/optimize/ConcatenatedModule.js +19 -15
  31. package/lib/optimize/ModuleConcatenationPlugin.js +73 -24
  32. package/lib/optimize/SplitChunksPlugin.js +146 -44
  33. package/lib/prefetch/ResourceHintPlugin.js +96 -72
  34. package/lib/serialization/BinaryMiddleware.js +270 -938
  35. package/lib/stats/DefaultStatsFactoryPlugin.js +204 -198
  36. package/lib/stats/DefaultStatsPrinterPlugin.js +24 -166
  37. package/lib/stats/StatsFactory.js +31 -9
  38. package/package.json +2 -2
  39. package/types.d.ts +0 -4
@@ -28,30 +28,6 @@ const makeSerializable = require("./util/makeSerializable");
28
28
  * @property {(fragments: MaybeMergeableInitFragment<GenerateContext>[]) => MaybeMergeableInitFragment<GenerateContext>[]=} mergeAll
29
29
  */
30
30
 
31
- /**
32
- * Extract fragment index.
33
- * @template T
34
- * @param {T} fragment the init fragment
35
- * @param {number} index index
36
- * @returns {[T, number]} tuple with both
37
- */
38
- const extractFragmentIndex = (fragment, index) => [fragment, index];
39
-
40
- /**
41
- * Sorts fragment with index.
42
- * @template T
43
- * @param {[MaybeMergeableInitFragment<T>, number]} a first pair
44
- * @param {[MaybeMergeableInitFragment<T>, number]} b second pair
45
- * @returns {number} sort value
46
- */
47
- const sortFragmentWithIndex = ([a, i], [b, j]) => {
48
- const stageCmp = a.stage - b.stage;
49
- if (stageCmp !== 0) return stageCmp;
50
- const positionCmp = a.position - b.position;
51
- if (positionCmp !== 0) return positionCmp;
52
- return i - j;
53
- };
54
-
55
31
  /**
56
32
  * Represents InitFragment.
57
33
  * @template GenerateContext
@@ -107,16 +83,28 @@ class InitFragment {
107
83
  */
108
84
  static addToSource(source, initFragments, context) {
109
85
  if (initFragments.length > 0) {
110
- // Sort fragments by position. If 2 fragments have the same position,
111
- // use their index.
112
- const sortedFragments = initFragments
113
- .map(extractFragmentIndex)
114
- .sort(sortFragmentWithIndex);
86
+ // Sort fragment indices by (stage, position), falling back to the
87
+ // original index — one flat number array instead of N [fragment, index]
88
+ // tuples for a stable-by-index order.
89
+ const sortedIndices = initFragments.map((_, index) => index);
90
+ sortedIndices.sort((a, b) => {
91
+ const fragmentA = initFragments[a];
92
+ const fragmentB = initFragments[b];
93
+ const stageCmp = fragmentA.stage - fragmentB.stage;
94
+ if (stageCmp !== 0) return stageCmp;
95
+ const positionCmp = fragmentA.position - fragmentB.position;
96
+ if (positionCmp !== 0) return positionCmp;
97
+ return a - b;
98
+ });
115
99
 
116
100
  // Deduplicate fragments. If a fragment has no key, it is always included.
117
- /** @type {Map<InitFragmentKey | symbol, MaybeMergeableInitFragment<Context> | MaybeMergeableInitFragment<Context>[]>} */
101
+ // Keyless fragments get a unique numeric key; number keys never collide
102
+ // with the string `InitFragmentKey`s used for keyed fragments.
103
+ /** @type {Map<InitFragmentKey | number, MaybeMergeableInitFragment<Context> | MaybeMergeableInitFragment<Context>[]>} */
118
104
  const keyedFragments = new Map();
119
- for (const [fragment] of sortedFragments) {
105
+ let keylessKey = 0;
106
+ for (const index of sortedIndices) {
107
+ const fragment = initFragments[index];
120
108
  if (typeof fragment.mergeAll === "function") {
121
109
  if (!fragment.key) {
122
110
  throw new Error(
@@ -142,7 +130,7 @@ class InitFragment {
142
130
  continue;
143
131
  }
144
132
  }
145
- keyedFragments.set(fragment.key || Symbol("fragment key"), fragment);
133
+ keyedFragments.set(fragment.key || keylessKey++, fragment);
146
134
  }
147
135
 
148
136
  const concatSource = new ConcatSource();
@@ -651,6 +651,12 @@ class NormalModule extends Module {
651
651
  * @type {Source | null}
652
652
  */
653
653
  this._source = null;
654
+ // Set at build time; declared here so the instance shape is fixed at construction
655
+ /**
656
+ * @private
657
+ * @type {PreparsedAst | null}
658
+ */
659
+ this._ast = null;
654
660
  /**
655
661
  * @private
656
662
  * @type {Map<undefined | SourceType, number> | undefined}
@@ -119,6 +119,33 @@ const TREE_DEPENDENCIES = {
119
119
  [RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
120
120
  };
121
121
 
122
+ // Tree runtime requirements whose only effect is attaching a zero-arg runtime
123
+ // module to the chunk. Conditional / argument-taking ones stay as explicit taps.
124
+ /** @type {[string, (new () => import("./RuntimeModule"))][]} */
125
+ const SIMPLE_TREE_RUNTIME_MODULES = [
126
+ [RuntimeGlobals.definePropertyGetters, DefinePropertyGettersRuntimeModule],
127
+ [RuntimeGlobals.makeNamespaceObject, MakeNamespaceObjectRuntimeModule],
128
+ [
129
+ RuntimeGlobals.createFakeNamespaceObject,
130
+ CreateFakeNamespaceObjectRuntimeModule
131
+ ],
132
+ [RuntimeGlobals.hasOwnProperty, HasOwnPropertyRuntimeModule],
133
+ [RuntimeGlobals.compatGetDefaultExport, CompatGetDefaultExportRuntimeModule],
134
+ [RuntimeGlobals.commonJsWrap, CommonJsWrapRuntimeModule],
135
+ [
136
+ RuntimeGlobals.setAnonymousDefaultName,
137
+ SetAnonymousDefaultNameRuntimeModule
138
+ ],
139
+ [RuntimeGlobals.runtimeId, RuntimeIdRuntimeModule],
140
+ [RuntimeGlobals.global, GlobalRuntimeModule],
141
+ [RuntimeGlobals.shareScopeMap, ShareRuntimeModule],
142
+ [RuntimeGlobals.relativeUrl, RelativeUrlRuntimeModule],
143
+ [RuntimeGlobals.worker, WorkerRuntimeModule],
144
+ [RuntimeGlobals.onChunksLoaded, OnChunksLoadedRuntimeModule],
145
+ [RuntimeGlobals.scriptNonce, NonceRuntimeModule],
146
+ [RuntimeGlobals.toBinary, ToBinaryRuntimeModule]
147
+ ];
148
+
122
149
  /**
123
150
  * @param {string} template path template
124
151
  * @returns {boolean} true when it references the compilation `[fullhash]`/`[hash]`
@@ -198,36 +225,20 @@ class RuntimePlugin {
198
225
  for (const dep of deps) set.add(dep);
199
226
  });
200
227
  }
201
- compilation.hooks.runtimeRequirementInTree
202
- .for(RuntimeGlobals.definePropertyGetters)
203
- .tap(PLUGIN_NAME, (chunk) => {
204
- compilation.addRuntimeModule(
205
- chunk,
206
- new DefinePropertyGettersRuntimeModule()
207
- );
208
- return true;
209
- });
210
- compilation.hooks.runtimeRequirementInTree
211
- .for(RuntimeGlobals.makeNamespaceObject)
212
- .tap(PLUGIN_NAME, (chunk) => {
213
- compilation.addRuntimeModule(
214
- chunk,
215
- new MakeNamespaceObjectRuntimeModule()
216
- );
217
- return true;
218
- });
219
- compilation.hooks.runtimeRequirementInTree
220
- .for(RuntimeGlobals.createFakeNamespaceObject)
221
- .tap(PLUGIN_NAME, (chunk) => {
222
- compilation.addRuntimeModule(
223
- chunk,
224
- new CreateFakeNamespaceObjectRuntimeModule()
225
- );
226
- return true;
227
- });
228
+ for (const [
229
+ runtimeGlobal,
230
+ RuntimeModule
231
+ ] of SIMPLE_TREE_RUNTIME_MODULES) {
232
+ compilation.hooks.runtimeRequirementInTree
233
+ .for(runtimeGlobal)
234
+ .tap(PLUGIN_NAME, (chunk) => {
235
+ compilation.addRuntimeModule(chunk, new RuntimeModule());
236
+ return true;
237
+ });
238
+ }
228
239
  compilation.hooks.runtimeRequirementInTree
229
240
  .for(RuntimeGlobals.makeOptimizedDeferredNamespaceObject)
230
- .tap("RuntimePlugin", (chunk, runtimeRequirement) => {
241
+ .tap(PLUGIN_NAME, (chunk, runtimeRequirement) => {
231
242
  compilation.addRuntimeModule(
232
243
  chunk,
233
244
  new MakeOptimizedDeferredNamespaceObjectRuntimeModule(
@@ -238,7 +249,7 @@ class RuntimePlugin {
238
249
  });
239
250
  compilation.hooks.runtimeRequirementInTree
240
251
  .for(RuntimeGlobals.makeDeferredNamespaceObject)
241
- .tap("RuntimePlugin", (chunk, runtimeRequirement) => {
252
+ .tap(PLUGIN_NAME, (chunk, runtimeRequirement) => {
242
253
  compilation.addRuntimeModule(
243
254
  chunk,
244
255
  new MakeDeferredNamespaceObjectRuntimeModule(
@@ -247,45 +258,6 @@ class RuntimePlugin {
247
258
  );
248
259
  return true;
249
260
  });
250
- compilation.hooks.runtimeRequirementInTree
251
- .for(RuntimeGlobals.hasOwnProperty)
252
- .tap(PLUGIN_NAME, (chunk) => {
253
- compilation.addRuntimeModule(
254
- chunk,
255
- new HasOwnPropertyRuntimeModule()
256
- );
257
- return true;
258
- });
259
- compilation.hooks.runtimeRequirementInTree
260
- .for(RuntimeGlobals.compatGetDefaultExport)
261
- .tap(PLUGIN_NAME, (chunk) => {
262
- compilation.addRuntimeModule(
263
- chunk,
264
- new CompatGetDefaultExportRuntimeModule()
265
- );
266
- return true;
267
- });
268
- compilation.hooks.runtimeRequirementInTree
269
- .for(RuntimeGlobals.commonJsWrap)
270
- .tap(PLUGIN_NAME, (chunk) => {
271
- compilation.addRuntimeModule(chunk, new CommonJsWrapRuntimeModule());
272
- return true;
273
- });
274
- compilation.hooks.runtimeRequirementInTree
275
- .for(RuntimeGlobals.setAnonymousDefaultName)
276
- .tap(PLUGIN_NAME, (chunk) => {
277
- compilation.addRuntimeModule(
278
- chunk,
279
- new SetAnonymousDefaultNameRuntimeModule()
280
- );
281
- return true;
282
- });
283
- compilation.hooks.runtimeRequirementInTree
284
- .for(RuntimeGlobals.runtimeId)
285
- .tap(PLUGIN_NAME, (chunk) => {
286
- compilation.addRuntimeModule(chunk, new RuntimeIdRuntimeModule());
287
- return true;
288
- });
289
261
  compilation.hooks.runtimeRequirementInTree
290
262
  .for(RuntimeGlobals.publicPath)
291
263
  .tap(PLUGIN_NAME, (chunk, set) => {
@@ -321,12 +293,6 @@ class RuntimePlugin {
321
293
  }
322
294
  return true;
323
295
  });
324
- compilation.hooks.runtimeRequirementInTree
325
- .for(RuntimeGlobals.global)
326
- .tap(PLUGIN_NAME, (chunk) => {
327
- compilation.addRuntimeModule(chunk, new GlobalRuntimeModule());
328
- return true;
329
- });
330
296
  compilation.hooks.runtimeRequirementInTree
331
297
  .for(RuntimeGlobals.asyncModule)
332
298
  .tap(PLUGIN_NAME, (chunk) => {
@@ -500,12 +466,6 @@ class RuntimePlugin {
500
466
  .tap(PLUGIN_NAME, (chunk, set) => {
501
467
  set.add(RuntimeGlobals.ensureChunkHandlers);
502
468
  });
503
- compilation.hooks.runtimeRequirementInTree
504
- .for(RuntimeGlobals.shareScopeMap)
505
- .tap(PLUGIN_NAME, (chunk, set) => {
506
- compilation.addRuntimeModule(chunk, new ShareRuntimeModule());
507
- return true;
508
- });
509
469
  compilation.hooks.runtimeRequirementInTree
510
470
  .for(RuntimeGlobals.loadScript)
511
471
  .tap(PLUGIN_NAME, (chunk, set) => {
@@ -552,27 +512,6 @@ class RuntimePlugin {
552
512
  );
553
513
  return true;
554
514
  });
555
- compilation.hooks.runtimeRequirementInTree
556
- .for(RuntimeGlobals.relativeUrl)
557
- .tap(PLUGIN_NAME, (chunk, _set) => {
558
- compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
559
- return true;
560
- });
561
- compilation.hooks.runtimeRequirementInTree
562
- .for(RuntimeGlobals.worker)
563
- .tap(PLUGIN_NAME, (chunk, _set) => {
564
- compilation.addRuntimeModule(chunk, new WorkerRuntimeModule());
565
- return true;
566
- });
567
- compilation.hooks.runtimeRequirementInTree
568
- .for(RuntimeGlobals.onChunksLoaded)
569
- .tap(PLUGIN_NAME, (chunk, _set) => {
570
- compilation.addRuntimeModule(
571
- chunk,
572
- new OnChunksLoadedRuntimeModule()
573
- );
574
- return true;
575
- });
576
515
  compilation.hooks.runtimeRequirementInTree
577
516
  .for(RuntimeGlobals.baseURI)
578
517
  .tap(PLUGIN_NAME, (chunk) => {
@@ -581,18 +520,6 @@ class RuntimePlugin {
581
520
  return true;
582
521
  }
583
522
  });
584
- compilation.hooks.runtimeRequirementInTree
585
- .for(RuntimeGlobals.scriptNonce)
586
- .tap(PLUGIN_NAME, (chunk) => {
587
- compilation.addRuntimeModule(chunk, new NonceRuntimeModule());
588
- return true;
589
- });
590
- compilation.hooks.runtimeRequirementInTree
591
- .for(RuntimeGlobals.toBinary)
592
- .tap(PLUGIN_NAME, (chunk) => {
593
- compilation.addRuntimeModule(chunk, new ToBinaryRuntimeModule());
594
- return true;
595
- });
596
523
  // TODO webpack 6: remove CompatRuntimeModule
597
524
  compilation.hooks.additionalTreeRuntimeRequirements.tap(
598
525
  PLUGIN_NAME,
package/lib/Template.js CHANGED
@@ -46,6 +46,22 @@ const COMMENT_END_REGEX = /\*\//g;
46
46
  const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-z0-9_!§$()=\-^°]+/gi;
47
47
  const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
48
48
 
49
+ /**
50
+ * Decimal digit count of a non-negative integer, without allocating a string.
51
+ * @param {number} n non-negative integer
52
+ * @returns {number} number of decimal digits
53
+ */
54
+ const numberLength = (n) => {
55
+ if (n < 10) return 1;
56
+ if (n < 100) return 2;
57
+ if (n < 1000) return 3;
58
+ if (n < 10000) return 4;
59
+ if (n < 100000) return 5;
60
+ if (n < 1000000) return 6;
61
+ if (n < 10000000) return 7;
62
+ return String(n).length;
63
+ };
64
+
49
65
  /**
50
66
  * Defines the render manifest options type used by this module.
51
67
  * @typedef {object} RenderManifestOptions
@@ -296,11 +312,15 @@ class Template {
296
312
  // start with -1 because the first module needs no comma
297
313
  let objectOverhead = -1;
298
314
  for (const module of modules) {
299
- // module id + colon + comma
300
- objectOverhead += `${module.id}`.length + 2;
315
+ // module id digits + colon + comma; ids are non-negative integers here
316
+ // (non-number ids already returned false above), so count digits
317
+ // arithmetically instead of allocating a string per module.
318
+ const id = /** @type {number} */ (module.id);
319
+ objectOverhead += numberLength(id) + 2;
301
320
  }
302
321
  // number of commas, or when starting non-zero the length of Array(minId).concat()
303
- const arrayOverhead = minId === 0 ? maxId : 16 + `${minId}`.length + maxId;
322
+ const arrayOverhead =
323
+ minId === 0 ? maxId : 16 + numberLength(minId) + maxId;
304
324
  return arrayOverhead < objectOverhead ? [minId, maxId] : false;
305
325
  }
306
326
 
@@ -38,12 +38,13 @@ class HoistContainerReferences {
38
38
  const depsToTrace = new Set();
39
39
  /** @type {Set<Dependency>} */
40
40
  const entryExternalsToHoist = new Set();
41
- hooks.addContainerEntryDependency.tap(PLUGIN_NAME, (dep) => {
41
+ // Both hooks feed the same trace set, so they share one callback.
42
+ /** @type {(dep: Dependency) => void} */
43
+ const traceDep = (dep) => {
42
44
  depsToTrace.add(dep);
43
- });
44
- hooks.addFederationRuntimeDependency.tap(PLUGIN_NAME, (dep) => {
45
- depsToTrace.add(dep);
46
- });
45
+ };
46
+ hooks.addContainerEntryDependency.tap(PLUGIN_NAME, traceDep);
47
+ hooks.addFederationRuntimeDependency.tap(PLUGIN_NAME, traceDep);
47
48
 
48
49
  compilation.hooks.addEntry.tap(PLUGIN_NAME, (entryDep) => {
49
50
  if (entryDep.type === "entry") {
@@ -76,46 +77,26 @@ class HoistContainerReferences {
76
77
  * @param {Set<Dependency>} entryExternalsToHoist Set of container entry dependencies to hoist.
77
78
  */
78
79
  hoistModulesInChunks(compilation, depsToTrace, entryExternalsToHoist) {
79
- const { chunkGraph, moduleGraph } = compilation;
80
+ const { moduleGraph } = compilation;
80
81
 
81
- // loop over entry points
82
+ // Entry externals: hoist the external modules (e.g. RemoteModule) they reference.
82
83
  for (const dep of entryExternalsToHoist) {
83
84
  const entryModule = moduleGraph.getModule(dep);
84
85
  if (!entryModule) continue;
85
- // get all the external module types and hoist them to the runtime chunk, this will get RemoteModule externals
86
86
  const allReferencedModules = getAllReferencedModules(
87
87
  compilation,
88
88
  entryModule,
89
89
  "external",
90
90
  false
91
91
  );
92
-
93
- const containerRuntimes = chunkGraph.getModuleRuntimes(entryModule);
94
- /** @type {Set<string>} */
95
- const runtimes = new Set();
96
-
97
- for (const runtimeSpec of containerRuntimes) {
98
- forEachRuntime(runtimeSpec, (runtimeKey) => {
99
- if (runtimeKey) {
100
- runtimes.add(runtimeKey);
101
- }
102
- });
103
- }
104
-
105
- for (const runtime of runtimes) {
106
- const runtimeChunk = compilation.namedChunks.get(runtime);
107
- if (!runtimeChunk) continue;
108
-
109
- for (const module of allReferencedModules) {
110
- if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {
111
- chunkGraph.connectChunkAndModule(runtimeChunk, module);
112
- }
113
- }
114
- }
115
- this.cleanUpChunks(compilation, allReferencedModules);
92
+ this.hoistReferencedModules(
93
+ compilation,
94
+ entryModule,
95
+ allReferencedModules
96
+ );
116
97
  }
117
98
 
118
- // handle container entry specifically
99
+ // Container entries: hoist the initial graph plus its external references.
119
100
  for (const dep of depsToTrace) {
120
101
  const containerEntryModule = moduleGraph.getModule(dep);
121
102
  if (!containerEntryModule) continue;
@@ -125,43 +106,54 @@ class HoistContainerReferences {
125
106
  "initial",
126
107
  false
127
108
  );
128
-
129
109
  const allRemoteReferences = getAllReferencedModules(
130
110
  compilation,
131
111
  containerEntryModule,
132
112
  "external",
133
113
  false
134
114
  );
135
-
136
115
  for (const remote of allRemoteReferences) {
137
116
  allReferencedModules.add(remote);
138
117
  }
118
+ this.hoistReferencedModules(
119
+ compilation,
120
+ containerEntryModule,
121
+ allReferencedModules
122
+ );
123
+ }
124
+ }
139
125
 
140
- const containerRuntimes =
141
- chunkGraph.getModuleRuntimes(containerEntryModule);
142
- /** @type {Set<string>} */
143
- const runtimes = new Set();
144
-
145
- for (const runtimeSpec of containerRuntimes) {
146
- forEachRuntime(runtimeSpec, (runtimeKey) => {
147
- if (runtimeKey) {
148
- runtimes.add(runtimeKey);
149
- }
150
- });
151
- }
126
+ /**
127
+ * Connect `referencedModules` into each runtime chunk of `entryModule`, then
128
+ * prune the chunks they were hoisted out of. The two passes above build
129
+ * `referencedModules` differently but hoist them identically.
130
+ * @param {Compilation} compilation The webpack compilation instance.
131
+ * @param {Module} entryModule The module whose runtimes receive the modules.
132
+ * @param {Set<Module>} referencedModules The modules to hoist.
133
+ */
134
+ hoistReferencedModules(compilation, entryModule, referencedModules) {
135
+ const { chunkGraph } = compilation;
136
+ /** @type {Set<string>} */
137
+ const runtimes = new Set();
138
+ for (const runtimeSpec of chunkGraph.getModuleRuntimes(entryModule)) {
139
+ forEachRuntime(runtimeSpec, (runtimeKey) => {
140
+ if (runtimeKey) {
141
+ runtimes.add(runtimeKey);
142
+ }
143
+ });
144
+ }
152
145
 
153
- for (const runtime of runtimes) {
154
- const runtimeChunk = compilation.namedChunks.get(runtime);
155
- if (!runtimeChunk) continue;
146
+ for (const runtime of runtimes) {
147
+ const runtimeChunk = compilation.namedChunks.get(runtime);
148
+ if (!runtimeChunk) continue;
156
149
 
157
- for (const module of allReferencedModules) {
158
- if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {
159
- chunkGraph.connectChunkAndModule(runtimeChunk, module);
160
- }
150
+ for (const module of referencedModules) {
151
+ if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {
152
+ chunkGraph.connectChunkAndModule(runtimeChunk, module);
161
153
  }
162
154
  }
163
- this.cleanUpChunks(compilation, allReferencedModules);
164
155
  }
156
+ this.cleanUpChunks(compilation, referencedModules);
165
157
  }
166
158
 
167
159
  /**