@depup/webpack 5.110.1-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 (304) 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/ChunkGraph.js +20 -18
  8. package/lib/CircularModulesPlugin.js +157 -55
  9. package/lib/CleanPlugin.js +2 -2
  10. package/lib/CompatibilityPlugin.js +3 -4
  11. package/lib/Compilation.js +337 -338
  12. package/lib/Compiler.js +213 -51
  13. package/lib/ConcatenationScope.js +25 -35
  14. package/lib/ConstPlugin.js +16 -132
  15. package/lib/CopyPlugin.js +1054 -0
  16. package/lib/DefinePlugin.js +24 -8
  17. package/lib/DependencyTemplate.js +2 -1
  18. package/lib/DotenvPlugin.js +64 -40
  19. package/lib/ErrorHelpers.js +113 -0
  20. package/lib/ExportsInfo.js +30 -16
  21. package/lib/ExternalModule.js +47 -22
  22. package/lib/FileSystemInfo.js +17 -14
  23. package/lib/FlagDependencyExportsPlugin.js +53 -34
  24. package/lib/FlagDependencyUsagePlugin.js +17 -15
  25. package/lib/Generator.js +24 -2
  26. package/lib/HotModuleReplacementPlugin.js +55 -7
  27. package/lib/IgnorePlugin.js +1 -1
  28. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  29. package/lib/LoaderOptionsPlugin.js +1 -1
  30. package/lib/MainTemplate.js +5 -1
  31. package/lib/Module.js +19 -10
  32. package/lib/ModuleGraph.js +6 -9
  33. package/lib/MultiCompiler.js +7 -17
  34. package/lib/MultiWatching.js +1 -1
  35. package/lib/NormalModule.js +148 -70
  36. package/lib/NormalModuleFactory.js +1 -1
  37. package/lib/RuntimeGlobals.js +21 -7
  38. package/lib/RuntimeModule.js +28 -12
  39. package/lib/RuntimePlugin.js +33 -3
  40. package/lib/RuntimeTemplate.js +1147 -847
  41. package/lib/SourceMapDevToolPlugin.js +54 -104
  42. package/lib/TemplatedPathPlugin.js +16 -59
  43. package/lib/Watching.js +9 -0
  44. package/lib/WebpackOptionsApply.js +84 -91
  45. package/lib/asset/AssetBytesGenerator.js +7 -1
  46. package/lib/asset/AssetGenerator.js +50 -24
  47. package/lib/asset/AssetModule.js +3 -0
  48. package/lib/asset/AssetSourceGenerator.js +7 -1
  49. package/lib/asset/WebManifestParser.js +7 -5
  50. package/lib/async-modules/AsyncModuleHelpers.js +10 -4
  51. package/lib/buildChunkGraph.js +11 -15
  52. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  53. package/lib/cache/IdleFileCachePlugin.js +2 -2
  54. package/lib/cache/MemoryCachePlugin.js +4 -4
  55. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  56. package/lib/cache/PackFileCacheStrategy.js +17 -19
  57. package/lib/cache/getLazyHashedEtag.js +3 -5
  58. package/lib/config/browserslistTargetHandler.js +17 -4
  59. package/lib/config/defaults.js +162 -142
  60. package/lib/config/getClaimedAssetTypes.js +10 -11
  61. package/lib/config/normalization.js +100 -20
  62. package/lib/config/target.js +13 -4
  63. package/lib/container/ContainerReferencePlugin.js +6 -0
  64. package/lib/container/RemoteRuntimeModule.js +9 -0
  65. package/lib/container/declaredRemotes.js +39 -0
  66. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  67. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  68. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  69. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  70. package/lib/css/CssGenerator.js +27 -11
  71. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  72. package/lib/css/CssLoadingRuntimeModule.js +92 -15
  73. package/lib/css/CssModule.js +1 -1
  74. package/lib/css/CssModulesPlugin.js +3 -10
  75. package/lib/css/CssParser.js +162 -31
  76. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  77. package/lib/css/cssMinify.js +43 -32
  78. package/lib/css/data.js +3526 -871
  79. package/lib/css/syntax.js +6455 -1237
  80. package/lib/debug/ProfilingPlugin.js +7 -4
  81. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  82. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  83. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  84. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  85. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  86. package/lib/dependencies/CommonJsPlugin.js +19 -3
  87. package/lib/dependencies/CommonJsRequireDependency.js +32 -9
  88. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  89. package/lib/dependencies/ContextDependency.js +1 -1
  90. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  91. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
  92. package/lib/dependencies/ContextElementDependency.js +1 -1
  93. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  94. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  95. package/lib/dependencies/CssUrlDependency.js +3 -5
  96. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  97. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  98. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
  99. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -7
  100. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  101. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +217 -34
  102. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  103. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  104. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  105. package/lib/dependencies/HarmonyImportDependency.js +99 -41
  106. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +198 -25
  107. package/lib/dependencies/HarmonyImportSideEffectDependency.js +117 -4
  108. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  109. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  110. package/lib/dependencies/HtmlEntryDependency.js +136 -104
  111. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  112. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  113. package/lib/dependencies/ImportContextDependency.js +43 -3
  114. package/lib/dependencies/ImportDependency.js +8 -29
  115. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  116. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  117. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  118. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  119. package/lib/dependencies/ImportParserPlugin.js +25 -15
  120. package/lib/dependencies/LoaderPlugin.js +26 -1
  121. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  122. package/lib/dependencies/RequireHeaderDependency.js +20 -21
  123. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  124. package/lib/dependencies/URLContextDependency.js +1 -1
  125. package/lib/dependencies/URLDependency.js +6 -5
  126. package/lib/dependencies/WorkerAndWorkletPlugin.js +16 -21
  127. package/lib/dependencies/WorkerDependency.js +12 -18
  128. package/lib/dependencies/WorkletDependency.js +12 -20
  129. package/lib/dependencies/importOptionsCheck.js +47 -0
  130. package/lib/dll/DelegatedModule.js +18 -1
  131. package/lib/dll/DllReferencePlugin.js +11 -8
  132. package/lib/dll/LibManifestPlugin.js +1 -1
  133. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  134. package/lib/errors/DotenvFileError.js +29 -0
  135. package/lib/errors/DuplicateModulesWarning.js +12 -7
  136. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  137. package/lib/errors/ExternalStarReexportError.js +44 -0
  138. package/lib/errors/HookWebpackError.js +3 -2
  139. package/lib/errors/ImportedBindingAssignmentError.js +30 -0
  140. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  141. package/lib/errors/ModuleParseError.js +2 -1
  142. package/lib/errors/UnusedAssetsWarning.js +36 -0
  143. package/lib/errors/UnusedFederationWarning.js +35 -0
  144. package/lib/errors/UnusedModulesWarning.js +38 -0
  145. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  146. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  147. package/lib/esm/ModuleChunkLoadingPlugin.js +21 -5
  148. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +91 -53
  149. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  150. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  151. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  152. package/lib/html/HtmlGenerator.js +72 -87
  153. package/lib/html/HtmlModulesPlugin.js +479 -215
  154. package/lib/html/HtmlParser.js +110 -147
  155. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  156. package/lib/html/data.js +142 -7
  157. package/lib/html/htmlMinify.js +92 -122
  158. package/lib/html/syntax.js +2031 -1556
  159. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  160. package/lib/index.js +49 -3
  161. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  162. package/lib/javascript/JavascriptGenerator.js +8 -1
  163. package/lib/javascript/JavascriptModule.js +1 -0
  164. package/lib/javascript/JavascriptModulesPlugin.js +76 -80
  165. package/lib/javascript/JavascriptParser.js +1970 -900
  166. package/lib/javascript/StartupHelpers.js +27 -3
  167. package/lib/javascript/data.js +172 -0
  168. package/lib/javascript/grammar.js +5546 -0
  169. package/lib/javascript/parser.js +1500 -0
  170. package/lib/javascript/regexp.js +1762 -0
  171. package/lib/javascript/regexpData.js +51 -0
  172. package/lib/javascript/syntax.js +9061 -5262
  173. package/lib/json/JsonGenerator.js +7 -1
  174. package/lib/library/ModuleLibraryPlugin.js +171 -132
  175. package/lib/loaders/LoaderRunner.js +170 -14
  176. package/lib/node/NodeWatchFileSystem.js +3 -9
  177. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  178. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
  179. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  180. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  181. package/lib/optimize/ConcatenatedModule.js +222 -125
  182. package/lib/optimize/ConstExportsPlugin.js +50 -34
  183. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  184. package/lib/optimize/InlineExports.js +20 -2
  185. package/lib/optimize/InnerGraphPlugin.js +7 -13
  186. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  187. package/lib/optimize/MangleExportsPlugin.js +13 -4
  188. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  189. package/lib/optimize/RealContentHashPlugin.js +179 -44
  190. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  191. package/lib/optimize/SplitChunksPlugin.js +2 -4
  192. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  193. package/lib/performance/BroadContextsPlugin.js +1 -1
  194. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  195. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  196. package/lib/performance/EvalUsagePlugin.js +5 -2
  197. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  198. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  199. package/lib/performance/SizeLimitsPlugin.js +2 -4
  200. package/lib/performance/TopLevelThisPlugin.js +5 -4
  201. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  202. package/lib/performance/UnusedFederationPlugin.js +147 -0
  203. package/lib/performance/UnusedModulesPlugin.js +141 -0
  204. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  205. package/lib/performance/isOnlyReexported.js +65 -0
  206. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  207. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  208. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  209. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  210. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  211. package/lib/prefetch/ResourceHintPlugin.js +29 -35
  212. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  213. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  214. package/lib/rules/RuleSetCompiler.js +211 -4
  215. package/lib/runtime/AsyncModuleRuntimeModule.js +103 -67
  216. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  217. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  218. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  219. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  220. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  221. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  222. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  223. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  224. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  225. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  226. package/lib/runtime/HelperRuntimeModule.js +10 -0
  227. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +313 -222
  228. package/lib/runtime/NonceRuntimeModule.js +9 -0
  229. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  230. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  231. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  232. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  233. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  234. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  235. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  236. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  237. package/lib/schemes/DataUriPlugin.js +3 -6
  238. package/lib/schemes/HttpUriPlugin.js +22 -5
  239. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  240. package/lib/serialization/BinaryMiddleware.js +9 -9
  241. package/lib/serialization/FileMiddleware.js +31 -18
  242. package/lib/serialization/ObjectMiddleware.js +168 -139
  243. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  244. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  245. package/lib/sharing/ShareRuntimeModule.js +9 -0
  246. package/lib/sharing/declaredShared.js +47 -0
  247. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  248. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  249. package/lib/typescript/TypeScriptPlugin.js +10 -13
  250. package/lib/url/URLParserPlugin.js +6 -8
  251. package/lib/util/ArrayQueue.js +3 -3
  252. package/lib/util/LocConverter.js +4 -7
  253. package/lib/util/SourceProcessor.js +115 -99
  254. package/lib/util/URLAbsoluteSpecifier.js +3 -1
  255. package/lib/util/async.js +292 -0
  256. package/lib/util/buildDiagnostics.js +69 -0
  257. package/lib/util/chainedImports.js +3 -4
  258. package/lib/util/concatenate.js +4 -4
  259. package/lib/util/conventions.js +5 -1
  260. package/lib/util/createHooksRegistry.js +1 -2
  261. package/lib/util/createMappings.js +25 -3
  262. package/lib/util/dataURL.js +2 -3
  263. package/lib/util/deterministicGrouping.js +8 -13
  264. package/lib/util/findGraphRoots.js +6 -13
  265. package/lib/util/fs.js +27 -1
  266. package/lib/util/globUtils.js +1 -1
  267. package/lib/util/handlerKeys.js +40 -0
  268. package/lib/util/hash/wasm-hash.js +3 -4
  269. package/lib/util/identifier.js +20 -0
  270. package/lib/util/internalSerializables.js +7 -1
  271. package/lib/util/registerExternalSerializer.js +6 -45
  272. package/lib/util/removeBOM.js +82 -1
  273. package/lib/util/semver.js +5 -3
  274. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +14 -3
  275. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +14 -3
  276. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  277. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  278. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
  279. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  280. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  281. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  282. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  283. package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -6
  284. package/lib/web/FetchCompileWasmPlugin.js +4 -2
  285. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  286. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  287. package/package.json +55 -46
  288. package/schemas/WebpackOptions.check.js +1 -1
  289. package/schemas/WebpackOptions.json +388 -76
  290. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  291. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  292. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  293. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  294. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  295. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  296. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  297. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  298. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  299. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  300. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  301. package/types.d.ts +1795 -608
  302. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  303. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  304. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -179,6 +179,7 @@ const {
179
179
  * portableRecords: NonNullable<Optimization["portableRecords"]>,
180
180
  * realContentHash: NonNullable<Optimization["realContentHash"]>,
181
181
  * minimize: NonNullable<Optimization["minimize"]>,
182
+ * minimizeOptions: NonNullable<Optimization["minimizeOptions"]>,
182
183
  * minimizer: NonNullable<Exclude<Optimization["minimizer"], "...">>,
183
184
  * nodeEnv: NonNullable<Optimization["nodeEnv"]>,
184
185
  * }} OptimizationNormalizedWithDefaults
