webpack 5.65.0 → 5.68.0

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.

Files changed (117) hide show
  1. package/README.md +1 -1
  2. package/lib/APIPlugin.js +33 -0
  3. package/lib/Cache.js +1 -1
  4. package/lib/CacheFacade.js +4 -11
  5. package/lib/Chunk.js +2 -0
  6. package/lib/CleanPlugin.js +1 -1
  7. package/lib/Compilation.js +91 -47
  8. package/lib/Compiler.js +57 -3
  9. package/lib/ContextModule.js +21 -17
  10. package/lib/DelegatedModule.js +1 -1
  11. package/lib/Dependency.js +10 -0
  12. package/lib/DependencyTemplate.js +9 -0
  13. package/lib/DependencyTemplates.js +1 -1
  14. package/lib/DllModule.js +1 -1
  15. package/lib/EvalDevToolModulePlugin.js +16 -1
  16. package/lib/EvalSourceMapDevToolPlugin.js +18 -1
  17. package/lib/ExternalModule.js +93 -53
  18. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  19. package/lib/FileSystemInfo.js +29 -25
  20. package/lib/Generator.js +2 -0
  21. package/lib/HookWebpackError.js +1 -1
  22. package/lib/Module.js +25 -4
  23. package/lib/ModuleFilenameHelpers.js +5 -1
  24. package/lib/MultiCompiler.js +1 -1
  25. package/lib/MultiWatching.js +1 -1
  26. package/lib/NormalModule.js +9 -5
  27. package/lib/RawModule.js +1 -1
  28. package/lib/RuntimeGlobals.js +29 -1
  29. package/lib/RuntimeModule.js +1 -1
  30. package/lib/RuntimePlugin.js +50 -0
  31. package/lib/RuntimeTemplate.js +21 -0
  32. package/lib/Template.js +2 -1
  33. package/lib/Watching.js +2 -2
  34. package/lib/WebpackOptionsApply.js +43 -2
  35. package/lib/asset/AssetGenerator.js +64 -24
  36. package/lib/asset/AssetModulesPlugin.js +3 -0
  37. package/lib/asset/RawDataUrlModule.js +148 -0
  38. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
  39. package/lib/cache/ResolverCachePlugin.js +1 -1
  40. package/lib/cli.js +44 -3
  41. package/lib/config/defaults.js +79 -5
  42. package/lib/config/normalization.js +5 -0
  43. package/lib/container/ContainerEntryModule.js +4 -2
  44. package/lib/container/FallbackModule.js +4 -4
  45. package/lib/container/RemoteModule.js +4 -2
  46. package/lib/css/CssExportsGenerator.js +139 -0
  47. package/lib/css/CssGenerator.js +109 -0
  48. package/lib/css/CssLoadingRuntimeModule.js +447 -0
  49. package/lib/css/CssModulesPlugin.js +461 -0
  50. package/lib/css/CssParser.js +618 -0
  51. package/lib/css/walkCssTokens.js +659 -0
  52. package/lib/debug/ProfilingPlugin.js +12 -10
  53. package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
  54. package/lib/dependencies/CssExportDependency.js +85 -0
  55. package/lib/dependencies/CssImportDependency.js +75 -0
  56. package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
  57. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
  58. package/lib/dependencies/CssUrlDependency.js +132 -0
  59. package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
  60. package/lib/dependencies/ImportMetaPlugin.js +22 -3
  61. package/lib/dependencies/LoaderPlugin.js +2 -2
  62. package/lib/dependencies/URLDependency.js +3 -8
  63. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
  64. package/lib/hmr/LazyCompilationPlugin.js +45 -21
  65. package/lib/hmr/lazyCompilationBackend.js +4 -2
  66. package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
  67. package/lib/ids/HashedModuleIdsPlugin.js +9 -12
  68. package/lib/ids/IdHelpers.js +24 -10
  69. package/lib/ids/NamedModuleIdsPlugin.js +6 -9
  70. package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
  71. package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
  72. package/lib/ids/SyncModuleIdsPlugin.js +140 -0
  73. package/lib/index.js +5 -0
  74. package/lib/javascript/JavascriptGenerator.js +1 -0
  75. package/lib/javascript/StartupHelpers.js +3 -3
  76. package/lib/library/AssignLibraryPlugin.js +26 -3
  77. package/lib/library/EnableLibraryPlugin.js +11 -0
  78. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
  79. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
  80. package/lib/optimize/ConcatenatedModule.js +11 -5
  81. package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
  82. package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
  83. package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
  84. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
  85. package/lib/schemes/HttpUriPlugin.js +8 -8
  86. package/lib/sharing/ConsumeSharedModule.js +4 -2
  87. package/lib/sharing/ProvideSharedModule.js +4 -2
  88. package/lib/sharing/utils.js +1 -1
  89. package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
  90. package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
  91. package/lib/util/ArrayHelpers.js +18 -4
  92. package/lib/util/AsyncQueue.js +1 -1
  93. package/lib/util/hash/xxhash64.js +2 -2
  94. package/lib/util/internalSerializables.js +11 -0
  95. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
  96. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -2
  97. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
  98. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  99. package/package.json +4 -11
  100. package/schemas/WebpackOptions.check.js +1 -1
  101. package/schemas/WebpackOptions.json +96 -1
  102. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  103. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  104. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  105. package/schemas/plugins/container/ContainerPlugin.json +2 -1
  106. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  107. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  108. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  109. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  110. package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
  111. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  112. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  113. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  114. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  115. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  116. package/schemas/plugins/css/CssParserOptions.json +3 -0
  117. package/types.d.ts +249 -39
