webpack 5.107.1 → 5.108.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 (360) hide show
  1. package/hot/dev-server.js +2 -0
  2. package/lib/APIPlugin.js +8 -4
  3. package/lib/CacheFacade.js +7 -0
  4. package/lib/Chunk.js +4 -0
  5. package/lib/ChunkGraph.js +30 -9
  6. package/lib/CircularModulesPlugin.js +190 -0
  7. package/lib/CleanPlugin.js +2 -1
  8. package/lib/Compilation.js +396 -65
  9. package/lib/Compiler.js +52 -14
  10. package/lib/ConcatenationScope.js +10 -3
  11. package/lib/ContextExclusionPlugin.js +1 -0
  12. package/lib/ContextModule.js +92 -47
  13. package/lib/ContextModuleFactory.js +45 -38
  14. package/lib/ContextReplacementPlugin.js +4 -0
  15. package/lib/DefinePlugin.js +89 -15
  16. package/lib/Dependency.js +111 -7
  17. package/lib/EntryOptionPlugin.js +39 -2
  18. package/lib/EntryPlugin.js +2 -0
  19. package/lib/ExportsInfo.js +314 -73
  20. package/lib/ExternalModule.js +82 -34
  21. package/lib/ExternalModuleFactoryPlugin.js +1 -0
  22. package/lib/ExternalsPlugin.js +1 -0
  23. package/lib/FileSystemInfo.js +173 -23
  24. package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
  25. package/lib/FlagDependencyExportsPlugin.js +23 -0
  26. package/lib/FlagDependencyUsagePlugin.js +87 -5
  27. package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
  28. package/lib/Generator.js +8 -0
  29. package/lib/HotModuleReplacementPlugin.js +65 -28
  30. package/lib/IgnorePlugin.js +1 -0
  31. package/lib/InitFragment.js +5 -0
  32. package/lib/JavascriptMetaInfoPlugin.js +7 -5
  33. package/lib/LazyBarrel.js +361 -0
  34. package/lib/LoaderTargetPlugin.js +1 -0
  35. package/lib/Module.js +21 -42
  36. package/lib/ModuleGraph.js +3 -2
  37. package/lib/ModuleProfile.js +27 -1
  38. package/lib/ModuleTemplate.js +2 -0
  39. package/lib/MultiCompiler.js +16 -0
  40. package/lib/MultiStats.js +1 -0
  41. package/lib/MultiWatching.js +2 -0
  42. package/lib/NodeStuffPlugin.js +22 -17
  43. package/lib/NormalModule.js +557 -77
  44. package/lib/NormalModuleReplacementPlugin.js +2 -0
  45. package/lib/PrefetchPlugin.js +2 -0
  46. package/lib/ProgressPlugin.js +9 -1
  47. package/lib/ProvidePlugin.js +1 -0
  48. package/lib/RawModule.js +20 -16
  49. package/lib/RecordIdsPlugin.js +1 -0
  50. package/lib/RuntimeGlobals.js +5 -0
  51. package/lib/RuntimePlugin.js +58 -26
  52. package/lib/RuntimeTemplate.js +278 -21
  53. package/lib/SelfModuleFactory.js +1 -0
  54. package/lib/SourceMapDevToolPlugin.js +105 -30
  55. package/lib/Stats.js +1 -0
  56. package/lib/Template.js +8 -2
  57. package/lib/TemplatedPathPlugin.js +473 -131
  58. package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
  59. package/lib/WarnDeprecatedOptionPlugin.js +4 -0
  60. package/lib/WarnNoModeSetPlugin.js +1 -0
  61. package/lib/WatchIgnorePlugin.js +1 -0
  62. package/lib/Watching.js +9 -0
  63. package/lib/WebpackOptionsApply.js +50 -5
  64. package/lib/asset/AssetBytesGenerator.js +11 -3
  65. package/lib/asset/AssetGenerator.js +47 -22
  66. package/lib/asset/AssetModule.js +47 -0
  67. package/lib/asset/AssetModulesPlugin.js +14 -14
  68. package/lib/asset/AssetParser.js +2 -2
  69. package/lib/asset/AssetSourceGenerator.js +8 -0
  70. package/lib/asset/RawDataUrlModule.js +12 -13
  71. package/lib/buildChunkGraph.js +88 -9
  72. package/lib/bun/BunTargetPlugin.js +48 -0
  73. package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
  74. package/lib/cache/AddManagedPathsPlugin.js +3 -0
  75. package/lib/cache/IdleFileCachePlugin.js +4 -0
  76. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  77. package/lib/cache/PackFileCacheStrategy.js +1 -0
  78. package/lib/cache/ResolverCachePlugin.js +2 -0
  79. package/lib/cache/getLazyHashedEtag.js +9 -2
  80. package/lib/cache/mergeEtags.js +2 -0
  81. package/lib/cli.js +109 -19
  82. package/lib/config/browserslistTargetHandler.js +99 -0
  83. package/lib/config/defaults.js +147 -7
  84. package/lib/config/defineConfig.js +31 -0
  85. package/lib/config/normalization.js +5 -0
  86. package/lib/config/target.js +181 -2
  87. package/lib/container/ContainerEntryModule.js +15 -14
  88. package/lib/container/ContainerExposedDependency.js +2 -2
  89. package/lib/container/ContainerReferencePlugin.js +1 -1
  90. package/lib/container/FallbackDependency.js +5 -7
  91. package/lib/container/FallbackModule.js +10 -9
  92. package/lib/container/RemoteModule.js +20 -10
  93. package/lib/container/RemoteRuntimeModule.js +14 -12
  94. package/lib/css/CssGenerator.js +353 -327
  95. package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
  96. package/lib/css/CssLoadingRuntimeModule.js +118 -47
  97. package/lib/css/CssModule.js +52 -23
  98. package/lib/css/CssModulesPlugin.js +107 -124
  99. package/lib/css/CssParser.js +2759 -2205
  100. package/lib/css/syntax.js +2859 -0
  101. package/lib/debug/ProfilingPlugin.js +2 -0
  102. package/lib/deno/DenoTargetPlugin.js +47 -0
  103. package/lib/dependencies/AMDDefineDependency.js +22 -17
  104. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
  105. package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
  106. package/lib/dependencies/AMDRequireContextDependency.js +7 -11
  107. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
  108. package/lib/dependencies/AMDRequireDependency.js +24 -20
  109. package/lib/dependencies/CachedConstDependency.js +3 -0
  110. package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
  111. package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
  112. package/lib/dependencies/CommonJsExportsDependency.js +21 -16
  113. package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
  114. package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
  115. package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
  116. package/lib/dependencies/CommonJsPlugin.js +1 -1
  117. package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
  118. package/lib/dependencies/CommonJsRequireDependency.js +42 -11
  119. package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
  120. package/lib/dependencies/ConstDependency.js +16 -11
  121. package/lib/dependencies/ContextDependency.js +4 -0
  122. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
  123. package/lib/dependencies/ContextElementDependency.js +23 -14
  124. package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
  125. package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
  126. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  127. package/lib/dependencies/CssIcssExportDependency.js +512 -574
  128. package/lib/dependencies/CssIcssImportDependency.js +9 -9
  129. package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
  130. package/lib/dependencies/CssImportDependency.js +25 -1
  131. package/lib/dependencies/CssUrlDependency.js +23 -14
  132. package/lib/dependencies/DllEntryDependency.js +9 -13
  133. package/lib/dependencies/ExportBindingInitFragment.js +164 -0
  134. package/lib/dependencies/ExportsInfoDependency.js +12 -12
  135. package/lib/dependencies/ExternalModuleDependency.js +8 -5
  136. package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
  137. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
  138. package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
  139. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
  140. package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
  141. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
  142. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
  143. package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
  144. package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
  145. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
  146. package/lib/dependencies/HarmonyExportInitFragment.js +22 -20
  147. package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
  148. package/lib/dependencies/HarmonyExports.js +4 -1
  149. package/lib/dependencies/HarmonyImportDependency.js +24 -0
  150. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
  151. package/lib/dependencies/HarmonyImportGuard.js +254 -0
  152. package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
  153. package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
  154. package/lib/dependencies/HarmonyLinkingError.js +1 -0
  155. package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
  156. package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +267 -154
  157. package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
  158. package/lib/dependencies/HtmlInlineScriptDependency.js +20 -27
  159. package/lib/dependencies/HtmlInlineStyleDependency.js +62 -11
  160. package/lib/dependencies/HtmlSourceDependency.js +18 -0
  161. package/lib/dependencies/ImportContextDependency.js +5 -9
  162. package/lib/dependencies/ImportDependency.js +44 -2
  163. package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
  164. package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
  165. package/lib/dependencies/ImportMetaPlugin.js +74 -30
  166. package/lib/dependencies/ImportParserPlugin.js +19 -0
  167. package/lib/dependencies/ImportWeakDependency.js +1 -0
  168. package/lib/dependencies/JsonExportsDependency.js +9 -9
  169. package/lib/dependencies/LoaderImportDependency.js +1 -0
  170. package/lib/dependencies/LocalModule.js +11 -12
  171. package/lib/dependencies/LocalModuleDependency.js +11 -13
  172. package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
  173. package/lib/dependencies/ModuleDependency.js +7 -0
  174. package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
  175. package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
  176. package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
  177. package/lib/dependencies/ProvidedDependency.js +31 -27
  178. package/lib/dependencies/PureExpressionDependency.js +7 -9
  179. package/lib/dependencies/RequireEnsureDependency.js +12 -13
  180. package/lib/dependencies/RequireHeaderDependency.js +3 -4
  181. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
  182. package/lib/dependencies/RequireResolveContextDependency.js +7 -11
  183. package/lib/dependencies/RequireResolveDependency.js +1 -0
  184. package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
  185. package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
  186. package/lib/dependencies/StaticExportsDependency.js +10 -10
  187. package/lib/dependencies/SystemPlugin.js +2 -0
  188. package/lib/dependencies/URLContextDependency.js +5 -7
  189. package/lib/dependencies/URLDependency.js +14 -16
  190. package/lib/dependencies/UnsupportedDependency.js +8 -13
  191. package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
  192. package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
  193. package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
  194. package/lib/dependencies/WorkerDependency.js +19 -8
  195. package/lib/dependencies/WorkerPlugin.js +40 -10
  196. package/lib/dependencies/processExportInfo.js +13 -11
  197. package/lib/dll/DelegatedModule.js +29 -15
  198. package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
  199. package/lib/dll/DelegatedPlugin.js +1 -0
  200. package/lib/dll/DllEntryPlugin.js +3 -0
  201. package/lib/dll/DllModule.js +3 -2
  202. package/lib/dll/DllPlugin.js +16 -0
  203. package/lib/dll/DllReferencePlugin.js +3 -0
  204. package/lib/dll/LibManifestPlugin.js +1 -0
  205. package/lib/electron/ElectronTargetPlugin.js +22 -4
  206. package/lib/errors/ConcurrentCompilationError.js +1 -0
  207. package/lib/errors/HookWebpackError.js +11 -13
  208. package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
  209. package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
  210. package/lib/errors/JSONParseError.js +9 -8
  211. package/lib/errors/ModuleBuildError.js +16 -13
  212. package/lib/errors/ModuleDependencyError.js +8 -1
  213. package/lib/errors/ModuleDependencyWarning.js +8 -1
  214. package/lib/errors/ModuleError.js +5 -11
  215. package/lib/errors/ModuleHashingError.js +4 -0
  216. package/lib/errors/ModuleNotFoundError.js +3 -0
  217. package/lib/errors/ModuleParseError.js +5 -11
  218. package/lib/errors/ModuleRestoreError.js +2 -0
  219. package/lib/errors/ModuleStoreError.js +3 -0
  220. package/lib/errors/ModuleWarning.js +7 -11
  221. package/lib/errors/NodeStuffInWebError.js +1 -0
  222. package/lib/errors/NonErrorEmittedError.js +2 -0
  223. package/lib/errors/UnhandledSchemeError.js +1 -0
  224. package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
  225. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
  226. package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
  227. package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
  228. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
  229. package/lib/hmr/LazyCompilationPlugin.js +134 -6
  230. package/lib/html/HtmlGenerator.js +292 -50
  231. package/lib/html/HtmlModule.js +40 -0
  232. package/lib/html/HtmlModulesPlugin.js +287 -60
  233. package/lib/html/HtmlParser.js +1108 -1099
  234. package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
  235. package/lib/ids/IdHelpers.js +4 -2
  236. package/lib/index.js +19 -0
  237. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  238. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
  239. package/lib/javascript/JavascriptGenerator.js +6 -2
  240. package/lib/javascript/JavascriptModule.js +54 -0
  241. package/lib/javascript/JavascriptModulesPlugin.js +257 -102
  242. package/lib/javascript/JavascriptParser.js +286 -159
  243. package/lib/json/JsonModule.js +40 -0
  244. package/lib/json/JsonModulesPlugin.js +7 -0
  245. package/lib/json/JsonParser.js +4 -2
  246. package/lib/library/AssignLibraryPlugin.js +5 -3
  247. package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
  248. package/lib/library/FalseIIFEUmdWarning.js +1 -0
  249. package/lib/library/ModuleLibraryPlugin.js +54 -29
  250. package/lib/library/SystemLibraryPlugin.js +3 -3
  251. package/lib/node/NodeTargetPlugin.js +1 -0
  252. package/lib/node/NodeWatchFileSystem.js +38 -22
  253. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
  254. package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
  255. package/lib/optimize/ConcatenatedModule.js +397 -78
  256. package/lib/optimize/ConstExportsPlugin.js +211 -0
  257. package/lib/optimize/InlineExports.js +178 -0
  258. package/lib/optimize/InnerGraph.js +372 -275
  259. package/lib/optimize/InnerGraphPlugin.js +196 -99
  260. package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
  261. package/lib/optimize/RealContentHashPlugin.js +14 -1
  262. package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
  263. package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
  264. package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
  265. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
  266. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
  267. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
  268. package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
  269. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
  270. package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
  271. package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
  272. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
  273. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
  274. package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
  275. package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
  276. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
  277. package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
  278. package/lib/runtime/WorkerRuntimeModule.js +33 -0
  279. package/lib/schemes/HttpUriPlugin.js +3 -2
  280. package/lib/serialization/AggregateErrorSerializer.js +7 -6
  281. package/lib/serialization/ArraySerializer.js +4 -8
  282. package/lib/serialization/BinaryMiddleware.js +538 -468
  283. package/lib/serialization/DateObjectSerializer.js +2 -2
  284. package/lib/serialization/ErrorObjectSerializer.js +7 -6
  285. package/lib/serialization/MapObjectSerializer.js +5 -9
  286. package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
  287. package/lib/serialization/ObjectMiddleware.js +50 -13
  288. package/lib/serialization/PlainObjectSerializer.js +9 -8
  289. package/lib/serialization/RegExpObjectSerializer.js +2 -2
  290. package/lib/serialization/Serializer.js +1 -0
  291. package/lib/serialization/SetObjectSerializer.js +4 -8
  292. package/lib/sharing/ConsumeSharedModule.js +6 -7
  293. package/lib/sharing/ConsumeSharedPlugin.js +1 -0
  294. package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
  295. package/lib/sharing/ProvideSharedDependency.js +30 -15
  296. package/lib/sharing/ProvideSharedModule.js +30 -11
  297. package/lib/sharing/ProvideSharedPlugin.js +4 -2
  298. package/lib/sharing/SharePlugin.js +3 -0
  299. package/lib/sharing/ShareRuntimeModule.js +18 -16
  300. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  301. package/lib/sharing/utils.js +1 -1
  302. package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
  303. package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
  304. package/lib/stats/StatsFactory.js +11 -9
  305. package/lib/stats/StatsPrinter.js +9 -2
  306. package/lib/url/URLParserPlugin.js +5 -2
  307. package/lib/util/AsyncQueue.js +10 -0
  308. package/lib/util/LazyBucketSortedSet.js +5 -0
  309. package/lib/util/LazySet.js +6 -4
  310. package/lib/util/LocConverter.js +11 -1
  311. package/lib/util/Semaphore.js +1 -0
  312. package/lib/util/SourceProcessor.js +106 -0
  313. package/lib/util/TupleSet.js +1 -0
  314. package/lib/util/WeakTupleMap.js +27 -1
  315. package/lib/util/chainedImports.js +3 -3
  316. package/lib/util/comparators.js +2 -2
  317. package/lib/util/concatenate.js +31 -7
  318. package/lib/util/createHash.js +0 -1
  319. package/lib/util/deterministicGrouping.js +19 -12
  320. package/lib/util/extractSourceMap.js +1 -1
  321. package/lib/util/findGraphRoots.js +2 -0
  322. package/lib/util/fs.js +16 -6
  323. package/lib/util/hash/DebugHash.js +1 -0
  324. package/lib/util/hash/hash-digest.js +24 -15
  325. package/lib/util/identifier.js +7 -0
  326. package/lib/util/internalSerializables.js +11 -2
  327. package/lib/util/magicComment.js +42 -0
  328. package/lib/util/makeSerializable.js +1 -0
  329. package/lib/util/nonNumericOnlyHash.js +30 -1
  330. package/lib/util/property.js +7 -1
  331. package/lib/util/publicPathPlaceholder.js +64 -0
  332. package/lib/util/registerExternalSerializer.js +4 -4
  333. package/lib/wasm-async/AsyncWasmModule.js +77 -0
  334. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
  335. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
  336. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  337. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
  338. package/lib/wasm-sync/SyncWasmModule.js +39 -0
  339. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
  340. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
  341. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
  342. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
  343. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  344. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
  345. package/lib/wasm-sync/WebAssemblyParser.js +7 -3
  346. package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
  347. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
  348. package/package.json +36 -28
  349. package/schemas/WebpackOptions.check.js +1 -1
  350. package/schemas/WebpackOptions.json +212 -3
  351. package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
  352. package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
  353. package/schemas/plugins/HtmlParserOptions.check.js +6 -0
  354. package/schemas/plugins/HtmlParserOptions.json +3 -0
  355. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
  356. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  357. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  358. package/types.d.ts +1592 -314
  359. package/lib/css/walkCssTokens.js +0 -2020
  360. package/lib/util/AppendOnlyStackedSet.js +0 -93