@@ -302,6 +303,15 @@ const A = (obj, prop, factory) => {
302
303
  }
303
304
  };
304
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
+
305
315
  /**
306
316
  * Apply webpack options base defaults.
307
317
  * @param {WebpackOptionsNormalized} options options to be modified
@@ -363,7 +373,6 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
363
373
  applyExperimentsDefaults(options.experiments, {
364
374
  production,
365
375
  development,
366
- targetProperties,
367
376
  rules: options.module.rules
368
377
  });
369
378
 
@@ -407,9 +416,6 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
407
416
  (typeof target === "string" && target.startsWith("browserslist")) ||
408
417
  (Array.isArray(target) &&
409
418
  target.some((target) => target.startsWith("browserslist"))),
410
- outputModule:
411
- /** @type {NonNullable<ExperimentsNormalized["outputModule"]>} */
412
- (options.experiments.outputModule),
413
419
  development,
414
420
  entry: options.entry,
415
421
  futureDefaults,
@@ -422,9 +428,7 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
422
428
  // is read by another bundler, where an eval wrapper hides `import.meta` from it.
423
429
  const noDevSourceMap = /** @type {LibraryType[]} */ (
424
430
  options.output.enabledLibraryTypes
425
- ).some(
426
- (type) => futureDefaults || type === "module" || type === "modern-module"
427
- );
431
+ ).some((type) => futureDefaults || isModuleLibraryType(type));
428
432
 