@@ -1658,84 +1658,121 @@ const collapse = children => {
1658
1658
  return newChildren;
1659
1659
  };
1660
1660
 
1661
- const spaceLimited = (itemsAndGroups, max) => {
1661
+ const spaceLimited = (
1662
+ itemsAndGroups,
1663
+ max,
1664
+ filteredChildrenLineReserved = false
1665
+ ) => {
1666
+ if (max < 1) {
1667
+ return {
1668
+ children: undefined,
1669
+ filteredChildren: getTotalItems(itemsAndGroups)
1670
+ };
1671
+ }
1662
1672
  /** @type {any[] | undefined} */
1663
1673
  let children = undefined;
1664
1674
  /** @type {number | undefined} */
1665
1675
  let filteredChildren = undefined;
1666
1676
  // This are the groups, which take 1+ lines each
1667
- const groups = itemsAndGroups.filter(c => c.children || c.filteredChildren);
1677
+ const groups = [];
1668
1678
  // The sizes of the groups are stored in groupSizes
1669
- const groupSizes = groups.map(g => getItemSize(g));
1679
+ const groupSizes = [];
1670
1680
  // This are the items, which take 1 line each
1671
- const items = itemsAndGroups.filter(c => !c.children && !c.filteredChildren);
1681
+ const items = [];
1672
1682
  // The total of group sizes
1673
- let groupsSize = groupSizes.reduce((a, b) => a + b, 0);
1683
+ let groupsSize = 0;
1684
+
1685
+ for (const itemOrGroup of itemsAndGroups) {
1686
+ // is item
1687
+ if (!itemOrGroup.children && !itemOrGroup.filteredChildren) {
1688
+ items.push(itemOrGroup);
1689
+ } else {
1690
+ groups.push(itemOrGroup);
1691
+ const size = getItemSize(itemOrGroup);
1692
+ groupSizes.push(size);
1693
+ groupsSize += size;
1694
+ }
1695
+ }
1696
+
1674
1697
  if (groupsSize + items.length <= max) {
1675
1698
  // The total size in the current state fits into the max
1676
1699
  // keep all
1677
- children = groups.concat(items);
1678
- } else if (
1679
- groups.length > 0 &&
1680
- groups.length + Math.min(1, items.length) < max
1681
- ) {
1682
- // If each group would take 1 line the total would be below the maximum
1683
- // collapse some groups, keep items
1684
- while (groupsSize + items.length + (filteredChildren ? 1 : 0) > max) {
1700
+ children = groups.length > 0 ? groups.concat(items) : items;
1701
+ } else if (groups.length === 0) {
1702
+ // slice items to max
1703
+ // inner space marks that lines for filteredChildren already reserved
1704
+ const limit = max - (filteredChildrenLineReserved ? 0 : 1);
1705
+ filteredChildren = items.length - limit;
1706
+ items.length = limit;
1707
+ children = items;
1708
+ } else {
1709
+ // limit is the size when all groups are collapsed
1710
+ const limit =
1711
+ groups.length +
1712
+ (filteredChildrenLineReserved || items.length === 0 ? 0 : 1);
1713
+ if (limit < max) {
1685
1714
  // calculate how much we are over the size limit
1686
1715
  // this allows to approach the limit faster
1687
- // it's always > 1
1688
- const oversize =
1689
- items.length + groupsSize + (filteredChildren ? 1 : 0) - max;
1690
- // Find the maximum group and process only this one
1691
- const maxGroupSize = Math.max(...groupSizes);
1692
- if (maxGroupSize < items.length) {
1693
- filteredChildren = items.length;
1694
- items.length = 0;
1695
- continue;
1696
- }
1697
- for (let i = 0; i < groups.length; i++) {
1698
- if (groupSizes[i] === maxGroupSize) {
1699
- const group = groups[i];
1700
- // run this algorithm recursively and limit the size of the children to
1701
- // current size - oversize / number of groups
1702
- // So it should always end up being smaller
1703
- const headerSize = !group.children
1704
- ? 0
1705
- : group.filteredChildren
1706
- ? 2
1707
- : 1;
1708
- const limited = spaceLimited(
1709
- group.children,
1710
- groupSizes[i] - headerSize - oversize / groups.length
1711
- );
1712
- groups[i] = {
1713
- ...group,
1714
- children: limited.children,
1715
- filteredChildren:
1716
- (group.filteredChildren || 0) + limited.filteredChildren
1717
- };
1718
- const newSize = getItemSize(groups[i]);
1719
- groupsSize -= groupSizes[i] - newSize;
1720
- groupSizes[i] = newSize;
1721
- break;
1716
+ let oversize;
1717
+ // If each group would take 1 line the total would be below the maximum
1718
+ // collapse some groups, keep items
1719
+ while (
1720
+ (oversize =
1721
+ groupsSize +
1722
+ items.length +
1723
+ (filteredChildren && !filteredChildrenLineReserved ? 1 : 0) -
1724
+ max) > 0
1725
+ ) {
1726
+ // Find the maximum group and process only this one
1727
+ const maxGroupSize = Math.max(...groupSizes);
1728
+ if (maxGroupSize < items.length) {
1729
+ filteredChildren = items.length;
1730
+ items.length = 0;
1731
+ continue;
1732
+ }
1733
+ for (let i = 0; i < groups.length; i++) {
1734
+ if (groupSizes[i] === maxGroupSize) {
1735
+ const group = groups[i];
1736
+ // run this algorithm recursively and limit the size of the children to
1737
+ // current size - oversize / number of groups
1738
+ // So it should always end up being smaller
1739
+ const headerSize = group.filteredChildren ? 2 : 1;
1740
+ const limited = spaceLimited(
1741
+ group.children,
1742
+ maxGroupSize -
1743
+ // we should use ceil to always feet in max
1744
+ Math.ceil(oversize / groups.length) -
1745
+ // we substitute size of group head
1746
+ headerSize,
1747
+ headerSize === 2
1748
+ );
1749
+ groups[i] = {
1750
+ ...group,
1751
+ children: limited.children,
1752
+ filteredChildren: limited.filteredChildren
1753
+ ? (group.filteredChildren || 0) + limited.filteredChildren
1754
+ : group.filteredChildren
1755
+ };
1756
+ const newSize = getItemSize(groups[i]);
1757
+ groupsSize -= maxGroupSize - newSize;
1758
+ groupSizes[i] = newSize;
1759
+ break;
1760
+ }
1722
1761
  }
1723
1762
  }
1763
+ children = groups.concat(items);
1764
+ } else if (limit === max) {
1765
+ // If we have only enough space to show one line per group and one line for the filtered items
1766
+ // collapse all groups and items
1767
+ children = collapse(groups);
1768
+ filteredChildren = items.length;
1769
+ } else {
1770
+ // If we have no space
1771
+ // collapse complete group
1772
+ filteredChildren = getTotalItems(itemsAndGroups);
1724
1773
  }
1725
- children = groups.concat(items);
1726
- } else if (
1727
- groups.length > 0 &&
1728
- groups.length + Math.min(1, items.length) <= max
1729
- ) {
1730
- // If we have only enough space to show one line per group and one line for the filtered items
1731
- // collapse all groups and items
1732
- children = groups.length ? collapse(groups) : undefined;
1733
- filteredChildren = items.length;
1734
- } else {
1735
- // If we have no space
1736
- // collapse complete group
1737
- filteredChildren = getTotalItems(itemsAndGroups);
1738
1774
  }
1775
+
1739
1776
  return {
1740
1777
  children,
1741
1778
  filteredChildren
@@ -1777,6 +1814,9 @@ const reasonGroup = (children, reasons) => {
1777
1814
  };
1778
1815
  };
1779
1816
 
1817
+ const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
1818
+ const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
1819
+
1780
1820
  /** @type {Record<string, (groupConfigs: GroupConfig[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} */
1781
1821
  const ASSETS_GROUPERS = {
1782
1822
  _: (groupConfigs, context, options) => {
@@ -1825,10 +1865,10 @@ const ASSETS_GROUPERS = {
1825
1865
  groupConfigs.push({
1826
1866
  getKeys: asset => {
1827
1867
  const extensionMatch =
1828
- groupAssetsByExtension && /(\.[^.]+)(?:\?.*|$)/.exec(asset.name);
1868
+ groupAssetsByExtension && GROUP_EXTENSION_REGEXP.exec(asset.name);
1829
1869
  const extension = extensionMatch ? extensionMatch[1] : "";
1830
1870
  const pathMatch =
1831
- groupAssetsByPath && /(.+)[/\\][^/\\]+(?:\?.*|$)/.exec(asset.name);
1871
+ groupAssetsByPath && GROUP_PATH_REGEXP.exec(asset.name);
1832
1872
  const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
1833
1873
  const keys = [];
1834
1874
  if (groupAssetsByPath) {
@@ -2022,11 +2062,13 @@ const MODULES_GROUPERS = type => ({
2022
2062
  getKeys: module => {
2023
2063
  if (!module.name) return;
2024
2064
  const resource = parseResource(module.name.split("!").pop()).path;
2065
+ const dataUrl = /^data:[^,;]+/.exec(resource);
2066
+ if (dataUrl) return [dataUrl[0]];
2025
2067
  const extensionMatch =
2026
- groupModulesByExtension && /(\.[^.]+)(?:\?.*|$)/.exec(resource);
2068
+ groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
2027
2069
  const extension = extensionMatch ? extensionMatch[1] : "";
2028
2070
  const pathMatch =
2029
- groupModulesByPath && /(.+)[/\\][^/\\]+(?:\?.*|$)/.exec(resource);
2071
+ groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
2030
2072
  const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
2031
2073
  const keys = [];
2032
2074
  if (groupModulesByPath) {
@@ -2046,11 +2088,14 @@ const MODULES_GROUPERS = type => ({
2046
2088
  return keys;
2047
2089
  },
2048
2090
  createGroup: (key, children, modules) => {
2091
+ const isDataUrl = key.startsWith("data:");
2049
2092
  return {
2050
- type: groupModulesByPath
2093
+ type: isDataUrl
2094
+ ? "modules by mime type"
2095
+ : groupModulesByPath
2051
2096
  ? "modules by path"
2052
2097
  : "modules by extension",
2053
- name: key,
2098
+ name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
2054
2099
  children,
2055
2100
  ...moduleGroup(children, modules)
2056
2101
  };
@@ -9,6 +9,8 @@
9
9
  /** @typedef {import("./StatsPrinter")} StatsPrinter */
10
10
  /** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
11
11
 
12
+ const DATA_URI_CONTENT_LENGTH = 16;
13
+
12
14
  const plural = (n, singular, plural) => (n === 1 ? singular : plural);
13
15
 
14
16
  /**
@@ -26,6 +28,23 @@ const printSizes = (sizes, { formatSize = n => `${n}` }) => {
26
28
  }
27
29
  };
28
30
 
31
+ const getResourceName = resource => {
32
+ const dataUrl = /^data:[^,]+,/.exec(resource);
33
+ if (!dataUrl) return resource;
34
+
35
+ const len = dataUrl[0].length + DATA_URI_CONTENT_LENGTH;
36
+ if (resource.length < len) return resource;
37
+ return `${resource.slice(
38
+ 0,
39
+ Math.min(resource.length - /* '..'.length */ 2, len)
40
+ )}..`;
41
+ };
42
+
43
+ const getModuleName = name => {
44
+ const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
45
+ return [prefix, getResourceName(resource)];
46
+ };
47
+
29
48
  const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
30
49
 
31
50
  /**
@@ -38,6 +57,10 @@ const isValidId = id => {
38
57
  return typeof id === "number" || id;
39
58
  };
40
59
 
60
+ const moreCount = (list, count) => {
61
+ return list && list.length > 0 ? `+ ${count}` : `${count}`;
62
+ };
63
+
41
64
  /** @type {Record<string, (thing: any, context: StatsPrinterContext, printer: StatsPrinter) => string | void>} */
42
65
  const SIMPLE_PRINTERS = {
43
66
  "compilation.summary!": (
@@ -163,13 +186,24 @@ const SIMPLE_PRINTERS = {
163
186
  },
164
187
  "compilation.assetsByChunkName": () => "",
165
188
 
166
- "compilation.filteredModules": filteredModules =>
189
+ "compilation.filteredModules": (
190
+ filteredModules,
191
+ { compilation: { modules } }
192
+ ) =>
167
193
  filteredModules > 0
168
- ? `${filteredModules} ${plural(filteredModules, "module", "modules")}`
194
+ ? `${moreCount(modules, filteredModules)} ${plural(
195
+ filteredModules,
196
+ "module",
197
+ "modules"
198
+ )}`
169
199
  : undefined,
170
200
  "compilation.filteredAssets": (filteredAssets, { compilation: { assets } }) =>
171
201
  filteredAssets > 0
172
- ? `${filteredAssets} ${plural(filteredAssets, "asset", "assets")}`
202
+ ? `${moreCount(assets, filteredAssets)} ${plural(
203
+ filteredAssets,
204
+ "asset",
205
+ "assets"
206
+ )}`
173
207
  : undefined,
174
208
  "compilation.logging": (logging, context, printer) =>
175
209
  Array.isArray(logging)
@@ -262,15 +296,19 @@ const SIMPLE_PRINTERS = {
262
296
  "asset.separator!": () => "\n",
263
297
  "asset.filteredRelated": (filteredRelated, { asset: { related } }) =>
264
298
  filteredRelated > 0
265
- ? `${filteredRelated} related ${plural(
299
+ ? `${moreCount(related, filteredRelated)} related ${plural(
266
300
  filteredRelated,
267
301
  "asset",
268
302
  "assets"
269
303
  )}`
270
304
  : undefined,
271
- "asset.filteredChildren": filteredChildren =>
305
+ "asset.filteredChildren": (filteredChildren, { asset: { children } }) =>
272
306
  filteredChildren > 0
273
- ? `${filteredChildren} ${plural(filteredChildren, "asset", "assets")}`
307
+ ? `${moreCount(children, filteredChildren)} ${plural(
308
+ filteredChildren,
309
+ "asset",
310
+ "assets"
311
+ )}`
274
312
  : undefined,
275
313
 
276
314
  assetChunk: (id, { formatChunkId }) => formatChunkId(id),
@@ -282,8 +320,8 @@ const SIMPLE_PRINTERS = {
282
320
  "module.id": (id, { formatModuleId }) =>
283
321
  isValidId(id) ? formatModuleId(id) : undefined,
284
322
  "module.name": (name, { bold }) => {
285
- const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
286
- return (prefix || "") + bold(resource);
323
+ const [prefix, resource] = getModuleName(name);
324
+ return `${prefix || ""}${bold(resource || "")}`;
287
325
  },
288
326
  "module.identifier": identifier => undefined,
289
327
  "module.layer": (layer, { formatLayer }) =>
@@ -366,21 +404,29 @@ const SIMPLE_PRINTERS = {
366
404
  "module.issuerPath": (issuerPath, { module }) =>
367
405
  module.profile ? undefined : "",
368
406
  "module.profile": profile => undefined,
369
- "module.filteredModules": filteredModules =>
407
+ "module.filteredModules": (filteredModules, { module: { modules } }) =>
370
408
  filteredModules > 0
371
- ? `${filteredModules} nested ${plural(
409
+ ? `${moreCount(modules, filteredModules)} nested ${plural(
372
410
  filteredModules,
373
411
  "module",
374
412
  "modules"
375
413
  )}`
376
414
  : undefined,
377
- "module.filteredReasons": filteredReasons =>
415
+ "module.filteredReasons": (filteredReasons, { module: { reasons } }) =>
378
416
  filteredReasons > 0
379
- ? `${filteredReasons} ${plural(filteredReasons, "reason", "reasons")}`
417
+ ? `${moreCount(reasons, filteredReasons)} ${plural(
418
+ filteredReasons,
419
+ "reason",
420
+ "reasons"
421
+ )}`
380
422
  : undefined,
381
- "module.filteredChildren": filteredChildren =>
423
+ "module.filteredChildren": (filteredChildren, { module: { children } }) =>
382
424
  filteredChildren > 0
383
- ? `${filteredChildren} ${plural(filteredChildren, "module", "modules")}`
425
+ ? `${moreCount(children, filteredChildren)} ${plural(
426
+ filteredChildren,
427
+ "module",
428
+ "modules"
429
+ )}`
384
430
  : undefined,
385
431
  "module.separator!": () => "\n",
386
432
 
@@ -388,7 +434,8 @@ const SIMPLE_PRINTERS = {
388
434
  "moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value),
389
435
 
390
436
  "moduleReason.type": type => type,
391
- "moduleReason.userRequest": (userRequest, { cyan }) => cyan(userRequest),
437
+ "moduleReason.userRequest": (userRequest, { cyan }) =>
438
+ cyan(getResourceName(userRequest)),
392
439
  "moduleReason.moduleId": (moduleId, { formatModuleId }) =>
393
440
  isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
394
441
  "moduleReason.module": (module, { magenta }) => magenta(module),
@@ -397,9 +444,16 @@ const SIMPLE_PRINTERS = {
397
444
  "moduleReason.active": (active, { formatFlag }) =>
398
445
  active ? undefined : formatFlag("inactive"),
399
446
  "moduleReason.resolvedModule": (module, { magenta }) => magenta(module),
400
- "moduleReason.filteredChildren": filteredChildren =>
447
+ "moduleReason.filteredChildren": (
448
+ filteredChildren,
449
+ { moduleReason: { children } }
450
+ ) =>
401
451
  filteredChildren > 0
402
- ? `${filteredChildren} ${plural(filteredChildren, "reason", "reasons")}`
452
+ ? `${moreCount(children, filteredChildren)} ${plural(
453
+ filteredChildren,
454
+ "reason",
455
+ "reasons"
456
+ )}`
403
457
  : undefined,
404
458
 
405
459
  "module.profile.total": (value, { formatTime }) => formatTime(value),
@@ -427,10 +481,21 @@ const SIMPLE_PRINTERS = {
427
481
  size ? formatSize(size) : undefined,
428
482
  "chunkGroup.auxiliaryAssetsSize": (size, { formatSize }) =>
429
483
  size ? `(${formatSize(size)})` : undefined,
430
- "chunkGroup.filteredAssets": n =>
431
- n > 0 ? `${n} ${plural(n, "asset", "assets")}` : undefined,
432
- "chunkGroup.filteredAuxiliaryAssets": n =>
433
- n > 0 ? `${n} auxiliary ${plural(n, "asset", "assets")}` : undefined,
484
+ "chunkGroup.filteredAssets": (n, { chunkGroup: { assets } }) =>
485
+ n > 0
486
+ ? `${moreCount(assets, n)} ${plural(n, "asset", "assets")}`
487
+ : undefined,
488
+ "chunkGroup.filteredAuxiliaryAssets": (
489
+ n,
490
+ { chunkGroup: { auxiliaryAssets } }
491
+ ) =>
492
+ n > 0
493
+ ? `${moreCount(auxiliaryAssets, n)} auxiliary ${plural(
494
+ n,
495
+ "asset",
496
+ "assets"
497
+ )}`
498
+ : undefined,
434
499
  "chunkGroup.is!": () => "=",
435
500
  "chunkGroupAsset.name": (asset, { green }) => green(asset),
436
501
  "chunkGroupAsset.size": (size, { formatSize, chunkGroup }) =>
@@ -490,9 +555,9 @@ const SIMPLE_PRINTERS = {
490
555
  "chunk.recorded": (recorded, { formatFlag, green }) =>
491
556
  recorded ? green(formatFlag("recorded")) : undefined,
492
557
  "chunk.reason": (reason, { yellow }) => (reason ? yellow(reason) : undefined),
493
- "chunk.filteredModules": filteredModules =>
558
+ "chunk.filteredModules": (filteredModules, { chunk: { modules } }) =>
494
559
  filteredModules > 0
495
- ? `${filteredModules} chunk ${plural(
560
+ ? `${moreCount(modules, filteredModules)} chunk ${plural(
496
561
  filteredModules,
497
562
  "module",
498
563
  "modules"
@@ -5,6 +5,14 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ /**
9
+ * Compare two arrays or strings by performing strict equality check for each value.
10
+ * @template T [T=any]
11
+ * @param {ArrayLike<T>} a Array of values to be compared
12
+ * @param {ArrayLike<T>} b Array of values to be compared
13
+ * @returns {boolean} returns true if all the elements of passed arrays are strictly equal.
14
+ */
15
+
8
16
  exports.equals = (a, b) => {
9
17
  if (a.length !== b.length) return false;
10
18
  for (let i = 0; i < a.length; i++) {
@@ -14,13 +22,19 @@ exports.equals = (a, b) => {
14
22
  };
15
23
 
16
24
  /**
17
- *
18
- * @param {Array} arr Array of values to be partitioned
19
- * @param {(value: any) => boolean} fn Partition function which partitions based on truthiness of result.
20
- * @returns {[Array, Array]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
25
+ * Partition an array by calling a predicate function on each value.
26
+ * @template T [T=any]
27
+ * @param {Array<T>} arr Array of values to be partitioned
28
+ * @param {(value: T) => boolean} fn Partition function which partitions based on truthiness of result.
29
+ * @returns {[Array<T>, Array<T>]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
21
30
  */
22
31
  exports.groupBy = (arr = [], fn) => {
23
32
  return arr.reduce(
33
+ /**
34
+ * @param {[Array<T>, Array<T>]} groups An accumulator storing already partitioned values returned from previous call.
35
+ * @param {T} value The value of the current element
36
+ * @returns {[Array<T>, Array<T>]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value.
37
+ */
24
38
  (groups, value) => {
25
39
  groups[fn(value) ? 0 : 1].push(value);
26
40
  return groups;
@@ -19,7 +19,7 @@ let inHandleResult = 0;
19
19
  /**
20
20
  * @template T
21
21
  * @callback Callback
22
- * @param {WebpackError=} err
22
+ * @param {(WebpackError | null)=} err
23
23
  * @param {T=} result
24
24
  */
25
25
 
@@ -10,8 +10,8 @@ const create = require("./wasm-hash");
10
10
  //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
11
11
  const xxhash64 = new WebAssembly.Module(
12
12
  Buffer.from(
13
- // 1173 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrUIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMB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AiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEAgAiABNQIAQoeVr6+Ytt6bnn9+hUIXiULP1tO+0ser2UJ+Qvnz3fGZ9pmrFnwhAiABQQRqIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAkIdiCAChUL5893xmfaZqxZ+IgJCIIggAoUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
15
15
  "base64"
16
16
  )
17
17
  );
@@ -67,6 +67,16 @@ module.exports = {
67
67
  require("../dependencies/ContextElementDependency"),
68
68
  "dependencies/CriticalDependencyWarning": () =>
69
69
  require("../dependencies/CriticalDependencyWarning"),
70
+ "dependencies/CssImportDependency": () =>
71
+ require("../dependencies/CssImportDependency"),
72
+ "dependencies/CssLocalIdentifierDependency": () =>
73
+ require("../dependencies/CssLocalIdentifierDependency"),
74
+ "dependencies/CssSelfLocalIdentifierDependency": () =>
75
+ require("../dependencies/CssSelfLocalIdentifierDependency"),
76
+ "dependencies/CssExportDependency": () =>
77
+ require("../dependencies/CssExportDependency"),
78
+ "dependencies/CssUrlDependency": () =>
79
+ require("../dependencies/CssUrlDependency"),
70
80
  "dependencies/DelegatedSourceDependency": () =>
71
81
  require("../dependencies/DelegatedSourceDependency"),
72
82
  "dependencies/DllEntryDependency": () =>
@@ -175,6 +185,7 @@ module.exports = {
175
185
  ModuleParseError: () => require("../ModuleParseError"),
176
186
  ModuleWarning: () => require("../ModuleWarning"),
177
187
  NormalModule: () => require("../NormalModule"),
188
+ RawDataUrlModule: () => require("../asset/RawDataUrlModule"),
178
189
  RawModule: () => require("../RawModule"),
179
190
  "sharing/ConsumeSharedModule": () =>
180
191
  require("../sharing/ConsumeSharedModule"),
@@ -167,14 +167,20 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
167
167
  )}`,
168
168
  `${RuntimeGlobals.asyncModule}(${
169
169
  module.moduleArgument
170
- }, ${runtimeTemplate.basicFunction(
171
- "__webpack_handle_async_dependencies__",
170
+ }, async ${runtimeTemplate.basicFunction(
171
+ "__webpack_handle_async_dependencies__, __webpack_async_result__",
172
172
  [
173
+ "try {",
173
174
  importsCode,
174
175
  `var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${promises.join(
175
176
  ", "
176
177
  )}]);`,
177
- "return __webpack_async_dependencies__.then ? __webpack_async_dependencies__.then(__webpack_instantiate__) : __webpack_instantiate__(__webpack_async_dependencies__);"
178
+ `var [${promises.join(
179
+ ", "
180
+ )}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__;`,
181
+ `${importsCompatCode}await ${instantiateCall};`,
182
+ "__webpack_async_result__();",
183
+ "} catch(e) { __webpack_async_result__(e); }"
178
184
  ]
179
185
  )}, 1);`
180
186
  ])
@@ -96,7 +96,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
96
96
  )}]`;
97
97
  const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
98
98
  const hasJsMatcher = compileBooleanMatcher(conditionMap);
99
- const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
99
+ const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
100
100
 
101
101
  const stateExpression = withHmr
102
102
  ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_jsonp`
@@ -419,7 +419,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
419
419
  `if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId]) {`,
420
420
  Template.indent("installedChunks[chunkId][0]();"),
421
421
  "}",
422
- "installedChunks[chunkIds[i]] = 0;"
422
+ "installedChunks[chunkId] = 0;"
423
423
  ]),
424
424
  "}",
425
425
  withOnChunkLoad
@@ -6,7 +6,6 @@
6
6
  "use strict";
7
7
 
8
8
  const RuntimeGlobals = require("../RuntimeGlobals");
9
- const CreateScriptUrlRuntimeModule = require("../runtime/CreateScriptUrlRuntimeModule");
10
9
  const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenciesPlugin");
11
10
  const ImportScriptsChunkLoadingRuntimeModule = require("./ImportScriptsChunkLoadingRuntimeModule");
12
11
 
@@ -43,7 +42,9 @@ class ImportScriptsChunkLoadingPlugin {
43
42
  const withCreateScriptUrl = !!compilation.outputOptions.trustedTypes;
44
43
  set.add(RuntimeGlobals.moduleFactoriesAddOnly);
45
44
  set.add(RuntimeGlobals.hasOwnProperty);
46
- if (withCreateScriptUrl) set.add(RuntimeGlobals.createScriptUrl);
45
+ if (withCreateScriptUrl) {
46
+ set.add(RuntimeGlobals.createScriptUrl);
47
+ }
47
48
  compilation.addRuntimeModule(
48
49
  chunk,
49
50
  new ImportScriptsChunkLoadingRuntimeModule(set, withCreateScriptUrl)
@@ -61,15 +62,6 @@ class ImportScriptsChunkLoadingPlugin {
61
62
  compilation.hooks.runtimeRequirementInTree
62
63
  .for(RuntimeGlobals.baseURI)
63
64
  .tap("ImportScriptsChunkLoadingPlugin", handler);
64
- compilation.hooks.runtimeRequirementInTree
65
- .for(RuntimeGlobals.createScriptUrl)
66
- .tap("RuntimePlugin", (chunk, set) => {
67
- compilation.addRuntimeModule(
68
- chunk,
69
- new CreateScriptUrlRuntimeModule()
70
- );
71
- return true;
72
- });
73
65
 
74
66
  compilation.hooks.runtimeRequirementInTree
75
67
  .for(RuntimeGlobals.ensureChunkHandlers)
@@ -53,7 +53,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
53
53
  const hasJsMatcher = compileBooleanMatcher(
54
54
  chunkGraph.getChunkConditionMap(chunk, chunkHasJs)
55
55
  );
56
- const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
56
+ const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
57
57
 
58
58
  const outputName = this.compilation.getPath(
59
59
  getChunkFilenameTemplate(chunk, this.compilation.outputOptions),