webpack 5.111.0 → 5.111.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 (144) hide show
  1. package/lib/APIPlugin.js +3 -4
  2. package/lib/CompatibilityPlugin.js +3 -4
  3. package/lib/Compilation.js +16 -35
  4. package/lib/Compiler.js +4 -5
  5. package/lib/ConstPlugin.js +16 -132
  6. package/lib/DependencyTemplate.js +2 -1
  7. package/lib/DotenvPlugin.js +24 -28
  8. package/lib/ErrorHelpers.js +113 -0
  9. package/lib/ExportsInfo.js +20 -16
  10. package/lib/ExternalModule.js +6 -8
  11. package/lib/FlagDependencyExportsPlugin.js +8 -13
  12. package/lib/FlagDependencyUsagePlugin.js +9 -13
  13. package/lib/Generator.js +24 -2
  14. package/lib/HotModuleReplacementPlugin.js +2 -0
  15. package/lib/IgnorePlugin.js +1 -1
  16. package/lib/LoaderOptionsPlugin.js +1 -1
  17. package/lib/Module.js +3 -3
  18. package/lib/ModuleGraph.js +6 -9
  19. package/lib/MultiCompiler.js +6 -16
  20. package/lib/NormalModule.js +96 -44
  21. package/lib/RuntimeTemplate.js +33 -43
  22. package/lib/SourceMapDevToolPlugin.js +53 -103
  23. package/lib/TemplatedPathPlugin.js +16 -59
  24. package/lib/asset/AssetBytesGenerator.js +7 -1
  25. package/lib/asset/AssetGenerator.js +25 -16
  26. package/lib/asset/AssetSourceGenerator.js +7 -1
  27. package/lib/buildChunkGraph.js +11 -15
  28. package/lib/cache/MemoryCachePlugin.js +4 -4
  29. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  30. package/lib/cache/PackFileCacheStrategy.js +3 -18
  31. package/lib/cache/getLazyHashedEtag.js +3 -5
  32. package/lib/config/browserslistTargetHandler.js +2 -8
  33. package/lib/config/defaults.js +52 -78
  34. package/lib/config/getClaimedAssetTypes.js +10 -11
  35. package/lib/config/target.js +3 -4
  36. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  37. package/lib/{ContextModule.js → context/ContextModule.js} +37 -34
  38. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  39. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  40. package/lib/css/CssGenerator.js +19 -11
  41. package/lib/css/CssParser.js +18 -20
  42. package/lib/css/cssMinify.js +32 -29
  43. package/lib/css/data.js +797 -288
  44. package/lib/css/syntax.js +2250 -934
  45. package/lib/debug/ProfilingPlugin.js +3 -4
  46. package/lib/dependencies/CommonJsExportRequireDependency.js +10 -11
  47. package/lib/dependencies/CommonJsImportsParserPlugin.js +4 -5
  48. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  49. package/lib/dependencies/ContextDependency.js +1 -1
  50. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  51. package/lib/dependencies/ContextElementDependency.js +1 -1
  52. package/lib/dependencies/CssIcssExportDependency.js +6 -8
  53. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  54. package/lib/dependencies/CssUrlDependency.js +3 -5
  55. package/lib/dependencies/HarmonyCompatibilityDependency.js +11 -20
  56. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  57. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -4
  58. package/lib/dependencies/HarmonyExportExpressionDependency.js +3 -4
  59. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +3 -4
  60. package/lib/dependencies/HarmonyExportInitFragment.js +26 -19
  61. package/lib/dependencies/HarmonyExportSpecifierDependency.js +7 -28
  62. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +103 -16
  63. package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
  64. package/lib/dependencies/HarmonyImportSpecifierDependency.js +16 -2
  65. package/lib/dependencies/HtmlEntryDependency.js +74 -102
  66. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  67. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  68. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  69. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  70. package/lib/dependencies/ImportMetaPlugin.js +8 -10
  71. package/lib/dependencies/ImportParserPlugin.js +1 -1
  72. package/lib/dependencies/LoaderPlugin.js +26 -1
  73. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  74. package/lib/dependencies/URLContextDependency.js +1 -1
  75. package/lib/dependencies/URLDependency.js +6 -5
  76. package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
  77. package/lib/dependencies/WorkerDependency.js +6 -5
  78. package/lib/dependencies/WorkletDependency.js +6 -9
  79. package/lib/errors/HookWebpackError.js +3 -2
  80. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  81. package/lib/html/HtmlGenerator.js +61 -82
  82. package/lib/html/HtmlModulesPlugin.js +88 -139
  83. package/lib/html/HtmlParser.js +97 -141
  84. package/lib/html/data.js +21 -0
  85. package/lib/html/htmlMinify.js +10 -11
  86. package/lib/html/syntax.js +883 -993
  87. package/lib/index.js +46 -3
  88. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  89. package/lib/javascript/JavascriptGenerator.js +8 -1
  90. package/lib/javascript/JavascriptModulesPlugin.js +21 -48
  91. package/lib/javascript/JavascriptParser.js +721 -178
  92. package/lib/javascript/parser.js +6 -0
  93. package/lib/javascript/syntax.js +420 -92
  94. package/lib/json/JsonGenerator.js +7 -1
  95. package/lib/library/ModuleLibraryPlugin.js +64 -136
  96. package/lib/loaders/LoaderRunner.js +137 -9
  97. package/lib/node/NodeWatchFileSystem.js +3 -9
  98. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  99. package/lib/optimize/ConcatenatedModule.js +81 -100
  100. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  101. package/lib/optimize/InnerGraphPlugin.js +7 -13
  102. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  103. package/lib/optimize/MangleExportsPlugin.js +3 -4
  104. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  105. package/lib/optimize/SideEffectsFlagPlugin.js +7 -19
  106. package/lib/optimize/SplitChunksPlugin.js +2 -4
  107. package/lib/performance/BroadContextsPlugin.js +1 -1
  108. package/lib/performance/CacheEffectivenessPlugin.js +3 -4
  109. package/lib/performance/SizeLimitsPlugin.js +2 -4
  110. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +6 -8
  111. package/lib/prefetch/ResourceHintPlugin.js +17 -21
  112. package/lib/prefetch/StartupAssetHintRuntimeModule.js +7 -10
  113. package/lib/runtime/AsyncModuleRuntimeModule.js +3 -5
  114. package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
  115. package/lib/runtime/GlobalRuntimeModule.js +2 -4
  116. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +55 -85
  117. package/lib/schemes/DataUriPlugin.js +3 -6
  118. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  119. package/lib/serialization/BinaryMiddleware.js +9 -9
  120. package/lib/serialization/FileMiddleware.js +16 -16
  121. package/lib/serialization/ObjectMiddleware.js +30 -33
  122. package/lib/stats/DefaultStatsFactoryPlugin.js +3 -4
  123. package/lib/typescript/TypeScriptPlugin.js +2 -3
  124. package/lib/url/URLParserPlugin.js +6 -8
  125. package/lib/util/LocConverter.js +4 -7
  126. package/lib/util/SourceProcessor.js +15 -22
  127. package/lib/util/chainedImports.js +3 -4
  128. package/lib/util/concatenate.js +4 -4
  129. package/lib/util/createHooksRegistry.js +1 -2
  130. package/lib/util/dataURL.js +2 -3
  131. package/lib/util/deterministicGrouping.js +8 -13
  132. package/lib/util/findGraphRoots.js +6 -13
  133. package/lib/util/globUtils.js +1 -1
  134. package/lib/util/hash/wasm-hash.js +3 -4
  135. package/lib/util/internalSerializables.js +1 -1
  136. package/lib/util/semver.js +5 -3
  137. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  138. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  139. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -4
  140. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  141. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  142. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  143. package/package.json +30 -23
  144. package/types.d.ts +299 -280
