@depup/webpack 5.110.3-depup.0 → 5.111.1-depup.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.
Files changed (283) hide show
  1. package/README.md +7 -8
  2. package/changes.json +7 -11
  3. package/lib/APIPlugin.js +26 -11
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/Cache.js +8 -3
  6. package/lib/CacheFacade.js +1 -1
  7. package/lib/CircularModulesPlugin.js +157 -55
  8. package/lib/CleanPlugin.js +2 -2
  9. package/lib/CompatibilityPlugin.js +3 -4
  10. package/lib/Compilation.js +336 -337
  11. package/lib/Compiler.js +213 -51
  12. package/lib/ConstPlugin.js +16 -132
  13. package/lib/CopyPlugin.js +1054 -0
  14. package/lib/DefinePlugin.js +24 -8
  15. package/lib/DependencyTemplate.js +2 -1
  16. package/lib/DotenvPlugin.js +24 -28
  17. package/lib/ErrorHelpers.js +113 -0
  18. package/lib/ExportsInfo.js +20 -16
  19. package/lib/ExternalModule.js +47 -22
  20. package/lib/FileSystemInfo.js +17 -14
  21. package/lib/FlagDependencyExportsPlugin.js +53 -34
  22. package/lib/FlagDependencyUsagePlugin.js +9 -13
  23. package/lib/Generator.js +24 -2
  24. package/lib/HotModuleReplacementPlugin.js +55 -7
  25. package/lib/IgnorePlugin.js +1 -1
  26. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  27. package/lib/LoaderOptionsPlugin.js +1 -1
  28. package/lib/MainTemplate.js +5 -1
  29. package/lib/Module.js +19 -10
  30. package/lib/ModuleGraph.js +6 -9
  31. package/lib/MultiCompiler.js +7 -17
  32. package/lib/MultiWatching.js +1 -1
  33. package/lib/NormalModule.js +135 -50
  34. package/lib/NormalModuleFactory.js +1 -1
  35. package/lib/RuntimeGlobals.js +21 -7
  36. package/lib/RuntimeModule.js +28 -12
  37. package/lib/RuntimePlugin.js +30 -3
  38. package/lib/RuntimeTemplate.js +813 -518
  39. package/lib/SourceMapDevToolPlugin.js +54 -104
  40. package/lib/TemplatedPathPlugin.js +16 -59
  41. package/lib/Watching.js +9 -0
  42. package/lib/WebpackOptionsApply.js +84 -91
  43. package/lib/asset/AssetBytesGenerator.js +7 -1
  44. package/lib/asset/AssetGenerator.js +50 -24
  45. package/lib/asset/AssetModule.js +3 -0
  46. package/lib/asset/AssetSourceGenerator.js +7 -1
  47. package/lib/asset/WebManifestParser.js +7 -5
  48. package/lib/buildChunkGraph.js +11 -15
  49. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  50. package/lib/cache/IdleFileCachePlugin.js +2 -2
  51. package/lib/cache/MemoryCachePlugin.js +4 -4
  52. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  53. package/lib/cache/PackFileCacheStrategy.js +17 -19
  54. package/lib/cache/getLazyHashedEtag.js +3 -5
  55. package/lib/config/browserslistTargetHandler.js +17 -4
  56. package/lib/config/defaults.js +138 -128
  57. package/lib/config/getClaimedAssetTypes.js +10 -11
  58. package/lib/config/normalization.js +82 -12
  59. package/lib/config/target.js +13 -4
  60. package/lib/container/ContainerReferencePlugin.js +6 -0
  61. package/lib/container/RemoteRuntimeModule.js +9 -0
  62. package/lib/container/declaredRemotes.js +39 -0
  63. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  64. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  65. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  66. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  67. package/lib/css/CssGenerator.js +27 -11
  68. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  69. package/lib/css/CssLoadingRuntimeModule.js +94 -36
  70. package/lib/css/CssModule.js +1 -1
  71. package/lib/css/CssModulesPlugin.js +7 -6
  72. package/lib/css/CssParser.js +162 -31
  73. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  74. package/lib/css/cssMinify.js +43 -32
  75. package/lib/css/data.js +3514 -869
  76. package/lib/css/syntax.js +6370 -1220
  77. package/lib/debug/ProfilingPlugin.js +7 -4
  78. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  79. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  80. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  81. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  82. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  83. package/lib/dependencies/CommonJsPlugin.js +19 -3
  84. package/lib/dependencies/CommonJsRequireDependency.js +14 -5
  85. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  86. package/lib/dependencies/ContextDependency.js +1 -1
  87. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  88. package/lib/dependencies/ContextElementDependency.js +1 -1
  89. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  90. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  91. package/lib/dependencies/CssUrlDependency.js +3 -5
  92. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  93. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  94. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
  95. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  96. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
  97. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  98. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  99. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  100. package/lib/dependencies/HarmonyImportDependency.js +6 -1
  101. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
  102. package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
  103. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  104. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  105. package/lib/dependencies/HtmlEntryDependency.js +124 -102
  106. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  107. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  108. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  109. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  110. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  111. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  112. package/lib/dependencies/ImportParserPlugin.js +1 -1
  113. package/lib/dependencies/LoaderPlugin.js +26 -1
  114. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  115. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  116. package/lib/dependencies/URLContextDependency.js +1 -1
  117. package/lib/dependencies/URLDependency.js +6 -5
  118. package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
  119. package/lib/dependencies/WorkerDependency.js +7 -7
  120. package/lib/dependencies/WorkletDependency.js +7 -11
  121. package/lib/dll/DelegatedModule.js +18 -1
  122. package/lib/dll/DllReferencePlugin.js +11 -8
  123. package/lib/dll/LibManifestPlugin.js +1 -1
  124. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  125. package/lib/errors/DuplicateModulesWarning.js +12 -7
  126. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  127. package/lib/errors/ExternalStarReexportError.js +44 -0
  128. package/lib/errors/HookWebpackError.js +3 -2
  129. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  130. package/lib/errors/ModuleParseError.js +2 -1
  131. package/lib/errors/UnusedAssetsWarning.js +36 -0
  132. package/lib/errors/UnusedFederationWarning.js +35 -0
  133. package/lib/errors/UnusedModulesWarning.js +38 -0
  134. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  135. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  136. package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
  137. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
  138. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  139. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  140. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  141. package/lib/html/HtmlGenerator.js +72 -87
  142. package/lib/html/HtmlModulesPlugin.js +418 -200
  143. package/lib/html/HtmlParser.js +110 -147
  144. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  145. package/lib/html/data.js +142 -7
  146. package/lib/html/htmlMinify.js +92 -122
  147. package/lib/html/syntax.js +1618 -1391
  148. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  149. package/lib/index.js +49 -3
  150. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  151. package/lib/javascript/JavascriptGenerator.js +8 -1
  152. package/lib/javascript/JavascriptModule.js +1 -0
  153. package/lib/javascript/JavascriptModulesPlugin.js +73 -72
  154. package/lib/javascript/JavascriptParser.js +1970 -900
  155. package/lib/javascript/StartupHelpers.js +27 -3
  156. package/lib/javascript/data.js +172 -0
  157. package/lib/javascript/grammar.js +5546 -0
  158. package/lib/javascript/parser.js +1500 -0
  159. package/lib/javascript/regexp.js +1762 -0
  160. package/lib/javascript/regexpData.js +51 -0
  161. package/lib/javascript/syntax.js +9061 -5262
  162. package/lib/json/JsonGenerator.js +7 -1
  163. package/lib/library/ModuleLibraryPlugin.js +171 -132
  164. package/lib/loaders/LoaderRunner.js +137 -9
  165. package/lib/node/NodeWatchFileSystem.js +3 -9
  166. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  167. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  168. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  169. package/lib/optimize/ConcatenatedModule.js +178 -120
  170. package/lib/optimize/ConstExportsPlugin.js +50 -39
  171. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  172. package/lib/optimize/InlineExports.js +20 -123
  173. package/lib/optimize/InnerGraphPlugin.js +7 -13
  174. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  175. package/lib/optimize/MangleExportsPlugin.js +13 -4
  176. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  177. package/lib/optimize/RealContentHashPlugin.js +68 -9
  178. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  179. package/lib/optimize/SplitChunksPlugin.js +2 -4
  180. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  181. package/lib/performance/BroadContextsPlugin.js +1 -1
  182. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  183. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  184. package/lib/performance/EvalUsagePlugin.js +5 -2
  185. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  186. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  187. package/lib/performance/SizeLimitsPlugin.js +2 -4
  188. package/lib/performance/TopLevelThisPlugin.js +5 -4
  189. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  190. package/lib/performance/UnusedFederationPlugin.js +147 -0
  191. package/lib/performance/UnusedModulesPlugin.js +141 -0
  192. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  193. package/lib/performance/isOnlyReexported.js +65 -0
  194. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  195. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  196. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  197. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  198. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  199. package/lib/prefetch/ResourceHintPlugin.js +18 -23
  200. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  201. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  202. package/lib/rules/RuleSetCompiler.js +211 -4
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
  204. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  205. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  206. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  207. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  208. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  209. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  210. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  211. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  212. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  213. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  214. package/lib/runtime/HelperRuntimeModule.js +10 -0
  215. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
  216. package/lib/runtime/NonceRuntimeModule.js +9 -0
  217. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  218. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  219. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  220. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  221. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  222. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  223. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  224. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  225. package/lib/schemes/DataUriPlugin.js +3 -6
  226. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  227. package/lib/serialization/BinaryMiddleware.js +9 -9
  228. package/lib/serialization/FileMiddleware.js +16 -16
  229. package/lib/serialization/ObjectMiddleware.js +168 -139
  230. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  231. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  232. package/lib/sharing/ShareRuntimeModule.js +9 -0
  233. package/lib/sharing/declaredShared.js +47 -0
  234. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  235. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  236. package/lib/typescript/TypeScriptPlugin.js +2 -3
  237. package/lib/url/URLParserPlugin.js +6 -8
  238. package/lib/util/LocConverter.js +4 -7
  239. package/lib/util/SourceProcessor.js +91 -91
  240. package/lib/util/async.js +292 -0
  241. package/lib/util/buildDiagnostics.js +69 -0
  242. package/lib/util/chainedImports.js +3 -4
  243. package/lib/util/concatenate.js +4 -4
  244. package/lib/util/createHooksRegistry.js +1 -2
  245. package/lib/util/dataURL.js +2 -3
  246. package/lib/util/deterministicGrouping.js +8 -13
  247. package/lib/util/findGraphRoots.js +6 -13
  248. package/lib/util/fs.js +27 -1
  249. package/lib/util/globUtils.js +1 -1
  250. package/lib/util/handlerKeys.js +40 -0
  251. package/lib/util/hash/wasm-hash.js +3 -4
  252. package/lib/util/identifier.js +20 -0
  253. package/lib/util/internalSerializables.js +5 -1
  254. package/lib/util/registerExternalSerializer.js +6 -45
  255. package/lib/util/semver.js +5 -3
  256. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
  257. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  258. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  259. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  260. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  261. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  262. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  263. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  264. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  265. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  266. package/package.json +55 -46
  267. package/schemas/WebpackOptions.check.js +1 -1
  268. package/schemas/WebpackOptions.json +379 -66
  269. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  270. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  271. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  272. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  273. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  274. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  275. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  276. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  277. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  278. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  279. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  280. package/types.d.ts +1723 -604
  281. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  282. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  283. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -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.
