webpack 5.1.2 → 5.1.3

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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

@@ -3443,14 +3443,14 @@ Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE = 1000;
3443
3443
  Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING = 2000;
3444
3444
 
3445
3445
  /**
3446
- * Optimize the transfer of existing assets, e. g. by preparing a compressed (gzip) file as separate asset.
3446
+ * Optimize the hashes of the assets, e. g. by generating real hashes of the asset content.
3447
3447
  */
3448
- Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER = 3000;
3448
+ Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH = 2500;
3449
3449
 
3450
3450
  /**
3451
- * Optimize the hashes of the assets, e. g. by generating real hashes of the asset content.
3451
+ * Optimize the transfer of existing assets, e. g. by preparing a compressed (gzip) file as separate asset.
3452
3452
  */
3453
- Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH = 3500;
3453
+ Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER = 3000;
3454
3454
 
3455
3455
  /**
3456
3456
  * Analyse existing assets.
@@ -416,7 +416,7 @@ class ExportsInfo {
416
416
 
417
417
  /**
418
418
  * @param {RuntimeSpec} runtime the runtime
419
- * @returns {boolean} true, when the module is used in any way
419
+ * @returns {boolean} true, when the module exports are used in any way
420
420
  */
421
421
  isUsed(runtime) {
422
422
  if (this._redirectTo !== undefined) {
@@ -436,6 +436,17 @@ class ExportsInfo {
436
436
  return false;
437
437
  }
438
438
 
439
+ /**
440
+ * @param {RuntimeSpec} runtime the runtime
441
+ * @returns {boolean} true, when the module is used in any way
442
+ */
443
+ isModuleUsed(runtime) {
444
+ if (this.isUsed(runtime)) return true;
445
+ if (this._sideEffectsOnlyInfo.getUsed(runtime) !== UsageState.Unused)
446
+ return true;
447
+ return false;
448
+ }
449
+
439
450
  /**
440
451
  * @param {RuntimeSpec} runtime the runtime
441
452
  * @returns {SortableSet<string> | boolean | null} set of used exports, or true (when namespace object is used), or false (when unused), or null (when unknown)
@@ -752,6 +763,8 @@ class ExportInfo {
752
763
  this.name = name;
753
764
  /** @private @type {string | null} */
754
765
  this._usedName = initFrom ? initFrom._usedName : null;
766
+ /** @private @type {UsageStateType} */
767
+ this._globalUsed = initFrom ? initFrom._globalUsed : undefined;
755
768
  /** @private @type {Map<string, RuntimeUsageStateType>} */
756
769
  this._usedInRuntime =
757
770
  initFrom && initFrom._usedInRuntime
@@ -907,7 +920,17 @@ class ExportInfo {
907
920
  * @returns {boolean} true when something has changed
908
921
  */
909
922
  setUsedConditionally(condition, newValue, runtime) {
910
- if (this._usedInRuntime === undefined) {
923
+ if (runtime === undefined) {
924
+ if (this._globalUsed === undefined) {
925
+ this._globalUsed = newValue;
926
+ return true;
927
+ } else {
928
+ if (this._globalUsed !== newValue && condition(this._globalUsed)) {
929
+ this._globalUsed = newValue;
930
+ return true;
931
+ }
932
+ }
933
+ } else if (this._usedInRuntime === undefined) {
911
934
  if (newValue !== UsageState.Unused && condition(UsageState.Unused)) {
912
935
  this._usedInRuntime = new Map();
913
936
  forEachRuntime(runtime, runtime =>
@@ -944,7 +967,12 @@ class ExportInfo {
944
967
  * @returns {boolean} true when something has changed
945
968
  */
946
969
  setUsed(newValue, runtime) {
947
- if (this._usedInRuntime === undefined) {
970
+ if (runtime === undefined) {
971
+ if (this._globalUsed !== newValue) {
972
+ this._globalUsed = newValue;
973
+ return true;
974
+ }
975
+ } else if (this._usedInRuntime === undefined) {
948
976
  if (newValue !== UsageState.Unused) {
949
977
  this._usedInRuntime = new Map();
950
978
  forEachRuntime(runtime, runtime =>
@@ -1023,6 +1051,7 @@ class ExportInfo {
1023
1051
  */
1024
1052
  getUsed(runtime) {
1025
1053
  if (!this._hasUseInRuntimeInfo) return UsageState.NoInfo;
1054
+ if (this._globalUsed !== undefined) return this._globalUsed;
1026
1055
  if (this._usedInRuntime === undefined) {
1027
1056
  return UsageState.Unused;
1028
1057
  } else if (typeof runtime === "string") {
@@ -1062,18 +1091,22 @@ class ExportInfo {
1062
1091
  */
1063
1092
  getUsedName(fallbackName, runtime) {
1064
1093
  if (this._hasUseInRuntimeInfo) {
1065
- if (this._usedInRuntime === undefined) return false;
1066
- if (typeof runtime === "string") {
1067
- if (!this._usedInRuntime.has(runtime)) {
1068
- return false;
1069
- }
1070
- } else if (runtime !== undefined) {
1071
- if (
1072
- Array.from(runtime).every(
1073
- runtime => !this._usedInRuntime.has(runtime)
1074
- )
1075
- ) {
1076
- return false;
1094
+ if (this._globalUsed !== undefined) {
1095
+ if (this._globalUsed === UsageState.Unused) return false;
1096
+ } else {
1097
+ if (this._usedInRuntime === undefined) return false;
1098
+ if (typeof runtime === "string") {
1099
+ if (!this._usedInRuntime.has(runtime)) {
1100
+ return false;
1101
+ }
1102
+ } else if (runtime !== undefined) {
1103
+ if (
1104
+ Array.from(runtime).every(
1105
+ runtime => !this._usedInRuntime.has(runtime)
1106
+ )
1107
+ ) {
1108
+ return false;
1109
+ }
1077
1110
  }
1078
1111
  }
1079
1112
  }
@@ -1282,7 +1315,20 @@ class ExportInfo {
1282
1315
  }
1283
1316
 
1284
1317
  getUsedInfo() {
1285
- if (this._usedInRuntime !== undefined) {
1318
+ if (this._globalUsed !== undefined) {
1319
+ switch (this._globalUsed) {
1320
+ case UsageState.Unused:
1321
+ return "unused";
1322
+ case UsageState.NoInfo:
1323
+ return "no usage info";
1324
+ case UsageState.Unknown:
1325
+ return "maybe used (runtime-defined)";
1326
+ case UsageState.Used:
1327
+ return "used";
1328
+ case UsageState.OnlyPropertiesUsed:
1329
+ return "only properties used";
1330
+ }
1331
+ } else if (this._usedInRuntime !== undefined) {
1286
1332
  /** @type {Map<RuntimeUsageStateType, string[]>} */
1287
1333
  const map = new Map();
1288
1334
  for (const [runtime, used] of this._usedInRuntime) {
@@ -7,13 +7,10 @@
7
7
 
8
8
  const Dependency = require("./Dependency");
9
9
  const { UsageState } = require("./ExportsInfo");
10
+ const ModuleGraphConnection = require("./ModuleGraphConnection");
10
11
  const { STAGE_DEFAULT } = require("./OptimizationStages");
11
12
  const TupleQueue = require("./util/TupleQueue");
12
- const {
13
- getEntryRuntime,
14
- mergeRuntime,
15
- mergeRuntimeOwned
16
- } = require("./util/runtime");
13
+ const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime");
17
14
 
18
15
  /** @typedef {import("./Chunk")} Chunk */
19
16
  /** @typedef {import("./ChunkGroup")} ChunkGroup */
@@ -63,9 +60,15 @@ class FlagDependencyUsagePlugin {
63
60
  * @param {Module} module module to process
64
61
  * @param {(string[] | ReferencedExport)[]} usedExports list of used exports
65
62
  * @param {RuntimeSpec} runtime part of which runtime
63
+ * @param {boolean} forceSideEffects always apply side effects
66
64
  * @returns {void}
67
65
  */
68
- const processReferencedModule = (module, usedExports, runtime) => {
66
+ const processReferencedModule = (
67
+ module,
68
+ usedExports,
69
+ runtime,
70
+ forceSideEffects
71
+ ) => {
69
72
  const exportsInfo = moduleGraph.getExportsInfo(module);
70
73
  if (usedExports.length > 0) {
71
74
  if (!module.buildMeta || !module.buildMeta.exportsType) {
@@ -143,10 +146,12 @@ class FlagDependencyUsagePlugin {
143
146
  // This module won't be evaluated in this case
144
147
  // TODO webpack 6 remove this check
145
148
  if (
149
+ !forceSideEffects &&
146
150
  module.factoryMeta !== undefined &&
147
151
  module.factoryMeta.sideEffectFree
148
- )
152
+ ) {
149
153
  return;
154
+ }
150
155
  if (exportsInfo.setUsedForSideEffectsOnly(runtime)) {
151
156
  queue.enqueue(module, runtime);
152
157
  }
@@ -166,7 +171,11 @@ class FlagDependencyUsagePlugin {
166
171
  const queue = [module];
167
172
  for (const block of queue) {
168
173
  for (const b of block.blocks) {
169
- if (b.groupOptions && b.groupOptions.entryOptions) {
174
+ if (
175
+ !this.global &&
176
+ b.groupOptions &&
177
+ b.groupOptions.entryOptions
178
+ ) {
170
179
  processModule(b, b.groupOptions.entryOptions.runtime);
171
180
  } else {
172
181
  queue.push(b);
@@ -174,14 +183,16 @@ class FlagDependencyUsagePlugin {
174
183
  }
175
184
  for (const dep of block.dependencies) {
176
185
  const connection = moduleGraph.getConnection(dep);
177
- if (
178
- !connection ||
179
- !connection.module ||
180
- !connection.isTargetActive(runtime)
181
- ) {
186
+ if (!connection || !connection.module) {
182
187
  continue;
183
188
  }
189
+ const activeState = connection.getActiveState(runtime);
190
+ if (activeState === false) continue;
184
191
  const { module } = connection;
192
+ if (activeState === ModuleGraphConnection.TRANSITIVE_ONLY) {
193
+ processModule(module, runtime);
194
+ continue;
195
+ }
185
196
  const oldReferencedExports = map.get(module);
186
197
  if (oldReferencedExports === EXPORTS_OBJECT_REFERENCED) {
187
198
  continue;
@@ -242,12 +253,18 @@ class FlagDependencyUsagePlugin {
242
253
 
243
254
  for (const [module, referencedExports] of map) {
244
255
  if (Array.isArray(referencedExports)) {
245
- processReferencedModule(module, referencedExports, runtime);
256
+ processReferencedModule(
257
+ module,
258
+ referencedExports,
259
+ runtime,
260
+ false
261
+ );
246
262
  } else {
247
263
  processReferencedModule(
248
264
  module,
249
265
  Array.from(referencedExports.values()),
250
- runtime
266
+ runtime,
267
+ false
251
268
  );
252
269
  }
253
270
  }
@@ -270,8 +287,12 @@ class FlagDependencyUsagePlugin {
270
287
  const processEntryDependency = (dep, runtime) => {
271
288
  const module = moduleGraph.getModule(dep);
272
289
  if (module) {
273
- processReferencedModule(module, NO_EXPORTS_REFERENCED, runtime);
274
- queue.enqueue(module, runtime);
290
+ processReferencedModule(
291
+ module,
292
+ NO_EXPORTS_REFERENCED,
293
+ runtime,
294
+ true
295
+ );
275
296
  }
276
297
  };
277
298
  /** @type {RuntimeSpec} */
@@ -305,31 +326,6 @@ class FlagDependencyUsagePlugin {
305
326
  logger.timeEnd("trace exports usage in graph");
306
327
  }
307
328
  );
308
- if (!this.global) {
309
- compilation.hooks.afterChunks.tap("FlagDependencyUsagePlugin", () => {
310
- /** @type {Map<Chunk, string>} */
311
- const runtimeChunks = new Map();
312
- for (const entrypoint of compilation.entrypoints.values()) {
313
- runtimeChunks.set(
314
- entrypoint.getRuntimeChunk(),
315
- entrypoint.options.runtime
316
- );
317
- }
318
- for (const entrypoint of compilation.asyncEntrypoints) {
319
- runtimeChunks.set(
320
- entrypoint.getRuntimeChunk(),
321
- entrypoint.options.runtime
322
- );
323
- }
324
-
325
- for (const [runtimeChunk, runtimeName] of runtimeChunks) {
326
- const runtime = runtimeName || runtimeChunk.name;
327
- for (const chunk of runtimeChunk.getAllReferencedChunks()) {
328
- chunk.runtime = mergeRuntime(chunk.runtime, runtime);
329
- }
330
- }
331
- });
332
- }
333
329
  });
334
330
  }
335
331
  }
@@ -8,6 +8,7 @@
8
8
  const AsyncDependencyToInitialChunkError = require("./AsyncDependencyToInitialChunkError");
9
9
  const { connectChunkGroupParentAndChild } = require("./GraphHelpers");
10
10
  const ModuleGraphConnection = require("./ModuleGraphConnection");
11
+ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
11
12
 
12
13
  /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
13
14
  /** @typedef {import("./Chunk")} Chunk */
@@ -20,6 +21,7 @@ const ModuleGraphConnection = require("./ModuleGraphConnection");
20
21
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
21
22
  /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
22
23
  /** @typedef {import("./logging/Logger").Logger} Logger */
24
+ /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
23
25
 
24
26
  /**
25
27
  * @typedef {Object} QueueItem
@@ -36,10 +38,12 @@ const ModuleGraphConnection = require("./ModuleGraphConnection");
36
38
  /**
37
39
  * @typedef {Object} ChunkGroupInfo
38
40
  * @property {ChunkGroup} chunkGroup the chunk group
41
+ * @property {RuntimeSpec} runtime the runtimes
39
42
  * @property {ModuleSetPlus} minAvailableModules current minimal set of modules available at this point
40
43
  * @property {boolean} minAvailableModulesOwned true, if minAvailableModules is owned and can be modified
41
44
  * @property {ModuleSetPlus[]} availableModulesToBeMerged enqueued updates to the minimal set of available modules
42
45
  * @property {Set<Module>=} skippedItems modules that were skipped because module is already available in parent chunks (need to reconsider when minAvailableModules is shrinking)
46
+ * @property {Set<[Module, ModuleGraphConnection[]]>=} skippedModuleConnections referenced modules that where skipped because they were not active in this runtime
43
47
  * @property {ModuleSetPlus} resultingAvailableModules set of modules available including modules from this chunk group
44
48
  * @property {Set<ChunkGroupInfo>} children set of children chunk groups, that will be revisited when availableModules shrink
45
49
  * @property {Set<ChunkGroupInfo>} availableSources set of chunk groups that are the source for minAvailableModules
@@ -66,21 +70,41 @@ const bySetSize = (a, b) => {
66
70
  return b.size + b.plus.size - a.size - a.plus.size;
67
71
  };
68
72
 
73
+ /**
74
+ *
75
+ * @param {ModuleGraphConnection[]} connections list of connections
76
+ * @param {RuntimeSpec} runtime for which runtime
77
+ * @returns {ConnectionState} connection state
78
+ */
79
+ const getActiveStateOfConnections = (connections, runtime) => {
80
+ let merged = connections[0].getActiveState(runtime);
81
+ if (merged === true) return true;
82
+ for (let i = 1; i < connections.length; i++) {
83
+ const c = connections[i];
84
+ merged = ModuleGraphConnection.addConnectionStates(
85
+ merged,
86
+ c.getActiveState(runtime)
87
+ );
88
+ if (merged === true) return true;
89
+ }
90
+ return merged;
91
+ };
92
+
69
93
  /**
70
94
  * Extracts block to modules mapping from all modules
71
95
  * @param {Compilation} compilation the compilation
72
- * @returns {Map<DependenciesBlock, Map<Module, Exclude<ConnectionState, false>>>} the mapping block to modules
96
+ * @returns {Map<DependenciesBlock, Map<Module, ModuleGraphConnection[]>>} the mapping block to modules
73
97
  */
74
98
  const extractBlockModulesMap = compilation => {
75
99
  const { moduleGraph } = compilation;
76
100
 
77
- /** @type {Map<DependenciesBlock, Map<Module, Exclude<ConnectionState, false>>>} */
101
+ /** @type {Map<DependenciesBlock, Map<Module, ModuleGraphConnection[]>>} */
78
102
  const blockModulesMap = new Map();
79
103
 
80
104
  const blockQueue = new Set();
81
105
 
82
106
  for (const module of compilation.modules) {
83
- /** @type {WeakMap<Dependency, [Module, Exclude<ConnectionState, false>]>} */
107
+ /** @type {WeakMap<Dependency, ModuleGraphConnection>} */
84
108
  let moduleMap;
85
109
 
86
110
  for (const connection of moduleGraph.getOutgoingConnections(module)) {
@@ -101,7 +125,7 @@ const extractBlockModulesMap = compilation => {
101
125
  if (moduleMap === undefined) {
102
126
  moduleMap = new WeakMap();
103
127
  }
104
- moduleMap.set(connection.dependency, [m, state]);
128
+ moduleMap.set(connection.dependency, connection);
105
129
  }
106
130
 
107
131
  blockQueue.clear();
@@ -111,27 +135,19 @@ const extractBlockModulesMap = compilation => {
111
135
 
112
136
  if (moduleMap !== undefined && block.dependencies) {
113
137
  for (const dep of block.dependencies) {
114
- const map = moduleMap.get(dep);
115
- if (map !== undefined) {
116
- const [module, state] = map;
138
+ const connection = moduleMap.get(dep);
139
+ if (connection !== undefined) {
140
+ const { module } = connection;
117
141
  if (modules === undefined) {
118
142
  modules = new Map();
119
143
  blockModulesMap.set(block, modules);
120
144
  }
121
- let merged = state;
122
- if (merged !== true) {
123
- const old = modules.get(module);
124
- if (old !== undefined) {
125
- merged = /** @type {Exclude<ConnectionState, false>} */ (ModuleGraphConnection.addConnectionStates(
126
- old,
127
- merged
128
- ));
129
- if (merged === old) {
130
- continue;
131
- }
132
- }
145
+ const old = modules.get(module);
146
+ if (old !== undefined) {
147
+ old.push(connection);
148
+ } else {
149
+ modules.set(module, [connection]);
133
150
  }
134
- modules.set(module, merged);
135
151
  }
136
152
  }
137
153
  }
@@ -216,9 +232,15 @@ const visitModules = (
216
232
  // Fill queue with entrypoint modules
217
233
  // Create ChunkGroupInfo for entrypoints
218
234
  for (const [chunkGroup, modules] of inputEntrypointsAndModules) {
235
+ const runtime = getEntryRuntime(
236
+ compilation,
237
+ chunkGroup.name,
238
+ chunkGroup.options
239
+ );
219
240
  /** @type {ChunkGroupInfo} */
220
241
  const chunkGroupInfo = {
221
242
  chunkGroup,
243
+ runtime,
222
244
  minAvailableModules: undefined,
223
245
  minAvailableModulesOwned: false,
224
246
  availableModulesToBeMerged: [],
@@ -288,6 +310,8 @@ const visitModules = (
288
310
 
289
311
  logger.timeEnd("visitModules: prepare");
290
312
 
313
+ /** @type {[Module, ModuleGraphConnection[]][]} */
314
+ const skipConnectionBuffer = [];
291
315
  /** @type {Module[]} */
292
316
  const skipBuffer = [];
293
317
  /** @type {QueueItem[]} */
@@ -332,6 +356,7 @@ const visitModules = (
332
356
  entrypoint.index = nextChunkGroupIndex++;
333
357
  cgi = {
334
358
  chunkGroup: entrypoint,
359
+ runtime: entrypoint.options.runtime || entrypoint.name,
335
360
  minAvailableModules: EMPTY_SET,
336
361
  minAvailableModulesOwned: false,
337
362
  availableModulesToBeMerged: [],
@@ -377,6 +402,7 @@ const visitModules = (
377
402
  c.index = nextChunkGroupIndex++;
378
403
  cgi = {
379
404
  chunkGroup: c,
405
+ runtime: chunkGroupInfo.runtime,
380
406
  minAvailableModules: undefined,
381
407
  minAvailableModulesOwned: undefined,
382
408
  availableModulesToBeMerged: [],
@@ -455,17 +481,24 @@ const visitModules = (
455
481
  const blockModules = blockModulesMap.get(block);
456
482
 
457
483
  if (blockModules !== undefined) {
458
- const { minAvailableModules } = chunkGroupInfo;
484
+ const { minAvailableModules, runtime } = chunkGroupInfo;
459
485
  // Buffer items because order need to be reversed to get indices correct
460
486
  // Traverse all referenced modules
461
- for (const [refModule, activeState] of blockModules) {
487
+ for (const entry of blockModules) {
488
+ const [refModule, connections] = entry;
462
489
  if (chunkGraph.isModuleInChunk(refModule, chunk)) {
463
490
  // skip early if already connected
464
491
  continue;
465
492
  }
493
+ const activeState = getActiveStateOfConnections(connections, runtime);
494
+ if (activeState !== true) {
495
+ skipConnectionBuffer.push(entry);
496
+ if (activeState === false) continue;
497
+ }
466
498
  if (
467
- minAvailableModules.has(refModule) ||
468
- minAvailableModules.plus.has(refModule)
499
+ activeState === true &&
500
+ (minAvailableModules.has(refModule) ||
501
+ minAvailableModules.plus.has(refModule))
469
502
  ) {
470
503
  // already in parent chunks, skip it for now
471
504
  skipBuffer.push(refModule);
@@ -483,6 +516,16 @@ const visitModules = (
483
516
  });
484
517
  }
485
518
  // Add buffered items in reverse order
519
+ if (skipConnectionBuffer.length > 0) {
520
+ let { skippedModuleConnections } = chunkGroupInfo;
521
+ if (skippedModuleConnections === undefined) {
522
+ chunkGroupInfo.skippedModuleConnections = skippedModuleConnections = new Set();
523
+ }
524
+ for (let i = skipConnectionBuffer.length - 1; i >= 0; i--) {
525
+ skippedModuleConnections.add(skipConnectionBuffer[i]);
526
+ }
527
+ skipConnectionBuffer.length = 0;
528
+ }
486
529
  if (skipBuffer.length > 0) {
487
530
  let { skippedItems } = chunkGroupInfo;
488
531
  if (skippedItems === undefined) {
@@ -522,7 +565,8 @@ const visitModules = (
522
565
 
523
566
  if (blockModules !== undefined) {
524
567
  // Traverse all referenced modules
525
- for (const [refModule, activeState] of blockModules) {
568
+ for (const [refModule, connections] of blockModules) {
569
+ const activeState = getActiveStateOfConnections(connections, undefined);
526
570
  // enqueue, then add and enter to be in the correct order
527
571
  // this is relevant with circular dependencies
528
572
  queueBuffer.push({
@@ -692,10 +736,18 @@ const visitModules = (
692
736
  chunkGroupInfo
693
737
  );
694
738
 
739
+ const runtime = chunkGroupInfo.runtime;
740
+
695
741
  // 3. Update chunk group info
696
742
  for (const target of targets) {
697
743
  target.availableModulesToBeMerged.push(resultingAvailableModules);
698
744
  chunkGroupsForMerging.add(target);
745
+ const oldRuntime = target.runtime;
746
+ const newRuntime = mergeRuntime(oldRuntime, runtime);
747
+ if (oldRuntime !== newRuntime) {
748
+ target.runtime = newRuntime;
749
+ outdatedChunkGroupInfo.add(target);
750
+ }
699
751
  }
700
752
 
701
753
  statConnectedChunkGroups += targets.size;
@@ -1000,6 +1052,35 @@ const visitModules = (
1000
1052
  }
1001
1053
  }
1002
1054
 
1055
+ // 2. Reconsider skipped connections
1056
+ if (info.skippedModuleConnections !== undefined) {
1057
+ const { minAvailableModules, runtime } = info;
1058
+ for (const entry of info.skippedModuleConnections) {
1059
+ const [module, connections] = entry;
1060
+ const activeState = getActiveStateOfConnections(connections, runtime);
1061
+ if (activeState === false) continue;
1062
+ if (activeState === true) {
1063
+ info.skippedModuleConnections.delete(entry);
1064
+ }
1065
+ if (
1066
+ activeState === true &&
1067
+ (minAvailableModules.has(module) ||
1068
+ minAvailableModules.plus.has(module))
1069
+ ) {
1070
+ info.skippedItems.add(module);
1071
+ continue;
1072
+ }
1073
+ queue.push({
1074
+ action: activeState === true ? ADD_AND_ENTER_MODULE : PROCESS_BLOCK,
1075
+ block: module,
1076
+ module,
1077
+ chunk: info.chunkGroup.chunks[0],
1078
+ chunkGroup: info.chunkGroup,
1079
+ chunkGroupInfo: info
1080
+ });
1081
+ }
1082
+ }
1083
+
1003
1084
  // 2. Reconsider children chunk groups
1004
1085
  if (info.children !== undefined) {
1005
1086
  statChildChunkGroupsReconnected += info.children.size;
@@ -1213,6 +1294,11 @@ const buildChunkGraph = (compilation, inputEntrypointsAndModules) => {
1213
1294
  );
1214
1295
  logger.timeEnd("connectChunkGroups");
1215
1296
 
1297
+ for (const [chunkGroup, chunkGroupInfo] of chunkGroupInfoMap) {
1298
+ for (const chunk of chunkGroup.chunks)
1299
+ chunk.runtime = mergeRuntime(chunk.runtime, chunkGroupInfo.runtime);
1300
+ }
1301
+
1216
1302
  // Cleanup work
1217
1303
 
1218
1304
  logger.time("cleanup");
@@ -1508,7 +1508,7 @@ ${defineGetters}`
1508
1508
  const orderedConcatenationList = this._createConcatenationList(
1509
1509
  this.rootModule,
1510
1510
  this._modules,
1511
- undefined,
1511
+ runtime,
1512
1512
  moduleGraph
1513
1513
  );
1514
1514
  return orderedConcatenationList.map((info, index) => {
@@ -44,7 +44,7 @@ exports.getEntryRuntime = (compilation, name, options) => {
44
44
  result = mergeRuntimeOwned(result, runtime || name);
45
45
  }
46
46
  }
47
- return result;
47
+ return result || name;
48
48
  } else {
49
49
  return runtime || name;
50
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -75,7 +75,7 @@
75
75
  "lodash": "^4.17.19",
76
76
  "lodash-es": "^4.17.15",
77
77
  "memfs": "^3.2.0",
78
- "mini-css-extract-plugin": "^0.10.0",
78
+ "mini-css-extract-plugin": "^1.0.0",
79
79
  "mini-svg-data-uri": "^1.2.3",
80
80
  "open-cli": "^6.0.1",
81
81
  "prettier": "^2.0.5",
package/types.d.ts CHANGED
@@ -1547,14 +1547,14 @@ declare class Compilation {
1547
1547
  static PROCESS_ASSETS_STAGE_DEV_TOOLING: number;
1548
1548
 
1549
1549
  /**
1550
- * Optimize the transfer of existing assets, e. g. by preparing a compressed (gzip) file as separate asset.
1550
+ * Optimize the hashes of the assets, e. g. by generating real hashes of the asset content.
1551
1551
  */
1552
- static PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER: number;
1552
+ static PROCESS_ASSETS_STAGE_OPTIMIZE_HASH: number;
1553
1553
 
1554
1554
  /**
1555
- * Optimize the hashes of the assets, e. g. by generating real hashes of the asset content.
1555
+ * Optimize the transfer of existing assets, e. g. by preparing a compressed (gzip) file as separate asset.
1556
1556
  */
1557
- static PROCESS_ASSETS_STAGE_OPTIMIZE_HASH: number;
1557
+ static PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER: number;
1558
1558
 
1559
1559
  /**
1560
1560
  * Analyse existing assets.
@@ -3076,6 +3076,7 @@ declare abstract class ExportsInfo {
3076
3076
  setAllKnownExportsUsed(runtime: string | SortableSet<string>): boolean;
3077
3077
  setUsedForSideEffectsOnly(runtime: string | SortableSet<string>): boolean;
3078
3078
  isUsed(runtime: string | SortableSet<string>): boolean;
3079
+ isModuleUsed(runtime: string | SortableSet<string>): boolean;
3079
3080
  getUsedExports(
3080
3081
  runtime: string | SortableSet<string>
3081
3082
  ): boolean | SortableSet<string>;