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
@@ -641,16 +641,13 @@ const visitModules = (
641
641
  }
642
642
  } else {
643
643
  entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);
644
- // Fill in options the existing entrypoint hasn't set yet. We never
645
- // overwrite: blocks that dedupe to one entrypoint (e.g. several
646
- // workers pointing at the same module) legitimately carry distinct
647
- // values such as `runtime`, so the first block to create the
648
- // entrypoint wins and later ones only contribute missing keys.
649
- // `name` is excluded: it is the entrypoint's identity, fixed at
650
- // creation (and used to key namedChunkGroups), so back-filling it
651
- // from a block that deduped in via its module would leave
652
- // `entrypoint.name` out of sync and make module codegen
653
- // order-dependent, which breaks persistent caching.
644
+ // Fill in only the options still unset: blocks deduping to one
645
+ // entrypoint may carry different values, so the first to create it
646
+ // wins.
647
+
648
+ // `name` is excluded, being the entrypoint's identity and fixed at
649
+ // creation. Back-filling it would make codegen order-dependent, which
650
+ // breaks persistent caching.
654
651
  const existingOptions = entrypoint.options;
655
652
  for (const key_ of Object.keys(entryOptions)) {
656
653
  const key =
@@ -1370,11 +1367,10 @@ const connectChunkGroups = (
1370
1367
 
1371
1368
  // For each edge in the basic chunk graph
1372
1369
  for (const [block, connections] of blockConnections) {
1373
- // 1. Check if connection is needed
1374
- // When none of the dependencies need to be connected
1375
- // we can skip all of them
1376
- // It's not possible to filter each item so it doesn't create inconsistent
1377
- // connections and modules can only create one version
1370
+ // Skip the whole set when no dependency needs connecting. They cannot be
1371
+ // filtered one by one without inconsistent connections, since a module can
1372
+ // only carry one version.
1373
+
1378
1374
  // TODO maybe decide this per runtime
1379
1375
  if (
1380
1376
  // Blocks with nested blocks must stay connected — skipping orphans the
@@ -31,13 +31,13 @@ class MemoryCachePlugin {
31
31
  const cacheEntry = cache.get(identifier);
32
32
  // A recorded miss: the whole chain was asked for this identifier already.
33
33
  if (cacheEntry === null) return null;
34
- // Etags are compared by identity — a lazy one is interned per source
35
- // object, so equal content reached through a second object is a
34
+ // WHY: etags are compared by identity, and a lazy one is interned per
35
+ // source object, so equal content reached through a second object is a
36
36
  // different etag. Hashing to tell those apart would cost every hit what
37
37
  // laziness saves, so a mismatch falls through to the next stage instead:
38
38
  // the file cache compares etags by value and can still answer. Returning
39
- // `null` here would bail the hook and lose that (`Cache.get` maps it to
40
- // `undefined` regardless, so it buys the caller nothing).
39
+ // `null` here would bail the hook and lose that, and `Cache.get` maps it
40
+ // to `undefined` regardless, so it buys the caller nothing.
41
41
  if (cacheEntry !== undefined && cacheEntry.etag === etag) {
42
42
  return cacheEntry.data;
43
43
  }
@@ -79,10 +79,9 @@ class MemoryWithGcCachePlugin {
79
79
  continue;
80
80
  }
81
81
  if (entry !== undefined) {
82
- // We don't delete the cache entry, but set it to undefined instead
83
- // This reserves the location in the data table and avoids rehashing
84
- // when constantly adding and removing entries.
85
- // It will be deleted when removed from oldCache.
82
+ // Set to undefined rather than deleted, reserving the slot and sparing
83
+ // a rehash as entries come and go. It goes for good once `oldCache`
84
+ // drops it.
86
85
  cache.set(identifier, undefined);
87
86
  oldCache.delete(identifier);
88
87
  oldCache.set(identifier, {
@@ -105,13 +104,13 @@ class MemoryWithGcCachePlugin {
105
104
  const cacheEntry = cache.get(identifier);
106
105
  // A recorded miss: the whole chain was asked for this identifier already.
107
106
  if (cacheEntry === null) return null;
108
- // Etags are compared by identity — a lazy one is interned per source
109
- // object, so equal content reached through a second object is a
107
+ // WHY: etags are compared by identity, and a lazy one is interned per
108
+ // source object, so equal content reached through a second object is a
110
109
  // different etag. Hashing to tell those apart would cost every hit what
111
110
  // laziness saves, so a mismatch falls through to the next stage instead:
112
111
  // the file cache compares etags by value and can still answer. Returning
113
- // `null` here would bail the hook and lose that (`Cache.get` maps it to
114
- // `undefined` regardless, so it buys the caller nothing).
112
+ // `null` here would bail the hook and lose that, and `Cache.get` maps it
113
+ // to `undefined` regardless, so it buys the caller nothing.
115
114
  let known = cacheEntry !== undefined;
116
115
  if (cacheEntry !== undefined) {
117
116
  if (cacheEntry.etag === etag) return cacheEntry.data;
@@ -901,24 +901,9 @@ makeSerializable(
901
901
  /** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number } }>} LazyFunction */
902
902
 
903
903
  class PackContent {
904
- /*
905
- This class can be in these states:
906
- | this.lazy | this.content | this.outdated | state
907
- A1 | undefined | Map | false | fresh content
908
- A2 | undefined | Map | true | (will not happen)
909
- B1 | lazy () => {} | undefined | false | not deserialized
910
- B2 | lazy () => {} | undefined | true | not deserialized, but some items has been removed
911
- C1 | lazy* () => {} | Map | false | deserialized
912
- C2 | lazy* () => {} | Map | true | deserialized, and some items has been removed
913
-
914
- this.used is a subset of this.items.
915
- this.items is a subset of this.content.keys() resp. this.lazy().map.keys()
916
- When this.outdated === false, this.items === this.content.keys() resp. this.lazy().map.keys()
917
- When this.outdated === true, this.items should be used to recreated this.lazy/this.content.
918
- When this.lazy and this.content is set, they contain the same data.
919
- this.get must only be called with a valid item from this.items.
920
- In state C this.lazy is unMemoized
921
- */
904
+ // `used` is a subset of `items`, itself a subset of the content's keys, and the
905
+ // two coincide while `outdated` is false. `lazy` and `content` hold the same
906
+ // data whenever both are set, and `get` takes only an item of `items`.
922
907
 
923
908
  /**
924
909
  * Creates an instance of PackContent.
@@ -42,11 +42,9 @@ class LazyHashedEtag {
42
42
  /** @type {HashableObject} */
43
43
  (this._obj).updateHash(hash);
44
44
  this._hash = hash.digest("base64");
45
- // Drop the captured object once the hash is memoized. The hash is
46
- // never reset, so we never need `_obj` again — and many callers
47
- // (e.g. `SourceMapDevToolPlugin`, `RealContentHashPlugin`) capture
48
- // a heavy `CachedSource` here that would otherwise stay reachable
49
- // through this etag for the lifetime of the compilation cache.
45
+ // Drop the captured object once the hash is memoized: the hash never
46
+ // resets, and callers often capture a heavy `CachedSource` that would
47
+ // otherwise stay reachable for the compilation cache's lifetime.
50
48
  this._obj = undefined;
51
49
  }
52
50
  return this._hash;
@@ -422,10 +422,7 @@ const resolve = (browsers) => {
422
422
  ios_saf: [15, 4],
423
423
  samsung: 17,
424
424
  android: 93,
425
- // and_qq: Not supported
426
- // baidu: Not supported
427
- // and_uc: Not supported
428
- // kaios: Not supported
425
+ // and_qq, baidu, and_uc and kaios are not supported.
429
426
  node: [16, 9]
430
427
  }),
431
428
  topLevelAwait: rawChecker({
@@ -441,10 +438,7 @@ const resolve = (browsers) => {
441
438
  ios_saf: 15,
442
439
  samsung: 15,
443
440
  android: 89,
444
- // and_qq: Not supported
445
- // baidu: Not supported
446
- // and_uc: Not supported
447
- // kaios: Not supported
441
+ // and_qq, baidu, and_uc and kaios are not supported.
448
442
  node: [14, 8]
449
443
  }),
450
444
  spread: rawChecker({
@@ -492,10 +492,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
492
492
  library: options.output.library
493
493
  });
494
494
 
495
- // `output.resourceHints.urlHints` shorthand: fan the project-wide rules out
496
- // as the base `urlHints` of every URL-emitting parser (JS `new URL`, CSS
497
- // `url()`, HTML `<img src>`). They go first so parser-scoped
498
- // `parser.<type>.urlHints` rules — matched later, last-match-wins — override.
495
+ // `output.resourceHints.urlHints` fans the project-wide rules out as the base
496
+ // `urlHints` of every URL-emitting parser. They go first, so a parser-scoped
497
+ // rule matches later and wins.
499
498
  const outputUrlHints =
500
499
  options.output.resourceHints && options.output.resourceHints.urlHints;
501
500
  if (outputUrlHints && outputUrlHints.length > 0) {
@@ -660,14 +659,12 @@ const applyExperimentsDefaults = (
660
659
  experiments.futureDefaults ? true : "auto"
661
660
  );
662
661
 
663
- // Resolve the "auto" default: enable the built-in css/html module type unless
664
- // the user already registered a loader (or explicit type) for these files, so
665
- // enabling them by default does not break existing css-loader/html-loader setups.
666
- // The built-in `/\.css$/i` rule also covers `.module.css`, so a loader scoped to
667
- // CSS modules must disable the built-in type too — sample both extensions.
668
- // When enabled implicitly the value stays `"auto"` (truthy): Css/HtmlModulesPlugin
669
- // then step aside per-module for requests that loaders were applied to
670
- // (inline requests or loaders injected via hooks, e.g. html-webpack-plugin).
662
+ // Resolve `"auto"`: enable the built-in type unless a loader is already
663
+ // registered for these files, so the default breaks no existing setup. Both
664
+ // extensions are sampled, since `/\.css$/i` also covers `.module.css`.
665
+
666
+ // Enabled implicitly the value stays `"auto"`, and the plugins then step
667
+ // aside per module for requests loaders were applied to.
671
668
  // TODO webpack 6: css/html default to `true`, drop the `"auto"` marker.
672
669
  if (experiments.css === "auto") {
673
670
  experiments.css =
@@ -1227,18 +1224,13 @@ const applyModuleDefaults = (
1227
1224
  }
1228
1225
 
1229
1226
  if (html) {
1230
- // `module.generator.html.extract` is intentionally left undefined by
1231
- // default: HtmlGenerator treats undefined as "extract iff this HTML
1232
- // module is a compilation entry", which is the HTML-entry-point
1233
- // behaviour. Setting `extract: true` forces extraction for all HTML
1234
- // modules (including imported ones); `extract: false` disables it
1235
- // everywhere.
1227
+ // `extract` is deliberately left undefined, which HtmlGenerator reads as
1228
+ // "extract only a module that is a compilation entry". `true` forces it for
1229
+ // imported modules too, `false` disables it everywhere.
1236
1230
  F(module.generator, HTML_MODULE_TYPE, () => ({}));
1237
- // `module.parser.html.sources` defaults to `true` — HtmlParser uses
1238
- // the built-in source list to extract URL-like attributes (`<img
1239
- // src>`, `<link href>`, `<script src>`, …) as webpack dependencies.
1240
- // Users may pass `false` to disable extraction entirely or an array
1241
- // (with `"..."` to include the defaults) to customize it.
1231
+ // `sources` defaults to `true`, so HtmlParser extracts URL-like attributes
1232
+ // as dependencies from its built-in list. `false` disables extraction, and
1233
+ // an array customizes it, with `"..."` keeping the defaults.
1242
1234
  F(module.parser, HTML_MODULE_TYPE, () => ({}));
1243
1235
  D(
1244
1236
  /** @type {NonNullable<ParserOptionsByModuleTypeKnown[HTML_MODULE_TYPE]>} */
@@ -1372,11 +1364,9 @@ const applyModuleDefaults = (
1372
1364
  type: CSS_MODULE_TYPE,
1373
1365
  resolve
1374
1366
  });
1375
- // For CSS modules, i.e. `.class { composes: className from "./style.css" }`
1376
- // We inherit for such constructions, but skip files that are already
1377
- // detected as CSS modules by extension (`.module.<ext>`) — they get
1378
- // the same modules-mode behavior from the auto rule, and forcing a
1379
- // different type stamp here would create a duplicate module instance.
1367
+ // For `composes: className from "./style.css"`. A file already detected as
1368
+ // a CSS module by extension is skipped: it gets modules mode from the auto
1369
+ // rule anyway, and a second type stamp would duplicate the module.
1380
1370
  const moduleExtension = /\.module\.\w+$/i;
1381
1371
  rules.push({
1382
1372
  dependency: /css-import-local-module/,
@@ -1426,11 +1416,9 @@ const applyModuleDefaults = (
1426
1416
  type: HTML_MODULE_TYPE,
1427
1417
  resolve
1428
1418
  });
1429
- // `<iframe srcdoc>` content is fed back through the HTML pipeline as a
1430
- // `data:text/html` module. `extract: "inline"` exposes the processed
1431
- // HTML on the `html` codegen channel that `HtmlInlineHtmlDependency.
1432
- // Template` reads back into the attribute, without emitting a standalone
1433
- // `.html` file (the module is never a page on its own).
1419
+ // `<iframe srcdoc>` content goes back through the HTML pipeline as a
1420
+ // `data:text/html` module. `extract: "inline"` exposes it on the `html`
1421
+ // channel without emitting a file: it is never a page on its own.
1434
1422
  rules.push({
1435
1423
  dependency: "html-srcdoc",
1436
1424
  generator: {
@@ -1439,12 +1427,9 @@ const applyModuleDefaults = (
1439
1427
  resolve
1440
1428
  });
1441
1429
  if (css) {
1442
- // Inline `<style>` content in an HTML module is fed into the
1443
- // CSS pipeline as a `data:text/css` virtual module. We force
1444
- // `exportType: "text"` so the CSS module exposes the
1445
- // processed CSS text on the `css-text` codegen channel that
1446
- // `HtmlInlineStyleDependency.Template` reads back into the
1447
- // `<style>` tag.
1430
+ // Inline `<style>` content goes into the CSS pipeline as a
1431
+ // `data:text/css` module. `exportType: "text"` is forced, so the
1432
+ // processed text reaches the `css-text` channel the template reads.
1448
1433
  rules.push({
1449
1434
  dependency: "html-style",
1450
1435
  parser: {
@@ -1750,12 +1735,11 @@ const applyOutputDefaults = (
1750
1735
  "const",
1751
1736
  () => tp && optimistic(/** @type {boolean | undefined} */ (tp.const))
1752
1737
  );
1753
- // Only the browserslist target reports these; everywhere else they stay
1754
- // unset, which `optimistic` reads as the modern spelling being available —
1755
- // the same policy the JS features above follow.
1756
- // `let` was added after `const`; targets predating it report only `const`,
1757
- // so fall back to `const` when `let` is unreported (undefined). Targets that
1758
- // do report `let` (browserslist, built-ins) keep their own accurate value.
1738
+ // Only the browserslist target reports these; unset elsewhere, which
1739
+ // `optimistic` reads as the modern spelling being available.
1740
+
1741
+ // `let` was added after `const`, so a target predating it reports only
1742
+ // `const` and falls back to it. One reporting `let` keeps its own value.
1759
1743
  F(environment, "let", () =>
1760
1744
  conditionallyOptimistic(
1761
1745
  /** @type {boolean | undefined} */ (tp && tp.let),
@@ -1887,10 +1871,9 @@ const applyOutputDefaults = (
1887
1871
  tp && optimistic(/** @type {boolean | undefined} */ (tp.modulePreload))
1888
1872
  );
1889
1873
 
1890
- // Vite-style default for ESM output (`output.module`): preload the entry's
1891
- // initial dependency graph, which native `import()` would otherwise fetch in
1892
- // a waterfall. Classic output loads initial chunks via parallel `<script>`
1893
- // tags (no waterfall), so it stays opt-in.
1874
+ // For ESM output, preload the entry's initial dependency graph, which native
1875
+ // `import()` would otherwise fetch in a waterfall. Classic output loads its
1876
+ // initial chunks in parallel already, so it stays opt-in.
1894
1877
  if (output.module && output.resourceHints === undefined) {
1895
1878
  output.resourceHints = {};
1896
1879
  }
@@ -1944,13 +1927,9 @@ const applyOutputDefaults = (
1944
1927
  }
1945
1928
  return "[id].css";
1946
1929
  });
1947
- // Derive html filename defaults from `output.filename` / `output.chunkFilename`
1948
- // (the same shape the CSS pipeline uses), but if the derived template lacks
1949
- // any per-module differentiator, fall back to `[name].html` so multiple
1950
- // extracted HTML modules in one compilation don't collide on the same
1951
- // emitted file. For example: `output.filename: "bundle.js"` would derive
1952
- // `bundle.html` — two `.html` modules extracted in the same build would
1953
- // both want that name and conflict at emit time.
1930
+ // Derive the html filenames from `output.filename`, as the CSS pipeline does.
1931
+ // A derived template with no per-module placeholder falls back to
1932
+ // `[name].html`, or two extracted modules would want the same file.
1954
1933
  const HAS_PATH_PLACEHOLDER_REGEXP =
1955
1934
  /\[(name|id|chunkhash|contenthash|fullhash|hash)/;
1956
1935
  /**
@@ -1997,11 +1976,9 @@ const applyOutputDefaults = (
1997
1976
  if (tp) {
1998
1977
  if (tp.global) return "global";
1999
1978
  if (tp.globalThis) return "globalThis";
2000
- // Universal target (web + node): no one identifier is defined on both
2001
- // sides, so `globalThis` where the target reports nothing against it,
2002
- // and a guarded pair where it does — `self` covers window and worker
2003
- // scopes, `global` covers Node.js. Naming either alone leaves the other
2004
- // platform reading an undeclared binding.
1979
+ // A universal target has no identifier defined on both sides, so this is
1980
+ // `globalThis` where nothing argues against it and a guarded pair where
1981
+ // something does: naming one alone leaves the other undeclared.
2005
1982
  if (tp.web === null && tp.node === null) {
2006
1983
  return tp.globalThis === undefined
2007
1984
  ? "globalThis"
@@ -2531,19 +2508,17 @@ const applyOptimizationDefaults = (
2531
2508
  // Lazy load the minimizer plugin
2532
2509
  const TerserPlugin = require("minimizer-webpack-plugin");
2533
2510
 
2534
- // One minimizer instance (one worker-thread pool) handles JS and, when
2535
- // native CSS / HTML is enabled, those assets too — an array of minify
2536
- // functions each dispatched by its own `filter` (terser -> JS,
2537
- // cssMinify -> CSS, htmlMinify -> HTML). The CSS / HTML serializers stay
2538
- // worker-safe by resolving their parser with `require("webpack/…")` in
2539
- // the worker, so all three share the same pool. `test` is widened to let
2540
- // CSS / HTML assets reach the dispatcher.
2541
- // Step aside for a minimizer the user already configured for these
2542
- // types: whichever of the two ran first would mark the asset
2543
- // `minimized` and silently disable the other, so webpack only claims
2544
- // what nothing else does. Their asset matchers are read directly rather
2545
- // than resolved per asset — a coarse check, but it keeps the outcome
2546
- // independent of tap order and of the plugin version in use.
2511
+ // WHY: one minimizer instance, so one worker-thread pool, handles JS and
2512
+ // — where native CSS and HTML are enabled — those assets too, as an array
2513
+ // of minify functions each dispatched by its own `filter`: terser to JS,
2514
+ // `cssMinify` to CSS, `htmlMinify` to HTML. The CSS and HTML serializers
2515
+ // stay worker-safe by resolving their parser with `require("webpack/…")`
2516
+ // in the worker, so all three share the pool, and `test` is widened to let
2517
+ // those assets reach the dispatcher.
2518
+
2519
+ // Step aside for a minimizer the user configured for these types:
2520
+ // whichever ran first would mark the asset `minimized` and silently
2521
+ // disable the other. Matchers are read directly, coarse but stable.
2547
2522
  const claimedByOtherMinimizer = require("./getClaimedAssetTypes")(
2548
2523
  compiler
2549
2524
  );
@@ -2619,10 +2594,9 @@ const applyOptimizationDefaults = (
2619
2594
  }
2620
2595
  if (minifyHtml) {
2621
2596
  minify.push(require("../html/htmlMinify"));
2622
- // `minimize.css` rides along under its own key rather than spread
2623
- // beside the HTML options: the two name some of the same switches
2624
- // (`quotes`, `comments`), and one flat object would hand
2625
- // each language the other's answer.
2597
+ // `minimize.css` rides under its own key rather than spread beside the
2598
+ // HTML options: the two name some of the same switches, so one flat
2599
+ // object would hand each language the other's answer.
2626
2600
  minimizerOptions.push({
2627
2601
  environment: cssEnvironment,
2628
2602
  css: cssOptions,
@@ -17,19 +17,18 @@ const { matchObject } = require("../ModuleFilenameHelpers");
17
17
  * @returns {boolean} whether the candidate minimizes that file
18
18
  */
19
19
  const claims = (candidate, file) => {
20
- // Every minimizer in the `minimizer-webpack-plugin` family (itself,
21
- // `css-minimizer-webpack-plugin`, `html-minimizer-webpack-plugin`, …) keeps
22
- // the minify implementation on `options.minimizer` and its asset matcher
23
- // alongside it in the shape `matchObject` reads. The matcher alone is not
24
- // enough to recognize one: `BannerPlugin` and `SourceMapDevToolPlugin` carry
25
- // the same three keys, and `LoaderOptionsPlugin` defaults `test` to match
26
- // every file — reading those as minimizers would disable minification.
20
+ // WHY: every minimizer in the `minimizer-webpack-plugin` family — itself,
21
+ // `css-minimizer-webpack-plugin`, `html-minimizer-webpack-plugin`, … — keeps
22
+ // its implementation on `options.minimizer` and its asset matcher alongside
23
+ // it, in the shape `matchObject` reads. The matcher alone is not enough to
24
+ // recognize one: `BannerPlugin` and `SourceMapDevToolPlugin` carry the same
25
+ // three keys, and `LoaderOptionsPlugin` defaults `test` to match every file,
26
+ // so reading those as minimizers would disable minification.
27
27
  const { options } = /** @type {{ options?: MinimizerOptions }} */ (candidate);
28
28
  if (!options || !options.minimizer) return false;
29
- // `test`/`include` say which types it handles, `exclude` only narrows the
30
- // files within them — honouring that narrowing would make a minimizer scoped
31
- // to a subdirectory claim nothing, and webpack would then race it on the very
32
- // files it was configured for.
29
+ // `test` and `include` say which types it handles, while `exclude` only
30
+ // narrows the files within them: honoring that narrowing would let a minimizer
31
+ // scoped to a subdirectory claim nothing, and webpack would then race it.
33
32
  const { test, include } = options;
34
33
  return (
35
34
  (test !== undefined && matchObject({ test }, file)) ||
@@ -345,10 +345,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
345
345
  "Bun in version X.Y. Output is always ECMAScript modules. Examples: bun, bun1.1.",
346
346
  /^bun((\d+)(?:\.(\d+))?)?$/,
347
347
  () => ({
348
- // Bun is a modern, Node.js-compatible runtime; every released version
349
- // supports the full modern ECMAScript feature set, so the version is
350
- // accepted but does not gate any feature. Output is always ESM, so sync
351
- // CommonJS `require` is never available.
348
+ // Every released Bun supports the full modern feature set, so a version is
349
+ // accepted but gates nothing. Output is always ESM, leaving no synchronous
350
+ // CommonJS `require`.
352
351
  node: true,
353
352
  bun: true,
354
353
  web: false,
@@ -4,7 +4,7 @@
4
4
 
5
5
  "use strict";
6
6
 
7
- /** @import Compiler from "./Compiler" */
7
+ /** @import Compiler from "../Compiler" */
8
8
 
9
9
  const PLUGIN_NAME = "ContextExclusionPlugin";
10
10
 
@@ -6,49 +6,52 @@
6
6
  "use strict";
7
7
 
8
8
  const { OriginalSource, RawSource } = require("webpack-sources");
9
- const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
10
- const Module = require("./Module");
9
+ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
+ const Module = require("../Module");
11
11
  const {
12
12
  JAVASCRIPT_TYPE,
13
13
  JAVASCRIPT_TYPES
14
- } = require("./ModuleSourceTypeConstants");
15
- const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
16
- const RuntimeGlobals = require("./RuntimeGlobals");
17
- const Template = require("./Template");
14
+ } = require("../ModuleSourceTypeConstants");
15
+ const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");
16
+ const RuntimeGlobals = require("../RuntimeGlobals");
17
+ const Template = require("../Template");
18
18
  const {
19
19
  getOutgoingAsyncModules
20
- } = require("./async-modules/AsyncModuleHelpers");
21
- const { ImportPhase, ImportPhaseUtils } = require("./dependencies/ImportPhase");
22
- const { makeWebpackError } = require("./errors/HookWebpackError");
23
- const WebpackError = require("./errors/WebpackError");
20
+ } = require("../async-modules/AsyncModuleHelpers");
21
+ const {
22
+ ImportPhase,
23
+ ImportPhaseUtils
24
+ } = require("../dependencies/ImportPhase");
25
+ const { makeWebpackError } = require("../errors/HookWebpackError");
26
+ const WebpackError = require("../errors/WebpackError");
24
27
  const {
25
28
  compareLocations,
26
29
  compareModulesById,
27
30
  compareSelect,
28
31
  concatComparators,
29
32
  keepOriginalOrder
30
- } = require("./util/comparators");
33
+ } = require("../util/comparators");
31
34
  const {
32
35
  contextify,
33
36
  makePathsRelative,
34
37
  parseResource
35
- } = require("./util/identifier");
36
- const makeSerializable = require("./util/makeSerializable");
37
- const { propertyAccess } = require("./util/property");
38
+ } = require("../util/identifier");
39
+ const makeSerializable = require("../util/makeSerializable");
40
+ const { propertyAccess } = require("../util/property");
38
41
 
39
42
  /** @import { Source } from "webpack-sources" */
40
- /** @import { ResolveOptions } from "../declarations/WebpackOptions" */
43
+ /** @import { ResolveOptions } from "../../declarations/WebpackOptions" */
41
44
  /**
42
45
  * @import {
43
46
  * WebpackOptionsNormalizedWithDefaults as WebpackOptions
44
- * } from "./config/defaults"
47
+ * } from "../config/defaults"
45
48
  */
46
- /** @import Chunk, { ChunkId, ChunkName } from "./Chunk" */
47
- /** @import ChunkGraph, { ModuleId } from "./ChunkGraph" */
48
- /** @import { RawChunkGroupOptions } from "./ChunkGroup" */
49
- /** @import Compilation, { FileSystemDependencies } from "./Compilation" */
50
- /** @import Dependency, { RawReferencedExports } from "./Dependency" */
51
- /** @import { Snapshot } from "./FileSystemInfo" */
49
+ /** @import Chunk, { ChunkId, ChunkName } from "../Chunk" */
50
+ /** @import ChunkGraph, { ModuleId } from "../ChunkGraph" */
51
+ /** @import { RawChunkGroupOptions } from "../ChunkGroup" */
52
+ /** @import Compilation, { FileSystemDependencies } from "../Compilation" */
53
+ /** @import Dependency, { RawReferencedExports } from "../Dependency" */
54
+ /** @import { Snapshot } from "../FileSystemInfo" */
52
55
  /**
53
56
  * @import {
54
57
  * BuildCallback,
@@ -63,17 +66,17 @@ const { propertyAccess } = require("./util/property");
63
66
  * RuntimeRequirements,
64
67
  * Sources,
65
68
  * SourceTypes
66
- * } from "./Module"
69
+ * } from "../Module"
67
70
  */
68
- /** @import RequestShortener from "./RequestShortener" */
69
- /** @import { ResolverWithOptions } from "./ResolverFactory" */
70
- /** @import RuntimeTemplate from "./RuntimeTemplate" */
71
- /** @import ContextElementDependency from "./dependencies/ContextElementDependency" */
72
- /** @import { ImportAttributes } from "./javascript/JavascriptParser" */
73
- /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext<[string, boolean]>} ObjectDeserializerContext */
74
- /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext<[string, boolean]>} ObjectSerializerContext */
75
- /** @import { InputFileSystem } from "./util/fs" */
76
- /** @import { ImportPhaseType } from "./dependencies/ImportPhase" */
71
+ /** @import RequestShortener from "../RequestShortener" */
72
+ /** @import { ResolverWithOptions } from "../ResolverFactory" */
73
+ /** @import RuntimeTemplate from "../RuntimeTemplate" */
74
+ /** @import ContextElementDependency from "../dependencies/ContextElementDependency" */
75
+ /** @import { ImportAttributes } from "../javascript/JavascriptParser" */
76
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, boolean]>} ObjectDeserializerContext */
77
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, boolean]>} ObjectSerializerContext */
78
+ /** @import { InputFileSystem } from "../util/fs" */
79
+ /** @import { ImportPhaseType } from "../dependencies/ImportPhase" */
77
80
 
78
81
  /** @typedef {"sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"} ContextMode Context mode */
79
82
 
@@ -1473,7 +1476,7 @@ module.exports = webpackEmptyAsyncContext;`;
1473
1476
  const returnModuleObject = this.getReturnModuleObjectSource(fakeMap);
1474
1477
  const globImportAccess = this.getImportPropertyAccess();
1475
1478
  const sortedDependencies =
1476
- /** @type {import("./dependencies/ContextElementDependency")[]} */
1479
+ /** @type {import("../dependencies/ContextElementDependency")[]} */
1477
1480
  (dependencies).sort((a, b) =>
1478
1481
  a.userRequest < b.userRequest
1479
1482
  ? -1
@@ -1724,6 +1727,6 @@ module.exports = webpackEmptyAsyncContext;`;
1724
1727
  }
1725
1728
  }
1726
1729
 
1727
- makeSerializable(ContextModule, "webpack/lib/ContextModule");
1730
+ makeSerializable(ContextModule, "webpack/lib/context/ContextModule");
1728
1731
 
1729
1732
  module.exports = ContextModule;