@@ -103,6 +103,7 @@ const {
103
103
  * devtoolNamespace: NonNullable<Output["devtoolNamespace"]>,
104
104
  * publicPath: NonNullable<Output["publicPath"]>,
105
105
  * workerPublicPath: NonNullable<Output["workerPublicPath"]>,
106
+ * workerChunkFilename: NonNullable<Output["workerChunkFilename"]>,
106
107
  * workerWasmLoading: NonNullable<Output["workerWasmLoading"]>,
107
108
  * workerChunkLoading: NonNullable<Output["workerChunkLoading"]>,
108
109
  * chunkFormat: NonNullable<Output["chunkFormat"]>,
@@ -123,6 +124,7 @@ const {
123
124
  * compareBeforeEmit: NonNullable<Output["compareBeforeEmit"]>,
124
125
  * strictModuleErrorHandling: NonNullable<Output["strictModuleErrorHandling"]>,
125
126
  * strictModuleExceptionHandling: NonNullable<Output["strictModuleExceptionHandling"]>,
127
+ * strictModuleResolution: NonNullable<Output["strictModuleResolution"]>,
126
128
  * importFunctionName: NonNullable<Output["importFunctionName"]>,
127
129
  * importMetaName: NonNullable<Output["importMetaName"]>,
128
130
  * environment: RecursiveNonNullable<Output["environment"]>,
@@ -160,6 +162,7 @@ const {
160
162
  * usedExports: NonNullable<Optimization["usedExports"]>,
161
163
  * mangleExports: NonNullable<Optimization["mangleExports"]>,
162
164
  * innerGraph: NonNullable<Optimization["innerGraph"]>,
165
+ * inlineExports: NonNullable<Optimization["inlineExports"]>,
163
166
  * concatenateModules: NonNullable<Optimization["concatenateModules"]>,
164
167
  * avoidEntryIife: NonNullable<Optimization["avoidEntryIife"]>,
165
168
  * emitOnErrors: NonNullable<Optimization["emitOnErrors"]>,
@@ -525,6 +528,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
525
528
  css:
526
529
  /** @type {NonNullable<ExperimentsNormalized["css"]>} */
527
530
  (options.experiments.css),
531
+ html:
532
+ /** @type {NonNullable<ExperimentsNormalized["html"]>} */
533
+ (options.experiments.html),
528
534
  typescript:
529
535
  /** @type {NonNullable<ExperimentsNormalized["typescript"]>} */
530
536
  (options.experiments.typescript)
@@ -546,8 +552,13 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
546
552
  browser: targetProperties.browser,
547
553
  webworker: targetProperties.webworker,
548
554
  node: targetProperties.node,
555
+ deno: targetProperties.deno,
556
+ bun: targetProperties.bun,
549
557
  nwjs: targetProperties.nwjs,
550
- electron: targetProperties.electron
558
+ electron: targetProperties.electron,
559
+ // spans both web and node (target "universal" or ["web", "node"])
560
+ universal:
561
+ targetProperties.node === null && targetProperties.web === null
551
562
  }
552
563
  };
553
564
  };