@@ -1263,6 +1248,8 @@ class PackFileCacheStrategy {
1263
1248
  this.buildDependencies = new Set();
1264
1249
  /** @type {FileSystemDependencies} */
1265
1250
  this.newBuildDependencies = new LazySet();
1251
+ /** @type {FileSystemDependencies} */
1252
+ this.newOptionalBuildDependencies = new LazySet();
1266
1253
  /** @type {InstanceType<Snapshot> | undefined} */
1267
1254
  this.resolveBuildDependenciesSnapshot = undefined;
1268
1255
  /** @type {ResolveResults | undefined} */
@@ -1492,10 +1479,13 @@ class PackFileCacheStrategy {
1492
1479
  /**
1493
1480
  * Stores build dependencies.
1494
1481
  * @param {FileSystemDependencies | Iterable<string>} dependencies dependencies to store
1482
+ * @param {FileSystemDependencies | Iterable<string>} optionalDependencies optional dependencies to store
1483
+ * @returns {void}
1495
1484
  */
1496
- storeBuildDependencies(dependencies) {
1485
+ storeBuildDependencies(dependencies, optionalDependencies) {
1497
1486
  if (this.readonly) return;
1498
1487
  this.newBuildDependencies.addAll(dependencies);
1488
+ this.newOptionalBuildDependencies.addAll(optionalDependencies);
1499
1489
  }
1500
1490
 
1501
1491
  afterAllStored() {
@@ -1512,9 +1502,14 @@ class PackFileCacheStrategy {
1512
1502
  let promise;
1513
1503
  /** @type {Set<string>} */
1514
1504
  const newBuildDependencies = new Set();
1505
+ /** @type {Set<string>} */
1506
+ const optionalBuildDependencies = new Set();
1515
1507
  for (const dep of this.newBuildDependencies) {
1516
1508
  if (!this.buildDependencies.has(dep)) {
1517
1509
  newBuildDependencies.add(dep);
1510
+ if (this.newOptionalBuildDependencies.has(dep)) {
1511
+ optionalBuildDependencies.add(dep);
1512
+ }
1518
1513
  }
1519
1514
  }
1520
1515
  if (newBuildDependencies.size > 0 || !this.buildSnapshot) {
@@ -1533,6 +1528,7 @@ class PackFileCacheStrategy {
1533
1528
  this.fileSystemInfo.resolveBuildDependencies(
1534
1529
  this.context,
1535
1530
  newBuildDependencies,
1531
+ optionalBuildDependencies,
1536
1532
  (err, result) => {
1537
1533
  this.logger.timeEnd("resolve build dependencies");
1538
1534
  if (err) return reject(err);
@@ -1667,6 +1663,7 @@ class PackFileCacheStrategy {
1667
1663
  this.buildDependencies.add(dep);
1668
1664
  }
1669
1665
  this.newBuildDependencies.clear();
1666
+ this.newOptionalBuildDependencies.clear();
1670
1667
  this.logger.timeEnd("store pack");
1671
1668
  const stats = pack.getContentStats();
1672
1669
  this.logger.log(
@@ -1887,6 +1884,7 @@ class PackFileCacheStrategy {
1887
1884
  this.fileSystemInfo.clear();
1888
1885
  this.buildDependencies.clear();
1889
1886
  this.newBuildDependencies.clear();
1887
+ this.newOptionalBuildDependencies.clear();
1890
1888
  this.resolveBuildDependenciesSnapshot = undefined;
1891
1889
  this.resolveResults = undefined;
1892
1890
  this.buildSnapshot = undefined;
@@ -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,12 +422,25 @@ 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
  }),
428
+ topLevelAwait: rawChecker({
429
+ chrome: 89,
430
+ and_chr: 89,
431
+ edge: 89,
432
+ firefox: 89,
433
+ and_ff: 89,
434
+ // ie: Not supported,
435
+ opera: 75,
436
+ op_mob: 63,
437
+ safari: 15,
438
+ ios_saf: 15,
439
+ samsung: 15,
440
+ android: 89,
441
+ // and_qq, baidu, and_uc and kaios are not supported.
442
+ node: [14, 8]
443
+ }),
431
444
  spread: rawChecker({
432
445
  chrome: 60,
433
446
  and_chr: 60,
@@ -303,6 +303,15 @@ const A = (obj, prop, factory) => {
303
303
  }
304
304
  };
305
305
 
306
+ /**
307
+ * Whether the library type emits an ECMAScript module, which only `output.module`
308
+ * output can carry — every other type is written into a script.
309
+ * @param {LibraryType | undefined} type library type
310
+ * @returns {boolean} true, when the type is only emitted as an ECMAScript module
311
+ */
312
+ const isModuleLibraryType = (type) =>
313
+ type === "module" || type === "modern-module";
314
+
306
315
  /**
307
316
  * Apply webpack options base defaults.
308
317
  * @param {WebpackOptionsNormalized} options options to be modified
@@ -364,7 +373,6 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
364
373
  applyExperimentsDefaults(options.experiments, {
365
374
  production,
366
375
  development,
367
- targetProperties,
368
376
  rules: options.module.rules
369
377
  });
370
378
 
@@ -408,9 +416,6 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
408
416
  (typeof target === "string" && target.startsWith("browserslist")) ||
409
417
  (Array.isArray(target) &&
410
418
  target.some((target) => target.startsWith("browserslist"))),
411
- outputModule:
412
- /** @type {NonNullable<ExperimentsNormalized["outputModule"]>} */
413
- (options.experiments.outputModule),
414
419
  development,
415
420
  entry: options.entry,
416
421
  futureDefaults,
@@ -423,9 +428,7 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
423
428
  // is read by another bundler, where an eval wrapper hides `import.meta` from it.
424
429
  const noDevSourceMap = /** @type {LibraryType[]} */ (
425
430
  options.output.enabledLibraryTypes
426
- ).some(
427
- (type) => futureDefaults || type === "module" || type === "modern-module"
428
- );
431
+ ).some((type) => futureDefaults || isModuleLibraryType(type));
429
432
 
430
433
  F(
431
434
  options,
@@ -489,10 +492,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
489
492
  library: options.output.library
490
493
  });
491
494
 
492
- // `output.resourceHints.urlHints` shorthand: fan the project-wide rules out
493
- // as the base `urlHints` of every URL-emitting parser (JS `new URL`, CSS
494
- // `url()`, HTML `<img src>`). They go first so parser-scoped
495
- // `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.
496
498
  const outputUrlHints =
497
499
  options.output.resourceHints && options.output.resourceHints.urlHints;
498
500
  if (outputUrlHints && outputUrlHints.length > 0) {
@@ -630,13 +632,12 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
630
632
  * @param {object} options options
631
633
  * @param {boolean} options.production is production
632
634
  * @param {boolean} options.development is development mode
633
- * @param {TargetProperties | false} options.targetProperties target properties
634
635
  * @param {RuleSetRules} options.rules user `module.rules`, used to resolve the css/html/asyncWebAssembly/typescript "auto" defaults
635
636
  * @returns {void}
636
637
  */
637
638
  const applyExperimentsDefaults = (
638
639
  experiments,
639
- { production, development, targetProperties, rules }
640
+ { production, development, rules }
640
641
  ) => {
641
642
  D(experiments, "futureDefaults", false);
642
643
  D(experiments, "backCompat", !experiments.futureDefaults);
@@ -647,23 +648,6 @@ const applyExperimentsDefaults = (
647
648
  "asyncWebAssembly",
648
649
  experiments.futureDefaults ? true : "auto"
649
650
  );
650
- // the universal target (web + node, neither specific) only works as ESM —
651
- // unless the target cannot read one, which no output format can repair, so
652
- // leave `output.chunkFormat` to say so rather than emitting a module the
653
- // target has already reported it will not load
654
- const universal =
655
- Boolean(targetProperties) &&
656
- /** @type {TargetProperties} */ (targetProperties).node === null &&
657
- /** @type {TargetProperties} */ (targetProperties).web === null &&
658
- /** @type {TargetProperties} */ (targetProperties).module !== false;
659
- // the deno and bun targets only emit ECMAScript modules
660
- const deno =
661
- Boolean(targetProperties) &&
662
- /** @type {TargetProperties} */ (targetProperties).deno === true;
663
- const bun =
664
- Boolean(targetProperties) &&
665
- /** @type {TargetProperties} */ (targetProperties).bun === true;
666
- D(experiments, "outputModule", universal || deno || bun);
667
651
  D(experiments, "lazyCompilation", undefined);
668
652
  D(experiments, "buildHttp", undefined);
669
653
  D(experiments, "cacheUnaffected", experiments.futureDefaults);
@@ -675,14 +659,12 @@ const applyExperimentsDefaults = (
675
659
  experiments.futureDefaults ? true : "auto"
676
660
  );
677
661
 
678
- // Resolve the "auto" default: enable the built-in css/html module type unless
679
- // the user already registered a loader (or explicit type) for these files, so
680
- // enabling them by default does not break existing css-loader/html-loader setups.
681
- // The built-in `/\.css$/i` rule also covers `.module.css`, so a loader scoped to
682
- // CSS modules must disable the built-in type too — sample both extensions.
683
- // When enabled implicitly the value stays `"auto"` (truthy): Css/HtmlModulesPlugin
684
- // then step aside per-module for requests that loaders were applied to
685
- // (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.
686
668
  // TODO webpack 6: css/html default to `true`, drop the `"auto"` marker.
687
669
  if (experiments.css === "auto") {
688
670
  experiments.css =
@@ -919,6 +901,7 @@ const applyJavascriptParserOptionsDefaults = (
919
901
  D(parserOptions, "wrappedContextRecursive", true);
920
902
  D(parserOptions, "wrappedContextCritical", false);
921
903
  D(parserOptions, "strictThisContextOnImports", false);
904
+ D(parserOptions, "specNamespaceObject", false);
922
905
  D(parserOptions, "importMeta", outputModule ? "preserve-unknown" : true);
923
906
  D(parserOptions, "dynamicImportMode", "lazy");
924
907
  D(parserOptions, "dynamicImportPrefetch", false);
@@ -1241,18 +1224,13 @@ const applyModuleDefaults = (
1241
1224
  }
1242
1225
 
1243
1226
  if (html) {
1244
- // `module.generator.html.extract` is intentionally left undefined by
1245
- // default: HtmlGenerator treats undefined as "extract iff this HTML
1246
- // module is a compilation entry", which is the HTML-entry-point
1247
- // behaviour. Setting `extract: true` forces extraction for all HTML
1248
- // modules (including imported ones); `extract: false` disables it
1249
- // 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.
1250
1230
  F(module.generator, HTML_MODULE_TYPE, () => ({}));
1251
- // `module.parser.html.sources` defaults to `true` — HtmlParser uses
1252
- // the built-in source list to extract URL-like attributes (`<img
1253
- // src>`, `<link href>`, `<script src>`, …) as webpack dependencies.
1254
- // Users may pass `false` to disable extraction entirely or an array
1255
- // (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.
1256
1234
  F(module.parser, HTML_MODULE_TYPE, () => ({}));
1257
1235
  D(
1258
1236
  /** @type {NonNullable<ParserOptionsByModuleTypeKnown[HTML_MODULE_TYPE]>} */
@@ -1386,11 +1364,9 @@ const applyModuleDefaults = (
1386
1364
  type: CSS_MODULE_TYPE,
1387
1365
  resolve
1388
1366
  });
1389
- // For CSS modules, i.e. `.class { composes: className from "./style.css" }`
1390
- // We inherit for such constructions, but skip files that are already
1391
- // detected as CSS modules by extension (`.module.<ext>`) — they get
1392
- // the same modules-mode behavior from the auto rule, and forcing a
1393
- // 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.
1394
1370
  const moduleExtension = /\.module\.\w+$/i;
1395
1371
  rules.push({
1396
1372
  dependency: /css-import-local-module/,
@@ -1433,16 +1409,16 @@ const applyModuleDefaults = (
1433
1409
  type: HTML_MODULE_TYPE,
1434
1410
  resolve
1435
1411
  });
1412
+ // Exactly `text/html` — a string condition matches by prefix, which
1413
+ // would make a `data:text/htmlx,` module (JavaScript) a page.
1436
1414
  rules.push({
1437
- mimetype: "text/html",
1415
+ mimetype: /^text\/html$/i,
1438
1416
  type: HTML_MODULE_TYPE,
1439
1417
  resolve
1440
1418
  });
1441
- // `<iframe srcdoc>` content is fed back through the HTML pipeline as a
1442
- // `data:text/html` module. `extract: "inline"` exposes the processed
1443
- // HTML on the `html` codegen channel that `HtmlInlineHtmlDependency.
1444
- // Template` reads back into the attribute, without emitting a standalone
1445
- // `.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.
1446
1422
  rules.push({
1447
1423
  dependency: "html-srcdoc",
1448
1424
  generator: {
@@ -1451,12 +1427,9 @@ const applyModuleDefaults = (
1451
1427
  resolve
1452
1428
  });
1453
1429
  if (css) {
1454
- // Inline `<style>` content in an HTML module is fed into the
1455
- // CSS pipeline as a `data:text/css` virtual module. We force
1456
- // `exportType: "text"` so the CSS module exposes the
1457
- // processed CSS text on the `css-text` codegen channel that
1458
- // `HtmlInlineStyleDependency.Template` reads back into the
1459
- // `<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.
1460
1433
  rules.push({
1461
1434
  dependency: "html-style",
1462
1435
  parser: {
@@ -1593,7 +1566,6 @@ const applyModuleDefaults = (
1593
1566
  * @param {string} options.context context
1594
1567
  * @param {TargetProperties | false} options.targetProperties target properties
1595
1568
  * @param {boolean} options.isAffectedByBrowserslist is affected by browserslist
1596
- * @param {boolean} options.outputModule is outputModule experiment enabled
1597
1569
  * @param {boolean} options.development is development mode
1598
1570
  * @param {Entry} options.entry entry option
1599
1571
  * @param {boolean} options.futureDefaults is future defaults enabled
@@ -1606,7 +1578,6 @@ const applyOutputDefaults = (
1606
1578
  context,
1607
1579
  targetProperties: tp,
1608
1580
  isAffectedByBrowserslist,
1609
- outputModule,
1610
1581
  development,
1611
1582
  entry,
1612
1583
  futureDefaults,
@@ -1662,7 +1633,65 @@ const applyOutputDefaults = (
1662
1633
  }
1663
1634
  });
1664
1635
 
1665
- F(output, "module", () => Boolean(outputModule));
1636
+ /**
1637
+ * Processes the provided fn.
1638
+ * @param {(entryDescription: EntryDescription) => void} fn iterator
1639
+ * @returns {void}
1640
+ */
1641
+ const forEachEntry = (fn) => {
1642
+ for (const name of Object.keys(entry)) {
1643
+ fn(/** @type {{ [k: string]: EntryDescription }} */ (entry)[name]);
1644
+ }
1645
+ };
1646
+
1647
+ /**
1648
+ * Every library type the configuration states, wherever it was declared.
1649
+ * @returns {LibraryType[]} the declared library types
1650
+ */
1651
+ const declaredLibraryTypes = () => {
1652
+ /** @type {LibraryType[]} */
1653
+ const types = [];
1654
+ if (output.library && output.library.type) types.push(output.library.type);
1655
+ // A plugin (`ModuleFederationPlugin`) pushed its type here before the defaults;
1656
+ // `"..."` is the extend placeholder `A` resolves, never a type of its own.
1657
+ if (output.enabledLibraryTypes) {
1658
+ for (const type of output.enabledLibraryTypes) {
1659
+ if (type !== "...") types.push(type);
1660
+ }
1661
+ }
1662
+ forEachEntry((desc) => {
1663
+ if (desc.library && desc.library.type) types.push(desc.library.type);
1664
+ });
1665
+ return types;
1666
+ };
1667
+
1668
+ const libraryTypes = declaredLibraryTypes();
1669
+
1670
+ // A library type that is an ECMAScript module is another spelling of
1671
+ // `output.module`, so it turns it on rather than disagreeing with it.
1672
+ if (libraryTypes.some(isModuleLibraryType)) {
1673
+ output.module = true;
1674
+ }
1675
+
1676
+ // Every other library type is read out of a script, which is a statement that
1677
+ // the output is not an ECMAScript module — so it holds the default below back.
1678
+ const hasScriptLibrary = libraryTypes.some(
1679
+ (type) => !isModuleLibraryType(type)
1680
+ );
1681
+
1682
+ // the universal target (web + node, neither specific), deno and bun only work
1683
+ // as ESM, unless `module: false` says the target cannot read one
1684
+ F(output, "module", () =>
1685
+ Boolean(
1686
+ tp &&
1687
+ ((tp.node === null && tp.web === null && tp.module !== false) ||
1688
+ tp.deno === true ||
1689
+ tp.bun === true ||
1690
+ // webpack@6 emits ESM wherever the target reads one — a browserslist
1691
+ // query (or `esX`/`nodeX`) without ESM support keeps script output
1692
+ (futureDefaults && tp.module !== false && !hasScriptLibrary))
1693
+ )
1694
+ );
1666
1695
 
1667
1696
  const environment = /** @type {Environment} */ (output.environment);
1668
1697
  /**
@@ -1706,12 +1735,11 @@ const applyOutputDefaults = (
1706
1735
  "const",
1707
1736
  () => tp && optimistic(/** @type {boolean | undefined} */ (tp.const))
1708
1737
  );
1709
- // Only the browserslist target reports these; everywhere else they stay
1710
- // unset, which `optimistic` reads as the modern spelling being available —
1711
- // the same policy the JS features above follow.
1712
- // `let` was added after `const`; targets predating it report only `const`,
1713
- // so fall back to `const` when `let` is unreported (undefined). Targets that
1714
- // 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.
1715
1743
  F(environment, "let", () =>
1716
1744
  conditionallyOptimistic(
1717
1745
  /** @type {boolean | undefined} */ (tp && tp.let),
@@ -1748,8 +1776,12 @@ const applyOutputDefaults = (
1748
1776
  "generator",
1749
1777
  () => tp && optimistic(/** @type {boolean | undefined} */ (tp.generator))
1750
1778
  );
1751
- // No `topLevelAwait` here: the option is held back from the patch release,
1752
- // so nothing derives it from `tp` yet. Reapply by reverting #21881.
1779
+ F(
1780
+ environment,
1781
+ "topLevelAwait",
1782
+ () =>
1783
+ tp && optimistic(/** @type {boolean | undefined} */ (tp.topLevelAwait))
1784
+ );
1753
1785
  F(
1754
1786
  environment,
1755
1787
  "forOf",
@@ -1839,10 +1871,9 @@ const applyOutputDefaults = (
1839
1871
  tp && optimistic(/** @type {boolean | undefined} */ (tp.modulePreload))
1840
1872
  );
1841
1873
 
1842
- // Vite-style default for ESM output (`output.module`): preload the entry's
1843
- // initial dependency graph, which native `import()` would otherwise fetch in
1844
- // a waterfall. Classic output loads initial chunks via parallel `<script>`
1845
- // 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.
1846
1877
  if (output.module && output.resourceHints === undefined) {
1847
1878
  output.resourceHints = {};
1848
1879
  }
@@ -1896,13 +1927,9 @@ const applyOutputDefaults = (
1896
1927
  }
1897
1928
  return "[id].css";
1898
1929
  });
1899
- // Derive html filename defaults from `output.filename` / `output.chunkFilename`
1900
- // (the same shape the CSS pipeline uses), but if the derived template lacks
1901
- // any per-module differentiator, fall back to `[name].html` so multiple
1902
- // extracted HTML modules in one compilation don't collide on the same
1903
- // emitted file. For example: `output.filename: "bundle.js"` would derive
1904
- // `bundle.html` — two `.html` modules extracted in the same build would
1905
- // 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.
1906
1933
  const HAS_PATH_PLACEHOLDER_REGEXP =
1907
1934
  /\[(name|id|chunkhash|contenthash|fullhash|hash)/;
1908
1935
  /**
@@ -1949,11 +1976,9 @@ const applyOutputDefaults = (
1949
1976
  if (tp) {
1950
1977
  if (tp.global) return "global";
1951
1978
  if (tp.globalThis) return "globalThis";
1952
- // Universal target (web + node): no one identifier is defined on both
1953
- // sides, so `globalThis` where the target reports nothing against it,
1954
- // and a guarded pair where it does — `self` covers window and worker
1955
- // scopes, `global` covers Node.js. Naming either alone leaves the other
1956
- // 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.
1957
1982
  if (tp.web === null && tp.node === null) {
1958
1983
  return tp.globalThis === undefined
1959
1984
  ? "globalThis"
@@ -1984,7 +2009,7 @@ const applyOutputDefaults = (
1984
2009
  "For the selected environment is no default script chunk format available:\n" +
1985
2010
  `${
1986
2011
  tp.module
1987
- ? "Module ('module') can be chosen when ES modules are available (please set 'experiments.outputModule' and 'output.module' to `true`)"
2012
+ ? "Module ('module') can be chosen when ES modules are available (please set 'output.module' to `true`)"
1988
2013
  : ""
1989
2014
  }\n` +
1990
2015
  "JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.\n" +
@@ -2131,16 +2156,6 @@ const applyOutputDefaults = (
2131
2156
  D(trustedTypes, "onPolicyCreationFailure", "stop");
2132
2157
  }
2133
2158
 
2134
- /**
2135
- * Processes the provided fn.
2136
- * @param {(entryDescription: EntryDescription) => void} fn iterator
2137
- * @returns {void}
2138
- */
2139
- const forEachEntry = (fn) => {
2140
- for (const name of Object.keys(entry)) {
2141
- fn(/** @type {{ [k: string]: EntryDescription }} */ (entry)[name]);
2142
- }
2143
- };
2144
2159
  A(output, "enabledLibraryTypes", () => {
2145
2160
  /** @type {LibraryType[]} */
2146
2161
  const enabledLibraryTypes = [];
@@ -2391,6 +2406,7 @@ const applyPerformanceDefaults = (performance, { production }) => {
2391
2406
  // Stands in for every check left unset, so an explicit one still wins.
2392
2407
  const all = performance.all !== undefined ? performance.all : false;
2393
2408
 
2409
+ D(performance, "analyzableBailouts", all);
2394
2410
  D(performance, "asyncChunkWaterfalls", all);
2395
2411
  D(performance, "broadContexts", all);
2396
2412
  D(performance, "cacheEffectiveness", all);
@@ -2399,8 +2415,6 @@ const applyPerformanceDefaults = (performance, { production }) => {
2399
2415
  D(performance, "duplicateModules", all);
2400
2416
  D(performance, "duplicatePackages", all);
2401
2417
  D(performance, "dynamicExports", all);
2402
- D(performance, "entrypointOverlap", all);
2403
- D(performance, "embeddedSourceMaps", all);
2404
2418
  D(performance, "evalUsage", all);
2405
2419
  D(performance, "hotspots", all);
2406
2420
  D(performance, "legacyJavascript", all);
@@ -2413,14 +2427,13 @@ const applyPerformanceDefaults = (performance, { production }) => {
2413
2427
  D(performance, "redundantDynamicImports", all);
2414
2428
  D(performance, "scopeHoistingBailouts", all);
2415
2429
  D(performance, "splitChunksCapped", all);
2430
+ D(performance, "sourceMaps", all);
2416
2431
  D(performance, "tinyChunks", all);
2417
2432
  D(performance, "topLevelThis", all);
2418
2433
  D(performance, "unsplitVendors", all);
2419
- D(performance, "unusedAliases", all);
2420
- D(performance, "unusedDefines", all);
2421
- D(performance, "unusedExternals", all);
2422
- D(performance, "unusedReexports", all);
2423
- D(performance, "unusedRules", all);
2434
+ D(performance, "unusedAssets", all);
2435
+ D(performance, "unusedConfig", all);
2436
+ D(performance, "unusedModules", all);
2424
2437
  F(performance, "hints", () => (production ? "warning" : false));
2425
2438
  };
2426
2439
 
@@ -2495,19 +2508,17 @@ const applyOptimizationDefaults = (
2495
2508
  // Lazy load the minimizer plugin
2496
2509
  const TerserPlugin = require("minimizer-webpack-plugin");
2497
2510
 
2498
- // One minimizer instance (one worker-thread pool) handles JS and, when
2499
- // native CSS / HTML is enabled, those assets too — an array of minify
2500
- // functions each dispatched by its own `filter` (terser -> JS,
2501
- // cssMinify -> CSS, htmlMinify -> HTML). The CSS / HTML serializers stay
2502
- // worker-safe by resolving their parser with `require("webpack/…")` in
2503
- // the worker, so all three share the same pool. `test` is widened to let
2504
- // CSS / HTML assets reach the dispatcher.
2505
- // Step aside for a minimizer the user already configured for these
2506
- // types: whichever of the two ran first would mark the asset
2507
- // `minimized` and silently disable the other, so webpack only claims
2508
- // what nothing else does. Their asset matchers are read directly rather
2509
- // than resolved per asset — a coarse check, but it keeps the outcome
2510
- // 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.
2511
2522
  const claimedByOtherMinimizer = require("./getClaimedAssetTypes")(
2512
2523
  compiler
2513
2524
  );
@@ -2583,10 +2594,9 @@ const applyOptimizationDefaults = (
2583
2594
  }
2584
2595
  if (minifyHtml) {
2585
2596
  minify.push(require("../html/htmlMinify"));
2586
- // `minimize.css` rides along under its own key rather than spread
2587
- // beside the HTML options: the two name some of the same switches
2588
- // (`quotes`, `comments`), and one flat object would hand
2589
- // 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.
2590
2600
  minimizerOptions.push({
2591
2601
  environment: cssEnvironment,
2592
2602
  css: cssOptions,