@@ -63,13 +63,10 @@ class LocConverter {
63
63
  // Retreat on line 1: no `\n` precedes `pos`, the cache stays valid.
64
64
  this.column = pos;
65
65
  } else {
66
- // Retreat: count newlines crossed in (pos, this.pos), i.e.
67
- // exclude the newline at `this.pos` itself. By convention a
68
- // `\n` is the last column of its line, so when `this.pos`
69
- // sits on one we're already on the line containing it; only
70
- // newlines strictly **before** `this.pos` and at-or-after
71
- // `pos` represent crossed line boundaries. The smallest
72
- // crossed one is the next newline after the new position.
66
+ // WHY: A `\n` counts as the last column of its own line here, so a
67
+ // `this.pos` sitting on one is already on that line. Retreating
68
+ // therefore crosses only the newlines at or after `pos` and strictly
69
+ // before `this.pos` — the newline at `this.pos` is not one of them.
73
70
  let i = input.lastIndexOf("\n", this.pos - 1);
74
71
  while (i >= pos) {
75
72
  this._nextNewline = i;
@@ -272,12 +272,9 @@ class PrintContext {
272
272
  this._storeLow = 0x7fffffff;
273
273
  /** @type {number} highest slot written since the epoch last moved */
274
274
  this._storeHigh = -1;
275
- // Output accumulates into `_tail`, a plain string append, so printing that
276
- // never takes anything back costs exactly what appending to one string
277
- // costs. A piece is cut off into `_chunks` only for text that may still be
278
- // taken back ({@link emitRetractable}) — that is what lets a printer emit
279
- // before it knows a later sibling overrides it, without every other emit
280
- // paying for the ability. The output is `_chunks` joined, then `_tail`.
275
+ // Output is `_chunks` joined, then `_tail`. Printing that never takes
276
+ // anything back only appends to `_tail`; a piece is cut off into `_chunks`
277
+ // for retractable text alone, so no other emit pays for that ability.
281
278
  /** @type {string[]} pieces already cut off, in output order */
282
279
  this._chunks = [];
283
280
  /** @type {string} output after the last cut piece */
@@ -299,10 +296,9 @@ class PrintContext {
299
296
  this._inserts = [];
300
297
  /** @type {number} next `_inserts` entry not yet flushed */
301
298
  this._insertIdx = 0;
302
- // Openers of the nodes being printed in pieces, innermost last, held back
303
- // until one of them turns out to have content: a node whose children all
304
- // print to nothing can then still be dropped whole, which is the one thing
305
- // emitting an opener eagerly would give up.
299
+ // Openers of the nodes printed in pieces, innermost last, held back until
300
+ // one has content — which is what lets a node whose children all print to
301
+ // nothing still be dropped whole.
306
302
  /** @type {string[]} openers not yet emitted, outermost first */
307
303
  this._pending = [];
308
304
  /** @type {[number | undefined, number | undefined, number | undefined] | null} anchor for the first pending opener */
@@ -524,14 +520,12 @@ class PrintContext {
524
520
  _emit(text) {
525
521
  this._tail += text;
526
522
  this._tailLength += text.length;
527
- // A printer returns its text as a rope of its children's pieces, and
528
- // appending a rope onto a rope keeps every fragment of every node reachable
529
- // until the output is finally flattened — on a stylesheet of many top-level
530
- // rules, a second copy of the whole output. So cut the tail off once it has
531
- // grown past a block and force that block flat, which drops every fragment
532
- // behind it. Per block rather than per piece: the flattening copy is one
533
- // the result would have paid for anyway, but paying it per piece means an
534
- // allocation for each, and the pieces are small.
523
+ // WHY: A printer returns a rope of its children's pieces, and appending a
524
+ // rope onto a rope keeps every fragment reachable until the output is
525
+ // flattened — a second copy of a large stylesheet. Cutting the tail once it
526
+ // passes a block forces that block flat and drops the fragments behind it.
527
+ // Per block rather than per piece: the copy is one the result pays anyway,
528
+ // while per piece it would be an allocation each, and the pieces are small.
535
529
  if (this._tailLength >= FLATTEN_BLOCK) this._cutTail();
536
530
  }
537
531
 
@@ -1020,10 +1014,9 @@ class SourceProcessor {
1020
1014
  this._grammar(input, this._visitors, undefined, opts);
1021
1015
  return undefined;
1022
1016
  }
1023
- // Handed over whole rather than copied entry by entry: which of them are
1024
- // print options is the language's to say, and listing them here is what
1025
- // made every new one an edit to this file. A grammar-only entry riding
1026
- // along is inert — a printer reads only what its own type declares.
1017
+ // Handed over whole rather than copied entry by entry: which entries are
1018
+ // print options is the language's to say, and a grammar-only one riding
1019
+ // along is inert, since a printer reads only what its own type declares.
1027
1020
  const ctx = new PrintContext(
1028
1021
  /** @type {PrintOptions & TPrintOptions} */ (
1029
1022
  /** @type {unknown} */ ({ ...opts, mode: asked })
@@ -39,10 +39,9 @@ module.exports.getTrimmedIdsAndRange = (
39
39
  );
40
40
  let trimmedRange = untrimmedRange;
41
41
  if (trimmedIds.length !== untrimmedIds.length) {
42
- // The array returned from dep.idRanges is right-aligned with the array returned from dep.names.
43
- // Meaning, the two arrays may not always have the same number of elements, but the last element of
44
- // dep.idRanges corresponds to [the expression fragment to the left of] the last element of dep.names.
45
- // Use this to find the correct replacement range based on the number of ids that were trimmed.
42
+ // `dep.idRanges` is right-aligned with `dep.names`: the two may differ in
43
+ // length, but their last elements correspond, which is what turns the count
44
+ // of trimmed ids into the replacement range.
46
45
  const idx =
47
46
  ranges === undefined
48
47
  ? -1 /* trigger failure case below */
@@ -324,10 +324,10 @@ const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {
324
324
  }
325
325
  };
326
326
 
327
- // Declared by the chunk bootstrap in the scope module code is hoisted into.
328
- // Hit when a webpack bundle is bundled again, since its output declares exactly
329
- // these: the `const` one then fails to parse, the `var` one silently clobbers
330
- // the module table. CompatibilityPlugin renames the other two runtime names.
327
+ // WHY: Declared by the chunk bootstrap in the scope module code is hoisted
328
+ // into, so re-bundling a webpack bundle collides with them: the `const` one
329
+ // fails to parse and the `var` one silently clobbers the module table.
330
+ // CompatibilityPlugin renames the other two runtime names.
331
331
  const CHUNK_RUNTIME_DECLARATIONS = new Set([
332
332
  "__webpack_modules__",
333
333
  "__webpack_module_cache__"
@@ -15,8 +15,7 @@ const createHooksRegistry = (createHooks) => {
15
15
  return (compilation) => {
16
16
  let hooks = map.get(compilation);
17
17
  if (hooks === undefined) {
18
- // validated once per compilation — this runs on every render and
19
- // codegen. Matched by class name, not `instanceof`: a compilation from
18
+ // Matched by class name rather than `instanceof`: a compilation from
20
19
  // another webpack copy has to pass too, and importing `Compilation`
21
20
  // here cycles.
22
21
  const candidate =
@@ -44,9 +44,8 @@ const decodeDataURI = (uri) => {
44
44
  */
45
45
 
46
46
  // `URIRegEx`'s `.` stops at a newline, which a raw `<svg>` payload carries, and
47
- // its `base64` group is optional in a way that reads `;charset=utf8` as one.
48
- // This one is the strict split a rewriter needs; that one stays as the matcher
49
- // module requests are recognized by.
47
+ // its optional `base64` group reads `;charset=utf8` as one. This is the strict
48
+ // split a rewriter needs; that one stays as the matcher for module requests.
50
49
  const STRICT_URI_REGEXP = /^data:([^,;]*)((?:;[^,;]*)*),([\s\S]*)$/i;
51
50
 
52
51
  const JSON_TYPE = "json";
@@ -450,12 +450,11 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
450
450
  right--;
451
451
  }
452
452
 
453
+ // WHY: both sides already clear minSize here.
453
454
  // left v v right
454
455
  // [ O O O ] O O O [ O O O ]
455
456
  // ^^^^^^^^^ leftSize
456
457
  // rightSize ^^^^^^^^^
457
- // leftSize > minSize
458
- // rightSize > minSize
459
458
 
460
459
  // Perfect split: [ O O O ] [ O O O ]
461
460
  // right === left - 1
@@ -476,26 +475,22 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
476
475
  queue.push(group);
477
476
  continue;
478
477
  }
479
- // can't split group while holding minSize
480
- // because minSize is preferred of maxSize we return
481
- // the problematic nodes as result here even while it's too big
482
- // To avoid this make sure maxSize > minSize * 3
478
+ // No split holds minSize, which is preferred over maxSize, so these
479
+ // nodes are returned oversized. Keeping maxSize > minSize * 3
480
+ // avoids it.
483
481
  result.push(group);
484
482
  continue;
485
483
  }
486
484
  if (left <= right) {
487
- // when there is a area between left and right
488
- // we look for best split point
489
- // we split at the minimum similarity
490
- // here key space is separated the most
491
- // But we also need to make sure to not create too small groups
485
+ // In the area between left and right, split at the minimum
486
+ // similarity, where the key space is separated the most — without
487
+ // creating groups that are too small.
492
488
  let best = -1;
493
489
  let bestSimilarity = Infinity;
494
490
  let pos = left;
495
491
  const rightSize = sumSize(group.nodes, pos);
496
492
 
497
- // pos v v right
498
- // [ O O O ] O O O [ O O O ]
493
+ // [ O O O ] O O O [ O O O ] pos, then right
499
494
  // ^^^^^^^^^ leftSize
500
495
  // rightSize ^^^^^^^^^^^^^^^
501
496
 
@@ -125,12 +125,9 @@ module.exports = (items, getDependencies) => {
125
125
  depSCC.marker = IN_PROGRESS_MARKER;
126
126
  break;
127
127
  case IN_PROGRESS_MARKER: {
128
- // Back-edge to an SCC that is still on the stack
129
- // Example:
130
- // A -> B -> C -> D
131
- // ^ |
132
- // |_________|
133
- // If we are at `D` and traverse `D` -> `B`, then `B/C/D` must be in one SCC
128
+ // A back-edge to an SCC still on the stack merges every SCC
129
+ // above it — in `A -> B -> C -> D` with `D -> B`, reaching `B`
130
+ // from `D` puts `B`, `C` and `D` into one SCC.
134
131
  /** @type {Set<SCC<T>>} */
135
132
  const sccsToMerge = new Set();
136
133
  for (
@@ -162,13 +159,9 @@ module.exports = (items, getDependencies) => {
162
159
  // All dependencies of the current node have been processed
163
160
  // So we leave the node
164
161
  stack.pop();
165
- // Mark an SCC as DONE only when the popped node is the last
166
- // node from that SCC remaining on the current stack.
167
- // A -> B -> C -> D
168
- // ^ |
169
- // |_________|
170
- // If `B` is popped and the new stack top is `A`, they are in
171
- // different SCCs, so B's SCC can be finalized.
162
+ // An SCC is DONE only once the popped node is its last one on
163
+ // the stack. In `A -> B -> C -> D` with `D -> B`, popping `B` onto a
164
+ // stack topped by `A` — a different SCC — finalizes B's.
172
165
  if (
173
166
  stack.length &&
174
167
  topOfStack.node.scc !== stack[stack.length - 1].node.scc
@@ -558,7 +558,7 @@ const braceFreeGlobToPathRegExpSource = (glob) => {
558
558
  * pattern built with `path.resolve` works everywhere; use `[*]` to match a
559
559
  * literal `*`), and a relative pattern matches at any depth. Matching follows
560
560
  * `path.matchesGlob`, except where its minimatch shows through — see the
561
- * divergences listed above the corpus in `test/globUtils.unittest.js`.
561
+ * divergences listed above the corpus in `test/unitCases/globUtils.unittest.js`.
562
562
  * @param {string} pattern glob pattern
563
563
  * @param {GlobMatchOptions=} options options
564
564
  * @returns {((str: string) => boolean) | null} matcher, null for un-compilable patterns
@@ -7,10 +7,9 @@
7
7
 
8
8
  const Hash = require("../Hash");
9
9
 
10
- // 65536 is the size of a wasm memory page
11
- // 64 is the maximum chunk size for every possible wasm hash implementation
12
- // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
13
- // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
10
+ // 65536 is a wasm memory page, 64 the largest chunk size any wasm hash
11
+ // implementation takes, 4 the most bytes utf-8 spends on one char, and `& ~3`
12
+ // keeps it a whole block of 4 chars so base64 never sees a partial encoding.
14
13
  const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
15
14
 
16
15
  /**
@@ -31,6 +31,7 @@ module.exports = {
31
31
  "container/RemoteModule": () => require("../container/RemoteModule"),
32
32
  "container/RemoteToExternalDependency": () =>
33
33
  require("../container/RemoteToExternalDependency"),
34
+ "context/ContextModule": () => require("../context/ContextModule"),
34
35
  "dependencies/AMDDefineDependency": () =>
35
36
  require("../dependencies/AMDDefineDependency"),
36
37
  "dependencies/AMDRequireArrayDependency": () =>
@@ -261,7 +262,6 @@ module.exports = {
261
262
  "wasm-async/AsyncWasmModule": () => require("../wasm-async/AsyncWasmModule"),
262
263
  "wasm-sync/SyncWasmModule": () => require("../wasm-sync/SyncWasmModule"),
263
264
  AsyncDependenciesBlock: () => require("../AsyncDependenciesBlock"),
264
- ContextModule: () => require("../ContextModule"),
265
265
  CssModule: () => require("../css/CssModule"),
266
266
  DependenciesBlock: () => require("../DependenciesBlock"),
267
267
  ExternalModule: () => require("../ExternalModule"),
@@ -63,6 +63,7 @@ const versionLt = (a, b) => {
63
63
  b = parseVersion(b);
64
64
  var i = 0;
65
65
  for (;;) {
66
+ // WHY: the ordering this loop implements, by the type of each side.
66
67
  // a b EOA object undefined number string
67
68
  // EOA a == b a < b b < a a < b a < b
68
69
  // object b < a (0) b < a a < b a < b
@@ -185,6 +186,7 @@ module.exports.parseRange = (str) => {
185
186
  * @returns {SemVerRange}
186
187
  */
187
188
  const parseSimple = (str) => {
189
+ // WHY: the grammar this parses.
188
190
  // simple ::= primitive | partial | tilde | caret
189
191
  // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | '!' ) ( ' ' ) * partial
190
192
  // tilde ::= '~' ( ' ' ) * partial
@@ -399,7 +401,7 @@ const satisfy = (range, version) => {
399
401
  for (var i = 0, j = 1, isEqual = true; ; j++, i++) {
400
402
  // cspell:word nequal nequ
401
403
 
402
- // when isEqual = true:
404
+ // WHY: the decision table this loop implements, when isEqual = true:
403
405
  // range version: EOA/object undefined number string
404
406
  // EOA equal block big-ver big-ver
405
407
  // undefined bigger next big-ver big-ver
@@ -408,7 +410,7 @@ const satisfy = (range, version) => {
408
410
  // string smaller block differ cmp
409
411
  // fixed string smaller block small-cmp cmp-fix
410
412
 
411
- // when isEqual = false:
413
+ // WHY: and when isEqual = false:
412
414
  // range version: EOA/object undefined number string
413
415
  // EOA nequal block next-ver next-ver
414
416
  // undefined nequal block next-ver next-ver
@@ -417,7 +419,7 @@ const satisfy = (range, version) => {
417
419
  // string nequal block next next
418
420
  // fixed string nequal block next next (this never happens)
419
421
 
420
- // EOA end of array
422
+ // WHY: EOA is end of array; what each cell of the two tables means:
421
423
  // equal (version is equal range):
422
424
  // when !negated: return true,
423
425
  // when negated: return false
@@ -72,7 +72,12 @@ class AsyncWebAssemblyGenerator extends Generator {
72
72
  * @returns {Source | null} generated code
73
73
  */
74
74
  generateError(error, module, generateContext) {
75
- return new RawSource(error.message);
75
+ return new RawSource(
76
+ Generator.buildErrorMessage(
77
+ error,
78
+ generateContext.runtimeTemplate.requestShortener
79
+ )
80
+ );
76
81
  }
77
82
  }
78
83
 
@@ -303,7 +303,11 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
303
303
  */
304
304
  generateError(error, module, generateContext) {
305
305
  return new RawSource(
306
- Generator.throwBuildErrorCode(error, "WebAssembly.CompileError")
306
+ Generator.throwBuildErrorCode(
307
+ error,
308
+ "WebAssembly.CompileError",
309
+ generateContext.runtimeTemplate.requestShortener
310
+ )
307
311
  );
308
312
  }
309
313
  }
@@ -339,10 +339,9 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
339
339
  stateExpression ? runtimeTemplate.assignOr(stateExpression, "{}") : "{}"
340
340
  };`,
341
341
  "",
342
- // This function is used to delay reading the installed wasm module promises
343
- // by a microtask. Sorting them doesn't help because there are edge cases where
344
- // sorting is not possible (modules splitted into different chunks).
345
- // So we not even trying and solve this by a microtask delay.
342
+ // Delays reading the installed wasm module promises by a microtask.
343
+ // Sorting them instead is not always possible — modules split across
344
+ // chunks have no order — so the delay is what is relied on.
346
345
  "function promiseResolve() { return Promise.resolve(); }",
347
346
  "",
348
347
  Template.asString(declarations),
@@ -544,7 +544,12 @@ class WebAssemblyGenerator extends Generator {
544
544
  * @returns {Source | null} generated code
545
545
  */
546
546
  generateError(error, module, generateContext) {
547
- return new RawSource(error.message);
547
+ return new RawSource(
548
+ Generator.buildErrorMessage(
549
+ error,
550
+ generateContext.runtimeTemplate.requestShortener
551
+ )
552
+ );
548
553
  }
549
554
 
550
555
  /**
@@ -232,7 +232,11 @@ class WebAssemblyJavascriptGenerator extends Generator {
232
232
  */
233
233
  generateError(error, module, generateContext) {
234
234
  return new RawSource(
235
- Generator.throwBuildErrorCode(error, "WebAssembly.CompileError")
235
+ Generator.throwBuildErrorCode(
236
+ error,
237
+ "WebAssembly.CompileError",
238
+ generateContext.runtimeTemplate.requestShortener
239
+ )
236
240
  );
237
241
  }
238
242
  }
@@ -42,10 +42,8 @@ const getUsedDependencies = (moduleGraph, module, mangle) => {
42
42
  }
43
43
 
44
44
  const exportName = dep.name;
45
- // TODO add the following 3 lines when removing of ModuleExport is possible
46
- // const importedModule = moduleGraph.getModule(dep);
47
- // const usedName = importedModule && moduleGraph.getExportsInfo(importedModule).getUsedName(exportName, runtime);
48
- // if (usedName !== false) {
45
+ // TODO once ModuleExport can be removed, skip a dependency whose
46
+ // imported module reports `getUsedName(exportName, runtime) === false`.
49
47
  if (mangle) {
50
48
  array.push({
51
49
  dependency: dep,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.111.0",
3
+ "version": "5.111.1",
4
4
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",
@@ -34,13 +34,12 @@
34
34
  "prelint": "yarn setup",
35
35
  "lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-benchmark && yarn lint:types-module-test && yarn lint:types-hot && yarn fmt:check && yarn lint:spellcheck",
36
36
  "lint:code": "node node_modules/eslint/bin/eslint.js --cache .",
37
- "lint:special": "node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node tooling/generate-css-data.js && node tooling/generate-html-data.js && node tooling/generate-js-data.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals && node tooling/generate-internal-serializables.js",
37
+ "lint:special": "node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node tooling/generate-css-data.js && node tooling/generate-html-data.js && node tooling/generate-js-data.js && node tooling/generate-types.js --no-template-literals && node tooling/generate-internal-serializables.js",
38
38
  "lint:types": "tsc",
39
39
  "lint:types-test": "tsc -p tsconfig.types.test.json",
40
40
  "lint:types-benchmark": "tsc -p tsconfig.types.benchmark.json",
41
41
  "lint:types-hot": "tsc -p tsconfig.hot.json",
42
42
  "lint:types-module-test": "tsc -p tsconfig.module.test.json",
43
- "lint:comments": "node tooling/check-comment-length.js",
44
43
  "lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
45
44
  "validate:changeset": "node .changeset/changeset-validate.mjs",
46
45
  "validate:types": "tsc -p tsconfig.validation.json",
@@ -49,7 +48,7 @@
49
48
  "fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
50
49
  "fix": "yarn fix:code && yarn fix:special && yarn fmt",
51
50
  "fix:code": "yarn lint:code --fix",
52
- "fix:special": "node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node tooling/generate-css-data.js --write && node tooling/generate-html-data.js --write && node tooling/generate-js-data.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write && node tooling/generate-internal-serializables.js --write",
51
+ "fix:special": "node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node tooling/generate-css-data.js --write && node tooling/generate-html-data.js --write && node tooling/generate-js-data.js --write && node tooling/generate-types.js --no-template-literals --write && node tooling/generate-internal-serializables.js --write",
53
52
  "fix:serializables": "node tooling/generate-internal-serializables.js --write",
54
53
  "build:examples": "cd examples && node buildAll.js",
55
54
  "benchmark": "node --max-old-space-size=6144 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
@@ -59,44 +58,46 @@
59
58
  "benchmark:html-tools:setup": "node tooling/compare-html-tools.js --setup",
60
59
  "benchmark:js-tools": "node tooling/compare-js-tools.js",
61
60
  "measure:color-agreement": "node tooling/measure-color-agreement.js",
61
+ "setup:firefox": "node tooling/install-firefox.js",
62
+ "setup:webkit": "node node_modules/playwright-core/cli.js install webkit",
62
63
  "pretest": "yarn lint",
63
64
  "test": "yarn test:base",
64
65
  "test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --workerIdleMemoryLimit=512MB --logHeapUsage",
65
66
  "test:basic": "yarn test:base --testMatch \"<rootDir>/test/*.basictest.js\"",
66
67
  "test:basic:deno": "yarn test:base:deno --testMatch \"<rootDir>/test/*.basictest.js\"",
67
68
  "test:basic:bun": "yarn test:base:bun --testMatch \"<rootDir>/test/*.basictest.js\"",
68
- "test:unit": "yarn test:base --testMatch \"<rootDir>/test/*.unittest.js\"",
69
+ "test:unit": "yarn test:base --testMatch \"<rootDir>/test/unitCases/*.unittest.js\"",
69
70
  "test:integration": "yarn test:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
70
71
  "test:integration:a": "yarn test:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\"",
71
72
  "test:integration:b": "yarn test:base --testMatch \"<rootDir>/test/*.longtest.js\"",
72
- "test:test262": "yarn test:base --testMatch \"<rootDir>/test/test262.spectest.js\"",
73
- "test:test262-parser": "yarn test:base --testMatch \"<rootDir>/test/test262-parser.spectest.js\"",
74
- "test:html5lib": "yarn test:base --testMatch \"<rootDir>/test/html5lib.spectest.js\"",
75
- "test:syntax-equivalence": "yarn test:base --testMatch \"<rootDir>/test/syntaxEquivalence.spectest.js\"",
76
- "test:css-parsing": "yarn test:base --testMatch \"<rootDir>/test/cssParsing-webpack.spectest.js\"",
77
- "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\" \"(ProfilingPlugin[.]unittest|WebpackDevServer)\"",
78
- "test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --allow-net --import-map=test/deno-import-map.json --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --workerIdleMemoryLimit=512MB --logHeapUsage",
79
- "test:bun": "yarn test:base:bun --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\" \"(ProfilingPlugin[.]unittest|WebpackDevServer)\"",
80
- "test:base:bun": "NODE_EXTRA_CA_CERTS=./test/hotCases/lazy-compilation/https/cert.pem bun --bun --smol --preload ./test/bun-preload.js ./node_modules/jest-cli/bin/jest.js --workerThreads --workerIdleMemoryLimit=2048MB --logHeapUsage",
73
+ "test:test262": "yarn test:base --testMatch \"<rootDir>/test/specCases/test262.spectest.js\"",
74
+ "test:test262-parser": "yarn test:base --testMatch \"<rootDir>/test/specCases/test262-parser.spectest.js\"",
75
+ "test:html5lib": "yarn test:base --testMatch \"<rootDir>/test/specCases/html5lib.spectest.js\"",
76
+ "test:syntax-equivalence": "yarn test:base --testMatch \"<rootDir>/test/specCases/syntaxEquivalence.spectest.js\"",
77
+ "test:css-parsing": "yarn test:base --testMatch \"<rootDir>/test/specCases/cssParsing-webpack.spectest.js\"",
78
+ "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/harness/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" \"<rootDir>/test/unitCases/*.unittest.js\" --testPathIgnorePatterns \"/node_modules/\" \"(ProfilingPlugin[.]unittest|WebpackDevServer)\"",
79
+ "test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --allow-net --import-map=test/harness/runtimes/deno-import-map.json --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --workerIdleMemoryLimit=512MB --logHeapUsage",
80
+ "test:bun": "yarn test:base:bun --reporters default --reporters \"<rootDir>/test/harness/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" \"<rootDir>/test/unitCases/*.unittest.js\" --testPathIgnorePatterns \"/node_modules/\" \"(ProfilingPlugin[.]unittest|WebpackDevServer)\"",
81
+ "test:base:bun": "NODE_EXTRA_CA_CERTS=./test/hotCases/lazy-compilation/https/cert.pem bun --bun --smol --preload ./test/harness/runtimes/bun-preload.js ./node_modules/jest-cli/bin/jest.js --workerThreads --workerIdleMemoryLimit=2048MB --logHeapUsage",
81
82
  "test:update-snapshots": "yarn test:base -u",
82
83
  "test:size": "node --max-old-space-size=4096 ./test/CodeSizeTestCases.size.js",
83
84
  "report:cover": "nyc report --reporter=lcov --reporter=text -t coverage",
84
85
  "report:cover:clean": "rimraf .nyc_output coverage",
85
86
  "report:cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
86
- "types:cover": "node node_modules/tooling/type-coverage",
87
+ "types:cover": "node tooling/type-coverage.js",
87
88
  "types:cover:report": "rimraf coverage && yarn types:cover && yarn report:cover && open-cli coverage/lcov-report/index.html",
88
89
  "cover": "yarn cover:all && yarn report:cover",
89
90
  "cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --workerIdleMemoryLimit=512MB --logHeapUsage",
90
91
  "cover:all": "yarn cover:base --coverage",
91
- "cover:unit": "yarn cover:base --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
92
+ "cover:unit": "yarn cover:base --testMatch \"<rootDir>/test/unitCases/*.unittest.js\" --coverage",
92
93
  "cover:basic": "yarn cover:base --testMatch \"<rootDir>/test/*.basictest.js\" --coverage",
93
94
  "cover:integration": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" --coverage",
94
95
  "cover:integration:a": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage",
95
96
  "cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage",
96
- "cover:test262": "yarn cover:base --testMatch \"<rootDir>/test/test262.spectest.js\" --coverage",
97
- "cover:html5lib": "yarn cover:base --testMatch \"<rootDir>/test/html5lib.spectest.js\" --coverage",
98
- "cover:syntax-equivalence": "yarn cover:base --testMatch \"<rootDir>/test/syntaxEquivalence.spectest.js\" --coverage",
99
- "cover:css-parsing": "yarn cover:base --testMatch \"<rootDir>/test/cssParsing-webpack.spectest.js\" --coverage"
97
+ "cover:test262": "yarn cover:base --testMatch \"<rootDir>/test/specCases/test262.spectest.js\" --coverage",
98
+ "cover:html5lib": "yarn cover:base --testMatch \"<rootDir>/test/specCases/html5lib.spectest.js\" --coverage",
99
+ "cover:syntax-equivalence": "yarn cover:base --testMatch \"<rootDir>/test/specCases/syntaxEquivalence.spectest.js\" --coverage",
100
+ "cover:css-parsing": "yarn cover:base --testMatch \"<rootDir>/test/specCases/cssParsing-webpack.spectest.js\" --coverage"
100
101
  },
101
102
  "lint-staged": {
102
103
  "*.{js,cjs,mjs}": [
@@ -133,6 +134,7 @@
133
134
  "@changesets/get-github-info": "^1.0.1",
134
135
  "@codspeed/core": "^5.5.0",
135
136
  "@mdn/browser-compat-data": "^8.0.9",
137
+ "@puppeteer/browsers": "^3.2.2",
136
138
  "@types/convert-source-map": "^2.0.3",
137
139
  "@types/graceful-fs": "^4.1.9",
138
140
  "@types/jest": "^30.0.0",
@@ -143,12 +145,14 @@
143
145
  "@webref/elements": "^2.8.0",
144
146
  "@webref/idl": "^3.83.1",
145
147
  "acorn": "^8.16.0",
148
+ "ajv": "^8.20.0",
146
149
  "assemblyscript": "^0.28.18",
147
150
  "babel-loader": "^10.0.0",
148
151
  "bundle-loader": "^0.5.6",
149
152
  "coffee-loader": "^5.0.0",
150
153
  "coffeescript": "^2.5.1",
151
154
  "color-name": "^2.1.1",
155
+ "commondir": "^1.0.1",
152
156
  "core-js": "^3.47.0",
153
157
  "cspell": "^10.0.1",
154
158
  "css-loader": "^7.1.2",
@@ -156,11 +160,12 @@
156
160
  "es5-ext": "^0.10.53",
157
161
  "es6-promise-polyfill": "^1.2.0",
158
162
  "eslint": "^9.39.5",
159
- "eslint-config-webpack": "^4.12.0",
163
+ "eslint-config-webpack": "^4.14.0",
160
164
  "eslint-scope": "^9.1.2",
161
165
  "eta": "^4.6.0",
162
166
  "file-loader": "^6.0.0",
163
167
  "fork-ts-checker-webpack-plugin": "^9.0.2",
168
+ "glob": "^13.0.6",
164
169
  "globals": "^17.6.0",
165
170
  "hash-wasm": "^4.9.0",
166
171
  "html-loader": "^5.1.0",
@@ -175,6 +180,7 @@
175
180
  "jest-snapshot": "^30.3.0",
176
181
  "jest-worker": "^30.2.0",
177
182
  "json-loader": "^0.5.7",
183
+ "json-schema-to-typescript": "^15.0.4",
178
184
  "json5": "^2.1.3",
179
185
  "less": "^4.6.4",
180
186
  "less-loader": "^13.0.0",
@@ -191,6 +197,7 @@
191
197
  "open-cli": "^9.0.0",
192
198
  "oxc-parser": "^0.149.0",
193
199
  "pkg-pr-new": "^0.0.88",
200
+ "playwright-core": "^1.63.0",
194
201
  "prettier": "^3.8.2",
195
202
  "prettier-2": "npm:prettier@^2",
196
203
  "pretty-format": "^30.0.5",
@@ -210,12 +217,12 @@
210
217
  "simple-git": "^3.28.0",
211
218
  "style-loader": "^4.0.0",
212
219
  "terser": "^5.46.2",
213
- "three": "^0.185.1",
220
+ "three": "^0.186.0",
214
221
  "tinybench": "^6.0.1",
215
222
  "toml": "^5.0.0",
216
- "tooling": "webpack/tooling#v1.28.3",
217
223
  "ts-loader": "^9.6.0",
218
224
  "typescript": "^6.0.3",
225
+ "typescript-eslint": "^8.70.0",
219
226
  "unified": "^11.0.5",
220
227
  "url-loader": "^4.1.0",
221
228
  "wast-loader": "^1.12.1",