@@ -570,7 +581,19 @@ const applyExperimentsDefaults = (
570
581
  // TODO do we need sync web assembly in webpack@6?
571
582
  D(experiments, "syncWebAssembly", false);
572
583
  D(experiments, "asyncWebAssembly", experiments.futureDefaults);
573
- D(experiments, "outputModule", false);
584
+ // the universal target (web + node, neither specific) only works as ESM
585
+ const universal =
586
+ Boolean(targetProperties) &&
587
+ /** @type {TargetProperties} */ (targetProperties).node === null &&
588
+ /** @type {TargetProperties} */ (targetProperties).web === null;
589
+ // the deno and bun targets only emit ECMAScript modules
590
+ const deno =
591
+ Boolean(targetProperties) &&
592
+ /** @type {TargetProperties} */ (targetProperties).deno === true;
593
+ const bun =
594
+ Boolean(targetProperties) &&
595
+ /** @type {TargetProperties} */ (targetProperties).bun === true;
596
+ D(experiments, "outputModule", universal || deno || bun);
574
597
  D(experiments, "lazyCompilation", undefined);
575
598
  D(experiments, "buildHttp", undefined);
576
599
  D(experiments, "cacheUnaffected", experiments.futureDefaults);
@@ -1090,6 +1113,18 @@ const applyModuleDefaults = (
1090
1113
  // modules (including imported ones); `extract: false` disables it
1091
1114
  // everywhere.
1092
1115
  F(module.generator, HTML_MODULE_TYPE, () => ({}));
1116
+ // `module.parser.html.sources` defaults to `true` — HtmlParser uses
1117
+ // the built-in source list to extract URL-like attributes (`<img
1118
+ // src>`, `<link href>`, `<script src>`, …) as webpack dependencies.
1119
+ // Users may pass `false` to disable extraction entirely or an array
1120
+ // (with `"..."` to include the defaults) to customize it.
1121
+ F(module.parser, HTML_MODULE_TYPE, () => ({}));
1122
+ D(
1123
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[HTML_MODULE_TYPE]>} */
1124
+ (module.parser[HTML_MODULE_TYPE]),
1125
+ "sources",
1126
+ true
1127
+ );
1093
1128
  }