429
433
  F(
430
434
  options,
@@ -488,10 +492,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
488
492
  library: options.output.library
489
493
  });
490
494
 
491
- // `output.resourceHints.urlHints` shorthand: fan the project-wide rules out
492
- // as the base `urlHints` of every URL-emitting parser (JS `new URL`, CSS
493
- // `url()`, HTML `<img src>`). They go first so parser-scoped
494
- // `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.
495
498
  const outputUrlHints =
496
499
  options.output.resourceHints && options.output.resourceHints.urlHints;
497
500
  if (outputUrlHints && outputUrlHints.length > 0) {
@@ -629,13 +632,12 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
629
632
  * @param {object} options options
630
633
  * @param {boolean} options.production is production
631
634
  * @param {boolean} options.development is development mode
632
- * @param {TargetProperties | false} options.targetProperties target properties
633
635
  * @param {RuleSetRules} options.rules user `module.rules`, used to resolve the css/html/asyncWebAssembly/typescript "auto" defaults
634
636
  * @returns {void}
635
637
  */
636
638
  const applyExperimentsDefaults = (
637
639
  experiments,
638
- { production, development, targetProperties, rules }
640
+ { production, development, rules }
639
641
  ) => {
640
642
  D(experiments, "futureDefaults", false);
641
643
  D(experiments, "backCompat", !experiments.futureDefaults);
@@ -646,23 +648,6 @@ const applyExperimentsDefaults = (
646
648
  "asyncWebAssembly",
647
649
  experiments.futureDefaults ? true : "auto"
648
650
  );
649
- // the universal target (web + node, neither specific) only works as ESM —
650
- // unless the target cannot read one, which no output format can repair, so
651
- // leave `output.chunkFormat` to say so rather than emitting a module the
652
- // target has already reported it will not load
653
- const universal =
654
- Boolean(targetProperties) &&
655
- /** @type {TargetProperties} */ (targetProperties).node === null &&
656
- /** @type {TargetProperties} */ (targetProperties).web === null &&
657
- /** @type {TargetProperties} */ (targetProperties).module !== false;
658
- // the deno and bun targets only emit ECMAScript modules
659
- const deno =
660
- Boolean(targetProperties) &&
661
- /** @type {TargetProperties} */ (targetProperties).deno === true;
662
- const bun =
663
- Boolean(targetProperties) &&
664
- /** @type {TargetProperties} */ (targetProperties).bun === true;
665
- D(experiments, "outputModule", universal || deno || bun);
666
651
  D(experiments, "lazyCompilation", undefined);
667
652
  D(experiments, "buildHttp", undefined);
668
653
  D(experiments, "cacheUnaffected", experiments.futureDefaults);
@@ -674,14 +659,12 @@ const applyExperimentsDefaults = (
674
659
  experiments.futureDefaults ? true : "auto"
675
660
  );
676
661
 
677
- // Resolve the "auto" default: enable the built-in css/html module type unless
678
- // the user already registered a loader (or explicit type) for these files, so
679
- // enabling them by default does not break existing css-loader/html-loader setups.
680
- // The built-in `/\.css$/i` rule also covers `.module.css`, so a loader scoped to
681
- // CSS modules must disable the built-in type too — sample both extensions.
682
- // When enabled implicitly the value stays `"auto"` (truthy): Css/HtmlModulesPlugin
683
- // then step aside per-module for requests that loaders were applied to
684
- // (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.
685
668
  // TODO webpack 6: css/html default to `true`, drop the `"auto"` marker.
686
669
  if (experiments.css === "auto") {
687
670
  experiments.css =
@@ -918,6 +901,7 @@ const applyJavascriptParserOptionsDefaults = (
918
901
  D(parserOptions, "wrappedContextRecursive", true);
919
902
  D(parserOptions, "wrappedContextCritical", false);
920
903
  D(parserOptions, "strictThisContextOnImports", false);
904
+ D(parserOptions, "specNamespaceObject", false);
921
905
  D(parserOptions, "importMeta", outputModule ? "preserve-unknown" : true);
922
906
  D(parserOptions, "dynamicImportMode", "lazy");
923
907
  D(parserOptions, "dynamicImportPrefetch", false);
@@ -1240,18 +1224,13 @@ const applyModuleDefaults = (
1240
1224
  }
1241
1225
 
1242
1226
  if (html) {
1243
- // `module.generator.html.extract` is intentionally left undefined by
1244
- // default: HtmlGenerator treats undefined as "extract iff this HTML
1245
- // module is a compilation entry", which is the HTML-entry-point
1246
- // behaviour. Setting `extract: true` forces extraction for all HTML
1247
- // modules (including imported ones); `extract: false` disables it
1248
- // 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.
1249
1230
  F(module.generator, HTML_MODULE_TYPE, () => ({}));
1250
- // `module.parser.html.sources` defaults to `true` — HtmlParser uses
1251
- // the built-in source list to extract URL-like attributes (`<img
1252
- // src>`, `<link href>`, `<script src>`, …) as webpack dependencies.
1253
- // Users may pass `false` to disable extraction entirely or an array
1254
- // (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.
1255
1234
  F(module.parser, HTML_MODULE_TYPE, () => ({}));
1256
1235
  D(
1257
1236
  /** @type {NonNullable<ParserOptionsByModuleTypeKnown[HTML_MODULE_TYPE]>} */
@@ -1385,11 +1364,9 @@ const applyModuleDefaults = (
1385
1364
  type: CSS_MODULE_TYPE,
1386
1365
  resolve
1387
1366
  });
1388
- // For CSS modules, i.e. `.class { composes: className from "./style.css" }`
1389
- // We inherit for such constructions, but skip files that are already
1390
- // detected as CSS modules by extension (`.module.<ext>`) — they get
1391
- // the same modules-mode behavior from the auto rule, and forcing a
1392
- // 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.
1393
1370
  const moduleExtension = /\.module\.\w+$/i;
1394
1371
  rules.push({
1395
1372
  dependency: /css-import-local-module/,
@@ -1432,16 +1409,16 @@ const applyModuleDefaults = (
1432
1409
  type: HTML_MODULE_TYPE,
1433
1410
  resolve
1434
1411
  });
1412
+ // Exactly `text/html` — a string condition matches by prefix, which
1413
+ // would make a `data:text/htmlx,` module (JavaScript) a page.
1435
1414
  rules.push({
1436
- mimetype: "text/html",
1415
+ mimetype: /^text\/html$/i,
1437
1416
  type: HTML_MODULE_TYPE,
1438
1417
  resolve
1439
1418
  });
1440
- // `<iframe srcdoc>` content is fed back through the HTML pipeline as a
1441
- // `data:text/html` module. `extract: "inline"` exposes the processed
1442
- // HTML on the `html` codegen channel that `HtmlInlineHtmlDependency.
1443
- // Template` reads back into the attribute, without emitting a standalone
1444
- // `.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.
1445
1422
  rules.push({
1446
1423
  dependency: "html-srcdoc",
1447
1424
  generator: {
@@ -1450,12 +1427,9 @@ const applyModuleDefaults = (
1450
1427
  resolve
1451
1428
  });
1452
1429
  if (css) {
1453
- // Inline `<style>` content in an HTML module is fed into the
1454
- // CSS pipeline as a `data:text/css` virtual module. We force
1455
- // `exportType: "text"` so the CSS module exposes the
1456
- // processed CSS text on the `css-text` codegen channel that
1457
- // `HtmlInlineStyleDependency.Template` reads back into the
1458
- // `<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.
1459
1433
  rules.push({
1460
1434
  dependency: "html-style",
1461
1435
  parser: {
@@ -1592,7 +1566,6 @@ const applyModuleDefaults = (
1592
1566
  * @param {string} options.context context
1593
1567
  * @param {TargetProperties | false} options.targetProperties target properties
1594
1568
  * @param {boolean} options.isAffectedByBrowserslist is affected by browserslist
1595
- * @param {boolean} options.outputModule is outputModule experiment enabled
1596
1569
  * @param {boolean} options.development is development mode
1597
1570
  * @param {Entry} options.entry entry option
1598
1571
  * @param {boolean} options.futureDefaults is future defaults enabled
@@ -1605,7 +1578,6 @@ const applyOutputDefaults = (
1605
1578
  context,
1606
1579
  targetProperties: tp,
1607
1580
  isAffectedByBrowserslist,
1608
- outputModule,
1609
1581
  development,
1610
1582
  entry,
1611
1583
  futureDefaults,
@@ -1661,7 +1633,65 @@ const applyOutputDefaults = (
1661
1633
  }
1662
1634
  });
1663
1635
 
1664
- 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
+ );
1665
1695
 
1666
1696
  const environment = /** @type {Environment} */ (output.environment);
1667
1697
  /**
@@ -1705,12 +1735,11 @@ const applyOutputDefaults = (
1705
1735
  "const",
1706
1736
  () => tp && optimistic(/** @type {boolean | undefined} */ (tp.const))
1707
1737
  );
1708
- // Only the browserslist target reports these; everywhere else they stay
1709
- // unset, which `optimistic` reads as the modern spelling being available —
1710
- // the same policy the JS features above follow.
1711
- // `let` was added after `const`; targets predating it report only `const`,
1712
- // so fall back to `const` when `let` is unreported (undefined). Targets that
1713
- // 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.
1714
1743
  F(environment, "let", () =>
1715
1744
  conditionallyOptimistic(
1716
1745
  /** @type {boolean | undefined} */ (tp && tp.let),
@@ -1747,6 +1776,12 @@ const applyOutputDefaults = (
1747
1776
  "generator",
1748
1777
  () => tp && optimistic(/** @type {boolean | undefined} */ (tp.generator))
1749
1778
  );
1779
+ F(
1780
+ environment,
1781
+ "topLevelAwait",
1782
+ () =>
1783
+ tp && optimistic(/** @type {boolean | undefined} */ (tp.topLevelAwait))
1784
+ );
1750
1785
  F(
1751
1786
  environment,
1752
1787
  "forOf",
@@ -1836,10 +1871,9 @@ const applyOutputDefaults = (
1836
1871
  tp && optimistic(/** @type {boolean | undefined} */ (tp.modulePreload))
1837
1872
  );
1838
1873
 
1839
- // Vite-style default for ESM output (`output.module`): preload the entry's
1840
- // initial dependency graph, which native `import()` would otherwise fetch in
1841
- // a waterfall. Classic output loads initial chunks via parallel `<script>`
1842
- // 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.
1843
1877
  if (output.module && output.resourceHints === undefined) {
1844
1878
  output.resourceHints = {};
1845
1879
  }
@@ -1893,13 +1927,9 @@ const applyOutputDefaults = (
1893
1927
  }
1894
1928
  return "[id].css";
1895
1929
  });
1896
- // Derive html filename defaults from `output.filename` / `output.chunkFilename`
1897
- // (the same shape the CSS pipeline uses), but if the derived template lacks
1898
- // any per-module differentiator, fall back to `[name].html` so multiple
1899
- // extracted HTML modules in one compilation don't collide on the same
1900
- // emitted file. For example: `output.filename: "bundle.js"` would derive
1901
- // `bundle.html` — two `.html` modules extracted in the same build would
1902
- // 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.
1903
1933
  const HAS_PATH_PLACEHOLDER_REGEXP =
1904
1934
  /\[(name|id|chunkhash|contenthash|fullhash|hash)/;
1905
1935
  /**
@@ -1946,11 +1976,9 @@ const applyOutputDefaults = (
1946
1976
  if (tp) {
1947
1977
  if (tp.global) return "global";
1948
1978
  if (tp.globalThis) return "globalThis";
1949
- // Universal target (web + node): no one identifier is defined on both
1950
- // sides, so `globalThis` where the target reports nothing against it,
1951
- // and a guarded pair where it does — `self` covers window and worker
1952
- // scopes, `global` covers Node.js. Naming either alone leaves the other
1953
- // 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.
1954
1982
  if (tp.web === null && tp.node === null) {
1955
1983
  return tp.globalThis === undefined
1956
1984
  ? "globalThis"
@@ -1981,7 +2009,7 @@ const applyOutputDefaults = (
1981
2009
  "For the selected environment is no default script chunk format available:\n" +
1982
2010
  `${
1983
2011
  tp.module
1984
- ? "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`)"
1985
2013
  : ""
1986
2014
  }\n` +
1987
2015
  "JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.\n" +
@@ -2128,16 +2156,6 @@ const applyOutputDefaults = (
2128
2156
  D(trustedTypes, "onPolicyCreationFailure", "stop");
2129
2157
  }
2130
2158
 
2131
- /**
2132
- * Processes the provided fn.
2133
- * @param {(entryDescription: EntryDescription) => void} fn iterator
2134
- * @returns {void}
2135
- */
2136
- const forEachEntry = (fn) => {
2137
- for (const name of Object.keys(entry)) {
2138
- fn(/** @type {{ [k: string]: EntryDescription }} */ (entry)[name]);
2139
- }
2140
- };
2141
2159
  A(output, "enabledLibraryTypes", () => {
2142
2160
  /** @type {LibraryType[]} */
2143
2161
  const enabledLibraryTypes = [];
@@ -2388,6 +2406,7 @@ const applyPerformanceDefaults = (performance, { production }) => {
2388
2406
  // Stands in for every check left unset, so an explicit one still wins.
2389
2407
  const all = performance.all !== undefined ? performance.all : false;
2390
2408
 
2409
+ D(performance, "analyzableBailouts", all);
2391
2410
  D(performance, "asyncChunkWaterfalls", all);
2392
2411
  D(performance, "broadContexts", all);
2393
2412
  D(performance, "cacheEffectiveness", all);
@@ -2396,8 +2415,6 @@ const applyPerformanceDefaults = (performance, { production }) => {
2396
2415
  D(performance, "duplicateModules", all);
2397
2416
  D(performance, "duplicatePackages", all);
2398
2417
  D(performance, "dynamicExports", all);
2399
- D(performance, "entrypointOverlap", all);
2400
- D(performance, "embeddedSourceMaps", all);
2401
2418
  D(performance, "evalUsage", all);
2402
2419
  D(performance, "hotspots", all);
2403
2420
  D(performance, "legacyJavascript", all);
@@ -2410,14 +2427,13 @@ const applyPerformanceDefaults = (performance, { production }) => {
2410
2427
  D(performance, "redundantDynamicImports", all);
2411
2428
  D(performance, "scopeHoistingBailouts", all);
2412
2429
  D(performance, "splitChunksCapped", all);
2430
+ D(performance, "sourceMaps", all);
2413
2431
  D(performance, "tinyChunks", all);
2414
2432
  D(performance, "topLevelThis", all);
2415
2433
  D(performance, "unsplitVendors", all);
2416
- D(performance, "unusedAliases", all);
2417
- D(performance, "unusedDefines", all);
2418
- D(performance, "unusedExternals", all);
2419
- D(performance, "unusedReexports", all);
2420
- D(performance, "unusedRules", all);
2434
+ D(performance, "unusedAssets", all);
2435
+ D(performance, "unusedConfig", all);
2436
+ D(performance, "unusedModules", all);
2421
2437
  F(performance, "hints", () => (production ? "warning" : false));
2422
2438
  };
2423
2439
 
@@ -2463,20 +2479,28 @@ const applyOptimizationDefaults = (
2463
2479
  D(optimization, "mangleWasmImports", false);
2464
2480
  D(optimization, "portableRecords", records);
2465
2481
  D(optimization, "realContentHash", production);
2466
- F(optimization, "minimize", () => (production ? {} : false));
2467
- // A plugin can assign the `true` shorthand in `apply()`, which runs after
2468
- // `getNormalizedOptimizationMinimize` and so never gets normalized. The
2469
- // normalized type does not allow it, hence the cast.
2470
- if (/** @type {unknown} */ (optimization.minimize) === true) {
2471
- optimization.minimize = {};
2482
+ // A plugin assigning the object shorthand in `apply()` runs after
2483
+ // normalization: it replaces `minimizeOptions`, keeping `minimize` boolean.
2484
+ const minimizeAssignedInApply = /** @type {unknown} */ (
2485
+ optimization.minimize
2486
+ );
2487
+ if (typeof minimizeAssignedInApply === "object") {
2488
+ optimization.minimizeOptions = /** @type {OptimizationMinimizeOptions} */ (
2489
+ minimizeAssignedInApply
2490
+ );
2491
+ optimization.minimize = true;
2472
2492
  }
2473
- const { minimize } = optimization;
2474
- if (minimize) {
2475
- // Canonicalize the object form: the JS minimizer's defaults become
2476
- // visible in the resolved config rather than hidden in the wiring.
2477
- F(minimize, "javascript", () => ({ compress: { passes: 2 } }));
2478
- F(minimize, "css", () => ({}));
2479
- F(minimize, "html", () => ({}));
2493
+ D(optimization, "minimize", production);
2494
+ F(optimization, "minimizeOptions", () => ({}));
2495
+ const minimizeOptions =
2496
+ /** @type {NonNullable<Optimization["minimizeOptions"]>} */
2497
+ (optimization.minimizeOptions);
2498
+ if (optimization.minimize) {
2499
+ // Canonicalize the per-asset-type options: the JS minimizer's defaults
2500
+ // become visible in the resolved config rather than hidden in the wiring.
2501
+ F(minimizeOptions, "javascript", () => ({ compress: { passes: 2 } }));
2502
+ F(minimizeOptions, "css", () => ({}));
2503
+ F(minimizeOptions, "html", () => ({}));
2480
2504
  }
2481
2505
  A(optimization, "minimizer", () => [
2482
2506
  {
@@ -2484,27 +2508,24 @@ const applyOptimizationDefaults = (
2484
2508
  // Lazy load the minimizer plugin
2485
2509
  const TerserPlugin = require("minimizer-webpack-plugin");
2486
2510
 
2487
- // One minimizer instance (one worker-thread pool) handles JS and, when
2488
- // native CSS / HTML is enabled, those assets too — an array of minify
2489
- // functions each dispatched by its own `filter` (terser -> JS,
2490
- // cssMinify -> CSS, htmlMinify -> HTML). The CSS / HTML serializers stay
2491
- // worker-safe by resolving their parser with `require("webpack/…")` in
2492
- // the worker, so all three share the same pool. `test` is widened to let
2493
- // CSS / HTML assets reach the dispatcher.
2494
- // Step aside for a minimizer the user already configured for these
2495
- // types: whichever of the two ran first would mark the asset
2496
- // `minimized` and silently disable the other, so webpack only claims
2497
- // what nothing else does. Their asset matchers are read directly rather
2498
- // than resolved per asset — a coarse check, but it keeps the outcome
2499
- // 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.
2500
2522
  const claimedByOtherMinimizer = require("./getClaimedAssetTypes")(
2501
2523
  compiler
2502
2524
  );
2503
2525
 
2504
- // Normalized + defaulted `optimization.minimize` is the per-asset-type
2505
- // object here: `false` disables a type, an object is its options.
2526
+ // Per asset type: `false` disables that type, an object is its options.
2506
2527
  const minimizeByType = /** @type {OptimizationMinimizeOptions} */ (
2507
- compiler.options.optimization.minimize
2528
+ compiler.options.optimization.minimizeOptions
2508
2529
  );
2509
2530
  const terserOptions = minimizeByType.javascript || {
2510
2531
  compress: { passes: 2 }
@@ -2573,10 +2594,9 @@ const applyOptimizationDefaults = (
2573
2594
  }
2574
2595
  if (minifyHtml) {
2575
2596
  minify.push(require("../html/htmlMinify"));
2576
- // `minimize.css` rides along under its own key rather than spread
2577
- // beside the HTML options: the two name some of the same switches
2578
- // (`quotes`, `comments`), and one flat object would hand
2579
- // 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.
2580
2600
  minimizerOptions.push({
2581
2601
  environment: cssEnvironment,
2582
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)) ||