1094
1129
 
1095
1130
  A(module, "defaultRules", () => {
@@ -1268,6 +1303,18 @@ const applyModuleDefaults = (
1268
1303
  type: HTML_MODULE_TYPE,
1269
1304
  resolve
1270
1305
  });
1306
+ // `<iframe srcdoc>` content is fed back through the HTML pipeline as a
1307
+ // `data:text/html` module. `extract: "inline"` exposes the processed
1308
+ // HTML on the `html` codegen channel that `HtmlInlineHtmlDependency.
1309
+ // Template` reads back into the attribute, without emitting a standalone
1310
+ // `.html` file (the module is never a page on its own).
1311
+ rules.push({
1312
+ dependency: "html-srcdoc",
1313
+ generator: {
1314
+ extract: "inline"
1315
+ },
1316
+ resolve
1317
+ });
1271
1318
  if (css) {
1272
1319
  // Inline `<style>` content in an HTML module is fed into the
1273
1320
  // CSS pipeline as a `data:text/css` virtual module. We force
@@ -1282,6 +1329,16 @@ const applyModuleDefaults = (
1282
1329
  },
1283
1330
  resolve
1284
1331
  });
1332
+ // A `style="..."` attribute is a CSS block's contents, not a
1333
+ // stylesheet, so parse it as one (`as: "block-contents"`).
1334
+ rules.push({
1335
+ dependency: "html-style-attribute",
1336
+ parser: {
1337
+ exportType: "text",
1338
+ as: "block-contents"
1339
+ },
1340
+ resolve
1341
+ });
1285
1342
  }
1286
1343
  }
1287
1344
 
@@ -1452,6 +1509,17 @@ const applyOutputDefaults = (
1452
1509
  "globalThis",
1453
1510
  () => /** @type {boolean | undefined} */ (tp && tp.globalThis)
1454
1511
  );
1512
+ F(
1513
+ environment,
1514
+ "symbol",
1515
+ () => tp && optimistic(/** @type {boolean | undefined} */ (tp.symbol))
1516
+ );
1517
+ F(
1518
+ environment,
1519
+ "hasOwn",
1520
+ // No optimistic, because it is new
1521
+ () => tp && /** @type {boolean | undefined} */ (tp.hasOwn)
1522
+ );
1455
1523
  F(
1456
1524
  environment,
1457
1525
  "bigIntLiteral",
@@ -1463,6 +1531,22 @@ const applyOutputDefaults = (
1463
1531
  "const",
1464
1532
  () => tp && optimistic(/** @type {boolean | undefined} */ (tp.const))
1465
1533
  );
1534
+ // `let` was added after `const`; targets predating it report only `const`,
1535
+ // so fall back to `const` when `let` is unreported (undefined). Targets that
1536
+ // do report `let` (browserslist, built-ins) keep their own accurate value.
1537
+ F(environment, "let", () =>
1538
+ conditionallyOptimistic(
1539
+ /** @type {boolean | undefined} */ (tp && tp.let),
1540
+ environment.const
1541
+ )
1542
+ );
1543
+ F(
1544
+ environment,
1545
+ "logicalAssignment",
1546
+ () =>
1547
+ // No optimistic, because it is new
1548
+ tp && /** @type {boolean | undefined} */ (tp.logicalAssignment)
1549
+ );
1466
1550
  F(
1467
1551
  environment,
1468
1552
  "methodShorthand",
@@ -1498,6 +1582,11 @@ const applyOutputDefaults = (
1498
1582
  () =>
1499
1583
  tp && optimistic(/** @type {boolean | undefined} */ (tp.optionalChaining))
1500
1584
  );
1585
+ F(
1586
+ environment,
1587
+ "spread",
1588
+ () => tp && optimistic(/** @type {boolean | undefined} */ (tp.spread))
1589
+ );
1501
1590
  F(
1502
1591
  environment,
1503
1592
  "nodePrefixForCoreModules",
@@ -1514,6 +1603,13 @@ const applyOutputDefaults = (
1514
1603
  // No optimistic, because it is new
1515
1604
  tp && /** @type {boolean | undefined} */ (tp.importMetaDirnameAndFilename)
1516
1605
  );
1606
+ F(
1607
+ environment,
1608
+ "nodeBuiltinModuleGetter",
1609
+ () =>
1610
+ // No optimistic, because it is new
1611
+ tp && /** @type {boolean | undefined} */ (tp.nodeBuiltinModuleGetter)
1612
+ );
1517
1613
  F(
1518
1614
  environment,
1519
1615
  "templateLiteral",
@@ -1619,6 +1715,7 @@ const applyOutputDefaults = (
1619
1715
  }
1620
1716
  return "[name].html";
1621
1717
  });
1718
+ D(output, "html", false);
1622
1719
  D(output, "assetModuleFilename", "[hash][ext][query][fragment]");
1623
1720
  D(output, "webassemblyModuleFilename", "[hash].module.wasm");
1624
1721
  D(output, "compareBeforeEmit", true);
@@ -1633,7 +1730,10 @@ const applyOutputDefaults = (
1633
1730
  if (tp.global) return "global";
1634
1731
  if (tp.globalThis) return "globalThis";
1635
1732
  // For universal target (i.e. code can be run in browser/node/worker etc.)
1636
- if (tp.web === null && tp.node === null && tp.module) return "globalThis";
1733
+ // `tp.module` is unset for a version-less universal target, so key off ESM output
1734
+ if (tp.web === null && tp.node === null && output.module) {
1735
+ return "globalThis";
1736
+ }
1637
1737
  }
1638
1738
  return "self";
1639
1739
  });
@@ -1700,6 +1800,13 @@ const applyOutputDefaults = (
1700
1800
  }
1701
1801
  return false;
1702
1802
  });
1803
+ F(
1804
+ output,
1805
+ "workerChunkFilename",
1806
+ () =>
1807
+ /** @type {NonNullable<Output["workerChunkFilename"]>} */
1808
+ (output.chunkFilename)
1809
+ );
1703
1810
  F(output, "workerChunkLoading", () => {
1704
1811
  if (tp) {
1705
1812
  switch (output.chunkFormat) {
@@ -1781,6 +1888,7 @@ const applyOutputDefaults = (
1781
1888
  D(output, "hashDigestLength", futureDefaults ? 16 : 20);
1782
1889
  D(output, "strictModuleErrorHandling", false);
1783
1890
  D(output, "strictModuleExceptionHandling", false);
1891
+ F(output, "strictModuleResolution", () => development);
1784
1892
 
1785
1893
  const { trustedTypes } = output;
1786
1894
  if (trustedTypes) {
@@ -1888,7 +1996,25 @@ const applyExternalsPresetsDefaults = (
1888
1996
  externalsPresets,
1889
1997
  "node",
1890
1998
  /** @type {boolean | undefined} */
1891
- (targetProperties && (targetProperties.node || isUniversal("node")))
1999
+ (
2000
+ targetProperties &&
2001
+ ((targetProperties.node &&
2002
+ !targetProperties.deno &&
2003
+ !targetProperties.bun) ||
2004
+ isUniversal("node"))
2005
+ )
2006
+ );
2007
+ D(
2008
+ externalsPresets,
2009
+ "deno",
2010
+ /** @type {boolean | undefined} */
2011
+ (Boolean(targetProperties && targetProperties.deno))
2012
+ );
2013
+ D(
2014
+ externalsPresets,
2015
+ "bun",
2016
+ /** @type {boolean | undefined} */
2017
+ (Boolean(targetProperties && targetProperties.bun))
1892
2018
  );
1893
2019
  D(
1894
2020
  externalsPresets,
@@ -1952,6 +2078,8 @@ const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
1952
2078
  return "electron";
1953
2079
  }
1954
2080
  if (targetProperties.nwjs) return "nwjs";
2081
+ if (targetProperties.deno) return "deno";
2082
+ if (targetProperties.bun) return "bun";
1955
2083
  if (targetProperties.node) return "node";
1956
2084
  if (targetProperties.web) return "web";
1957
2085
  }
@@ -2051,6 +2179,7 @@ const applyOptimizationDefaults = (
2051
2179
  D(optimization, "providedExports", true);
2052
2180
  D(optimization, "usedExports", production);
2053
2181
  D(optimization, "innerGraph", production);
2182
+ D(optimization, "inlineExports", production);
2054
2183
  D(optimization, "mangleExports", production);
2055
2184
  D(optimization, "concatenateModules", production);
2056
2185
  D(optimization, "avoidEntryIife", production);
@@ -2064,8 +2193,8 @@ const applyOptimizationDefaults = (
2064
2193
  A(optimization, "minimizer", () => [
2065
2194
  {
2066
2195
  apply: (compiler) => {
2067
- // Lazy load the Terser plugin
2068
- const TerserPlugin = require("terser-webpack-plugin");
2196
+ // Lazy load the minimizer plugin
2197
+ const TerserPlugin = require("minimizer-webpack-plugin");
2069
2198
 
2070
2199
  new TerserPlugin({
2071
2200
  terserOptions: {
@@ -2125,6 +2254,7 @@ const applyOptimizationDefaults = (
2125
2254
  * @param {TargetProperties | false} options.targetProperties target properties
2126
2255
  * @param {Mode} options.mode mode
2127
2256
  * @param {boolean} options.css is css enabled
2257
+ * @param {boolean} options.html is html enabled
2128
2258
  * @param {boolean} options.typescript is typescript enabled
2129
2259
  * @returns {ResolveOptions} resolve options
2130
2260
  */
@@ -2134,6 +2264,7 @@ const getResolveDefaults = ({
2134
2264
  targetProperties,
2135
2265
  mode,
2136
2266
  css,
2267
+ html,
2137
2268
  typescript
2138
2269
  }) => {
2139
2270
  /** @type {string[]} */
@@ -2142,6 +2273,8 @@ const getResolveDefaults = ({
2142
2273
  conditions.push(mode === "development" ? "development" : "production");
2143
2274
 
2144
2275
  if (targetProperties) {
2276
+ if (targetProperties.deno) conditions.push("deno");
2277
+ if (targetProperties.bun) conditions.push("bun");
2145
2278
  if (targetProperties.webworker) conditions.push("worker");
2146
2279
  if (targetProperties.node) conditions.push("node");
2147
2280
  if (targetProperties.web) conditions.push("browser");
@@ -2153,6 +2286,13 @@ const getResolveDefaults = ({
2153
2286
  ? [".ts", ".js", ".json", ".wasm"]
2154
2287
  : [".js", ".json", ".wasm"];
2155
2288
 
2289
+ // HTML-first when enabled: `.html` outranks `.js`, `.css` is the last fallback.
2290
+ const esmResolveExtensions = [
2291
+ ...(html ? [".html"] : []),
2292
+ ...jsExtensions,
2293
+ ...(css ? [".css"] : [])
2294
+ ];
2295
+
2156
2296
  const tp = targetProperties;
2157
2297
  const browserField =
2158
2298
  tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer));
@@ -2186,7 +2326,7 @@ const getResolveDefaults = ({
2186
2326
  "module",
2187
2327
  "..."
2188
2328
  ],
2189
- extensions: [...jsExtensions]
2329
+ extensions: [...esmResolveExtensions]
2190
2330
  });
2191
2331
 
2192
2332
  /** @type {() => ResolveOptions} */
@@ -0,0 +1,31 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Alexander Akait @alexander-akait
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} Configuration */
9
+ /** @typedef {import("../MultiCompiler").MultiWebpackOptions} MultiConfiguration */
10
+
11
+ /**
12
+ * @template T
13
+ * @typedef {T | Promise<T>} MaybePromise
14
+ */
15
+
16
+ /**
17
+ * Function style configuration, called with the `--env` values and CLI arguments.
18
+ * @typedef {(env: Record<string, EXPECTED_ANY>, argv: Record<string, EXPECTED_ANY>) => MaybePromise<Configuration | MultiConfiguration>} ConfigurationFactory
19
+ */
20
+
21
+ /** @typedef {MaybePromise<Configuration | MultiConfiguration | ConfigurationFactory | ConfigurationFactory[]>} DefineConfigInput */
22
+
23
+ /**
24
+ * A type helper for authoring configuration files, no-op at runtime.
25
+ * @template {DefineConfigInput} T
26
+ * @param {T} config webpack configuration
27
+ * @returns {T} the same configuration
28
+ */
29
+ const defineConfig = (config) => config;
30
+
31
+ module.exports = defineConfig;
@@ -368,6 +368,7 @@ const getNormalizedWebpackOptions = (config) => ({
368
368
  hotUpdateChunkFilename: output.hotUpdateChunkFilename,
369
369
  hotUpdateGlobal: output.hotUpdateGlobal,
370
370
  hotUpdateMainFilename: output.hotUpdateMainFilename,
371
+ html: output.html,
371
372
  htmlChunkFilename: output.htmlChunkFilename,
372
373
  htmlFilename: output.htmlFilename,
373
374
  ignoreBrowserWarnings: output.ignoreBrowserWarnings,
@@ -407,6 +408,7 @@ const getNormalizedWebpackOptions = (config) => ({
407
408
  sourcePrefix: output.sourcePrefix,
408
409
  strictModuleErrorHandling: output.strictModuleErrorHandling,
409
410
  strictModuleExceptionHandling: output.strictModuleExceptionHandling,
411
+ strictModuleResolution: output.strictModuleResolution,
410
412
  trustedTypes: optionalNestedConfig(
411
413
  output.trustedTypes,
412
414
  (trustedTypes) => {
@@ -421,6 +423,7 @@ const getNormalizedWebpackOptions = (config) => ({
421
423
  wasmLoading: output.wasmLoading,
422
424
  webassemblyModuleFilename: output.webassemblyModuleFilename,
423
425
  workerPublicPath: output.workerPublicPath,
426
+ workerChunkFilename: output.workerChunkFilename,
424
427
  workerChunkLoading: output.workerChunkLoading,
425
428
  workerWasmLoading: output.workerWasmLoading
426
429
  };
@@ -551,6 +554,7 @@ const getNormalizedEntryStatic = (entry) => {
551
554
  (Array.isArray(value.import) ? value.import : [value.import])
552
555
  ),
553
556
  filename: value.filename,
557
+ html: value.html,
554
558
  layer: value.layer,
555
559
  runtime: value.runtime,
556
560
  baseUri: value.baseUri,
@@ -558,6 +562,7 @@ const getNormalizedEntryStatic = (entry) => {
558
562
  chunkLoading: value.chunkLoading,
559
563
  asyncChunks: value.asyncChunks,
560
564
  wasmLoading: value.wasmLoading,
565
+ worker: value.worker,
561
566
  dependOn:
562
567
  /** @type {EntryDescriptionNormalized["dependOn"]} */
563
568
  (