webpack 5.107.2 → 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 (357) 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 +25 -11
  10. package/lib/ConcatenationScope.js +10 -3
  11. package/lib/ContextExclusionPlugin.js +1 -0
  12. package/lib/ContextModule.js +92 -47
  13. package/lib/ContextReplacementPlugin.js +4 -0
  14. package/lib/DefinePlugin.js +89 -15
  15. package/lib/Dependency.js +111 -7
  16. package/lib/EntryOptionPlugin.js +39 -2
  17. package/lib/EntryPlugin.js +2 -0
  18. package/lib/ExportsInfo.js +314 -73
  19. package/lib/ExternalModule.js +82 -34
  20. package/lib/ExternalModuleFactoryPlugin.js +1 -0
  21. package/lib/ExternalsPlugin.js +1 -0
  22. package/lib/FileSystemInfo.js +173 -23
  23. package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
  24. package/lib/FlagDependencyExportsPlugin.js +23 -0
  25. package/lib/FlagDependencyUsagePlugin.js +87 -5
  26. package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
  27. package/lib/Generator.js +8 -0
  28. package/lib/HotModuleReplacementPlugin.js +65 -28
  29. package/lib/IgnorePlugin.js +1 -0
  30. package/lib/InitFragment.js +5 -0
  31. package/lib/JavascriptMetaInfoPlugin.js +7 -5
  32. package/lib/LazyBarrel.js +361 -0
  33. package/lib/LoaderTargetPlugin.js +1 -0
  34. package/lib/Module.js +21 -42
  35. package/lib/ModuleGraph.js +3 -2
  36. package/lib/ModuleProfile.js +27 -1
  37. package/lib/ModuleTemplate.js +2 -0
  38. package/lib/MultiCompiler.js +2 -0
  39. package/lib/MultiStats.js +1 -0
  40. package/lib/MultiWatching.js +2 -0
  41. package/lib/NodeStuffPlugin.js +22 -17
  42. package/lib/NormalModule.js +142 -80
  43. package/lib/NormalModuleReplacementPlugin.js +2 -0
  44. package/lib/PrefetchPlugin.js +2 -0
  45. package/lib/ProgressPlugin.js +8 -0
  46. package/lib/ProvidePlugin.js +1 -0
  47. package/lib/RawModule.js +20 -16
  48. package/lib/RecordIdsPlugin.js +1 -0
  49. package/lib/RuntimeGlobals.js +5 -0
  50. package/lib/RuntimePlugin.js +58 -26
  51. package/lib/RuntimeTemplate.js +278 -21
  52. package/lib/SelfModuleFactory.js +1 -0
  53. package/lib/SourceMapDevToolPlugin.js +3 -5
  54. package/lib/Stats.js +1 -0
  55. package/lib/Template.js +8 -2
  56. package/lib/TemplatedPathPlugin.js +473 -131
  57. package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
  58. package/lib/WarnDeprecatedOptionPlugin.js +4 -0
  59. package/lib/WarnNoModeSetPlugin.js +1 -0
  60. package/lib/WatchIgnorePlugin.js +1 -0
  61. package/lib/Watching.js +9 -0
  62. package/lib/WebpackOptionsApply.js +50 -5
  63. package/lib/asset/AssetBytesGenerator.js +11 -3
  64. package/lib/asset/AssetGenerator.js +47 -22
  65. package/lib/asset/AssetModule.js +47 -0
  66. package/lib/asset/AssetModulesPlugin.js +14 -14
  67. package/lib/asset/AssetParser.js +2 -2
  68. package/lib/asset/AssetSourceGenerator.js +8 -0
  69. package/lib/asset/RawDataUrlModule.js +12 -13
  70. package/lib/buildChunkGraph.js +64 -7
  71. package/lib/bun/BunTargetPlugin.js +48 -0
  72. package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
  73. package/lib/cache/AddManagedPathsPlugin.js +3 -0
  74. package/lib/cache/IdleFileCachePlugin.js +4 -0
  75. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  76. package/lib/cache/PackFileCacheStrategy.js +1 -0
  77. package/lib/cache/ResolverCachePlugin.js +2 -0
  78. package/lib/cache/mergeEtags.js +2 -0
  79. package/lib/cli.js +109 -19
  80. package/lib/config/browserslistTargetHandler.js +99 -0
  81. package/lib/config/defaults.js +147 -7
  82. package/lib/config/defineConfig.js +31 -0
  83. package/lib/config/normalization.js +5 -0
  84. package/lib/config/target.js +181 -2
  85. package/lib/container/ContainerEntryModule.js +15 -14
  86. package/lib/container/ContainerExposedDependency.js +2 -2
  87. package/lib/container/ContainerReferencePlugin.js +1 -1
  88. package/lib/container/FallbackDependency.js +5 -7
  89. package/lib/container/FallbackModule.js +10 -9
  90. package/lib/container/RemoteModule.js +20 -10
  91. package/lib/container/RemoteRuntimeModule.js +14 -12
  92. package/lib/css/CssGenerator.js +353 -327
  93. package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
  94. package/lib/css/CssLoadingRuntimeModule.js +118 -47
  95. package/lib/css/CssModule.js +52 -23
  96. package/lib/css/CssModulesPlugin.js +107 -124
  97. package/lib/css/CssParser.js +2759 -2205
  98. package/lib/css/syntax.js +2859 -0
  99. package/lib/debug/ProfilingPlugin.js +2 -0
  100. package/lib/deno/DenoTargetPlugin.js +47 -0
  101. package/lib/dependencies/AMDDefineDependency.js +22 -17
  102. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
  103. package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
  104. package/lib/dependencies/AMDRequireContextDependency.js +7 -11
  105. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
  106. package/lib/dependencies/AMDRequireDependency.js +24 -20
  107. package/lib/dependencies/CachedConstDependency.js +3 -0
  108. package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
  109. package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
  110. package/lib/dependencies/CommonJsExportsDependency.js +21 -16
  111. package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
  112. package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
  113. package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
  114. package/lib/dependencies/CommonJsPlugin.js +1 -1
  115. package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
  116. package/lib/dependencies/CommonJsRequireDependency.js +42 -11
  117. package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
  118. package/lib/dependencies/ConstDependency.js +16 -11
  119. package/lib/dependencies/ContextDependency.js +4 -0
  120. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
  121. package/lib/dependencies/ContextElementDependency.js +23 -14
  122. package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
  123. package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
  124. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  125. package/lib/dependencies/CssIcssExportDependency.js +512 -574
  126. package/lib/dependencies/CssIcssImportDependency.js +9 -9
  127. package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
  128. package/lib/dependencies/CssImportDependency.js +25 -1
  129. package/lib/dependencies/CssUrlDependency.js +23 -14
  130. package/lib/dependencies/DllEntryDependency.js +9 -13
  131. package/lib/dependencies/ExportBindingInitFragment.js +164 -0
  132. package/lib/dependencies/ExportsInfoDependency.js +12 -12
  133. package/lib/dependencies/ExternalModuleDependency.js +8 -5
  134. package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
  135. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
  136. package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
  137. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
  138. package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
  139. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
  140. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
  141. package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
  142. package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
  143. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
  144. package/lib/dependencies/HarmonyExportInitFragment.js +18 -15
  145. package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
  146. package/lib/dependencies/HarmonyExports.js +4 -1
  147. package/lib/dependencies/HarmonyImportDependency.js +24 -0
  148. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
  149. package/lib/dependencies/HarmonyImportGuard.js +254 -0
  150. package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
  151. package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
  152. package/lib/dependencies/HarmonyLinkingError.js +1 -0
  153. package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
  154. package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +261 -109
  155. package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
  156. package/lib/dependencies/HtmlInlineScriptDependency.js +17 -13
  157. package/lib/dependencies/HtmlInlineStyleDependency.js +45 -11
  158. package/lib/dependencies/ImportContextDependency.js +5 -9
  159. package/lib/dependencies/ImportDependency.js +44 -2
  160. package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
  161. package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
  162. package/lib/dependencies/ImportMetaPlugin.js +74 -30
  163. package/lib/dependencies/ImportParserPlugin.js +19 -0
  164. package/lib/dependencies/ImportWeakDependency.js +1 -0
  165. package/lib/dependencies/JsonExportsDependency.js +9 -9
  166. package/lib/dependencies/LoaderImportDependency.js +1 -0
  167. package/lib/dependencies/LocalModule.js +11 -12
  168. package/lib/dependencies/LocalModuleDependency.js +11 -13
  169. package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
  170. package/lib/dependencies/ModuleDependency.js +7 -0
  171. package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
  172. package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
  173. package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
  174. package/lib/dependencies/ProvidedDependency.js +31 -27
  175. package/lib/dependencies/PureExpressionDependency.js +7 -9
  176. package/lib/dependencies/RequireEnsureDependency.js +12 -13
  177. package/lib/dependencies/RequireHeaderDependency.js +3 -4
  178. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
  179. package/lib/dependencies/RequireResolveContextDependency.js +7 -11
  180. package/lib/dependencies/RequireResolveDependency.js +1 -0
  181. package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
  182. package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
  183. package/lib/dependencies/StaticExportsDependency.js +10 -10
  184. package/lib/dependencies/SystemPlugin.js +2 -0
  185. package/lib/dependencies/URLContextDependency.js +5 -7
  186. package/lib/dependencies/URLDependency.js +14 -16
  187. package/lib/dependencies/UnsupportedDependency.js +8 -13
  188. package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
  189. package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
  190. package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
  191. package/lib/dependencies/WorkerDependency.js +19 -8
  192. package/lib/dependencies/WorkerPlugin.js +22 -6
  193. package/lib/dependencies/processExportInfo.js +13 -11
  194. package/lib/dll/DelegatedModule.js +29 -15
  195. package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
  196. package/lib/dll/DelegatedPlugin.js +1 -0
  197. package/lib/dll/DllEntryPlugin.js +3 -0
  198. package/lib/dll/DllModule.js +3 -2
  199. package/lib/dll/DllPlugin.js +16 -0
  200. package/lib/dll/DllReferencePlugin.js +3 -0
  201. package/lib/dll/LibManifestPlugin.js +1 -0
  202. package/lib/electron/ElectronTargetPlugin.js +22 -4
  203. package/lib/errors/ConcurrentCompilationError.js +1 -0
  204. package/lib/errors/HookWebpackError.js +11 -13
  205. package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
  206. package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
  207. package/lib/errors/JSONParseError.js +9 -8
  208. package/lib/errors/ModuleBuildError.js +16 -13
  209. package/lib/errors/ModuleDependencyError.js +8 -1
  210. package/lib/errors/ModuleDependencyWarning.js +8 -1
  211. package/lib/errors/ModuleError.js +5 -11
  212. package/lib/errors/ModuleHashingError.js +4 -0
  213. package/lib/errors/ModuleNotFoundError.js +3 -0
  214. package/lib/errors/ModuleParseError.js +5 -11
  215. package/lib/errors/ModuleRestoreError.js +2 -0
  216. package/lib/errors/ModuleStoreError.js +3 -0
  217. package/lib/errors/ModuleWarning.js +7 -11
  218. package/lib/errors/NodeStuffInWebError.js +1 -0
  219. package/lib/errors/NonErrorEmittedError.js +2 -0
  220. package/lib/errors/UnhandledSchemeError.js +1 -0
  221. package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
  222. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
  223. package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
  224. package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
  225. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
  226. package/lib/hmr/LazyCompilationPlugin.js +30 -6
  227. package/lib/html/HtmlGenerator.js +217 -23
  228. package/lib/html/HtmlModule.js +40 -0
  229. package/lib/html/HtmlModulesPlugin.js +219 -55
  230. package/lib/html/HtmlParser.js +1108 -1099
  231. package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
  232. package/lib/ids/IdHelpers.js +4 -2
  233. package/lib/index.js +19 -0
  234. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  235. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
  236. package/lib/javascript/JavascriptGenerator.js +6 -2
  237. package/lib/javascript/JavascriptModule.js +54 -0
  238. package/lib/javascript/JavascriptModulesPlugin.js +257 -102
  239. package/lib/javascript/JavascriptParser.js +285 -158
  240. package/lib/json/JsonModule.js +40 -0
  241. package/lib/json/JsonModulesPlugin.js +7 -0
  242. package/lib/json/JsonParser.js +4 -2
  243. package/lib/library/AssignLibraryPlugin.js +5 -3
  244. package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
  245. package/lib/library/FalseIIFEUmdWarning.js +1 -0
  246. package/lib/library/ModuleLibraryPlugin.js +24 -5
  247. package/lib/library/SystemLibraryPlugin.js +3 -3
  248. package/lib/node/NodeTargetPlugin.js +1 -0
  249. package/lib/node/NodeWatchFileSystem.js +1 -0
  250. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
  251. package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
  252. package/lib/optimize/ConcatenatedModule.js +395 -77
  253. package/lib/optimize/ConstExportsPlugin.js +211 -0
  254. package/lib/optimize/InlineExports.js +178 -0
  255. package/lib/optimize/InnerGraph.js +372 -275
  256. package/lib/optimize/InnerGraphPlugin.js +196 -99
  257. package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
  258. package/lib/optimize/RealContentHashPlugin.js +14 -1
  259. package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
  260. package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
  261. package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
  262. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
  263. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
  264. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
  265. package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
  266. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
  267. package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
  268. package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
  269. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
  270. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
  271. package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
  272. package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
  273. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
  274. package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
  275. package/lib/runtime/WorkerRuntimeModule.js +33 -0
  276. package/lib/schemes/HttpUriPlugin.js +3 -2
  277. package/lib/serialization/AggregateErrorSerializer.js +7 -6
  278. package/lib/serialization/ArraySerializer.js +4 -8
  279. package/lib/serialization/BinaryMiddleware.js +538 -468
  280. package/lib/serialization/DateObjectSerializer.js +2 -2
  281. package/lib/serialization/ErrorObjectSerializer.js +7 -6
  282. package/lib/serialization/MapObjectSerializer.js +5 -9
  283. package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
  284. package/lib/serialization/ObjectMiddleware.js +50 -13
  285. package/lib/serialization/PlainObjectSerializer.js +9 -8
  286. package/lib/serialization/RegExpObjectSerializer.js +2 -2
  287. package/lib/serialization/Serializer.js +1 -0
  288. package/lib/serialization/SetObjectSerializer.js +4 -8
  289. package/lib/sharing/ConsumeSharedModule.js +6 -7
  290. package/lib/sharing/ConsumeSharedPlugin.js +1 -0
  291. package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
  292. package/lib/sharing/ProvideSharedDependency.js +30 -15
  293. package/lib/sharing/ProvideSharedModule.js +30 -11
  294. package/lib/sharing/ProvideSharedPlugin.js +4 -2
  295. package/lib/sharing/SharePlugin.js +3 -0
  296. package/lib/sharing/ShareRuntimeModule.js +18 -16
  297. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  298. package/lib/sharing/utils.js +1 -1
  299. package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
  300. package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
  301. package/lib/stats/StatsFactory.js +11 -9
  302. package/lib/stats/StatsPrinter.js +9 -2
  303. package/lib/url/URLParserPlugin.js +5 -2
  304. package/lib/util/AsyncQueue.js +10 -0
  305. package/lib/util/LazyBucketSortedSet.js +5 -0
  306. package/lib/util/LazySet.js +6 -4
  307. package/lib/util/LocConverter.js +11 -1
  308. package/lib/util/Semaphore.js +1 -0
  309. package/lib/util/SourceProcessor.js +106 -0
  310. package/lib/util/TupleSet.js +1 -0
  311. package/lib/util/WeakTupleMap.js +27 -1
  312. package/lib/util/chainedImports.js +3 -3
  313. package/lib/util/comparators.js +2 -2
  314. package/lib/util/concatenate.js +31 -7
  315. package/lib/util/createHash.js +0 -1
  316. package/lib/util/deterministicGrouping.js +19 -12
  317. package/lib/util/extractSourceMap.js +1 -1
  318. package/lib/util/findGraphRoots.js +2 -0
  319. package/lib/util/fs.js +10 -5
  320. package/lib/util/hash/DebugHash.js +1 -0
  321. package/lib/util/hash/hash-digest.js +24 -15
  322. package/lib/util/identifier.js +7 -0
  323. package/lib/util/internalSerializables.js +11 -2
  324. package/lib/util/magicComment.js +42 -0
  325. package/lib/util/makeSerializable.js +1 -0
  326. package/lib/util/nonNumericOnlyHash.js +30 -1
  327. package/lib/util/property.js +7 -1
  328. package/lib/util/publicPathPlaceholder.js +64 -0
  329. package/lib/util/registerExternalSerializer.js +4 -4
  330. package/lib/wasm-async/AsyncWasmModule.js +77 -0
  331. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
  332. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
  333. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  334. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
  335. package/lib/wasm-sync/SyncWasmModule.js +39 -0
  336. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
  337. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
  338. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
  339. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
  340. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  341. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
  342. package/lib/wasm-sync/WebAssemblyParser.js +7 -3
  343. package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
  344. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
  345. package/package.json +35 -27
  346. package/schemas/WebpackOptions.check.js +1 -1
  347. package/schemas/WebpackOptions.json +212 -3
  348. package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
  349. package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
  350. package/schemas/plugins/HtmlParserOptions.check.js +6 -0
  351. package/schemas/plugins/HtmlParserOptions.json +3 -0
  352. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
  353. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  354. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  355. package/types.d.ts +1456 -290
  356. package/lib/css/walkCssTokens.js +0 -2020
  357. package/lib/util/AppendOnlyStackedSet.js +0 -93
@@ -75,6 +75,7 @@ ${modulesList}`);
75
75
 
76
76
  /** @type {string} */
77
77
  this.name = "CaseSensitiveModulesWarning";
78
+ /** @type {Module} */
78
79
  this.module = sortedModules[0];
79
80
  }
80
81
  }
@@ -19,8 +19,11 @@ class WarnDeprecatedOptionPlugin {
19
19
  * @param {string} suggestion the suggestion replacement
20
20
  */
21
21
  constructor(option, value, suggestion) {
22
+ /** @type {string} */
22
23
  this.option = option;
24
+ /** @type {string | number} */
23
25
  this.value = value;
26
+ /** @type {string} */
24
27
  this.suggestion = suggestion;
25
28
  }
26
29
 
@@ -50,6 +53,7 @@ class DeprecatedOptionWarning extends WebpackError {
50
53
 
51
54
  /** @type {string} */
52
55
  this.name = "DeprecatedOptionWarning";
56
+ /** @type {string} */
53
57
  this.message =
54
58
  "configuration\n" +
55
59
  `The value '${value}' for option '${option}' is deprecated. ` +
@@ -13,6 +13,7 @@ class NoModeWarning extends WebpackError {
13
13
 
14
14
  /** @type {string} */
15
15
  this.name = "NoModeWarning";
16
+ /** @type {string} */
16
17
  this.message =
17
18
  "configuration\n" +
18
19
  "The 'mode' option has not been set, webpack will fallback to 'production' for this value.\n" +
@@ -23,6 +23,7 @@ class IgnoringWatchFileSystem {
23
23
  * @param {WatchIgnorePluginOptions["paths"]} paths ignored paths
24
24
  */
25
25
  constructor(wfs, paths) {
26
+ /** @type {WatchFileSystem} */
26
27
  this.wfs = wfs;
27
28
  this.paths = paths;
28
29
  }
package/lib/Watching.js CHANGED
@@ -35,6 +35,7 @@ class Watching {
35
35
  constructor(compiler, watchOptions, handler) {
36
36
  /** @type {null | number} */
37
37
  this.startTime = null;
38
+ /** @type {boolean} */
38
39
  this.invalid = false;
39
40
  /** @type {Callback<Stats>} */
40
41
  this.handler = handler;
@@ -42,8 +43,11 @@ class Watching {
42
43
  this.callbacks = [];
43
44
  /** @type {ErrorCallback[] | undefined} */
44
45
  this._closeCallbacks = undefined;
46
+ /** @type {boolean} */
45
47
  this.closed = false;
48
+ /** @type {boolean} */
46
49
  this.suspended = false;
50
+ /** @type {boolean} */
47
51
  this.blocked = false;
48
52
  this._isBlocked = () => false;
49
53
  this._onChange = () => {};
@@ -63,10 +67,15 @@ class Watching {
63
67
  if (typeof this.watchOptions.aggregateTimeout !== "number") {
64
68
  this.watchOptions.aggregateTimeout = 20;
65
69
  }
70
+ /** @type {Compiler} */
66
71
  this.compiler = compiler;
72
+ /** @type {boolean} */
67
73
  this.running = false;
74
+ /** @type {boolean} */
68
75
  this._initial = true;
76
+ /** @type {boolean} */
69
77
  this._invalidReported = true;
78
+ /** @type {boolean} */
70
79
  this._needRecords = true;
71
80
  /** @type {undefined | null | Watcher} */
72
81
  this.watcher = undefined;
@@ -149,6 +149,16 @@ class WebpackOptionsApply extends OptionsApply {
149
149
  ).apply(compiler);
150
150
  }
151
151
  }
152
+ if (options.externalsPresets.deno) {
153
+ const DenoTargetPlugin = require("./deno/DenoTargetPlugin");
154
+
155
+ new DenoTargetPlugin().apply(compiler);
156
+ }
157
+ if (options.externalsPresets.bun) {
158
+ const BunTargetPlugin = require("./bun/BunTargetPlugin");
159
+
160
+ new BunTargetPlugin().apply(compiler);
161
+ }
152
162
  if (options.externalsPresets.webAsync || options.externalsPresets.web) {
153
163
  const type = options.externalsPresets.webAsync ? "import" : "module";
154
164
 
@@ -175,23 +185,42 @@ class WebpackOptionsApply extends OptionsApply {
175
185
  }).apply(compiler);
176
186
  }
177
187
  if (options.externalsPresets.electron) {
188
+ // Use ESM imports only when the targeted electron version supports them
189
+ const type =
190
+ options.output.module && options.output.environment.module
191
+ ? "module-import"
192
+ : "node-commonjs";
193
+
194
+ // Warn when ESM output is requested but the electron version lacks it (added in electron 28)
195
+ if (options.output.module && !options.output.environment.module) {
196
+ const WebpackError = require("./WebpackError");
197
+
198
+ compiler.hooks.thisCompilation.tap(CLASS_NAME, (compilation) => {
199
+ compilation.warnings.push(
200
+ new WebpackError(
201
+ "'output.module' is enabled, but the targeted electron version does not support ECMAScript modules (added in electron 28). Electron built-in modules are externalized as 'node-commonjs'."
202
+ )
203
+ );
204
+ });
205
+ }
206
+
178
207
  if (options.externalsPresets.electronMain) {
179
208
  // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
180
209
  const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin");
181
210
 
182
- new ElectronTargetPlugin("main").apply(compiler);
211
+ new ElectronTargetPlugin("main", type).apply(compiler);
183
212
  }
184
213
  if (options.externalsPresets.electronPreload) {
185
214
  // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
186
215
  const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin");
187
216
 
188
- new ElectronTargetPlugin("preload").apply(compiler);
217
+ new ElectronTargetPlugin("preload", type).apply(compiler);
189
218
  }
190
219
  if (options.externalsPresets.electronRenderer) {
191
220
  // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
192
221
  const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin");
193
222
 
194
- new ElectronTargetPlugin("renderer").apply(compiler);
223
+ new ElectronTargetPlugin("renderer", type).apply(compiler);
195
224
  }
196
225
  if (
197
226
  !options.externalsPresets.electronMain &&
@@ -201,7 +230,7 @@ class WebpackOptionsApply extends OptionsApply {
201
230
  // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
202
231
  const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin");
203
232
 
204
- new ElectronTargetPlugin().apply(compiler);
233
+ new ElectronTargetPlugin(undefined, type).apply(compiler);
205
234
  }
206
235
  }
207
236
  if (options.externalsPresets.nwjs) {
@@ -372,6 +401,7 @@ class WebpackOptionsApply extends OptionsApply {
372
401
  }
373
402
 
374
403
  new JavascriptModulesPlugin().apply(compiler);
404
+
375
405
  new JsonModulesPlugin().apply(compiler);
376
406
  new AssetModulesPlugin({
377
407
  sideEffectFree: options.experiments.futureDefaults
@@ -610,7 +640,9 @@ class WebpackOptionsApply extends OptionsApply {
610
640
  const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
611
641
 
612
642
  new FlagDependencyUsagePlugin(
613
- options.optimization.usedExports === "global"
643
+ options.optimization.usedExports === "global",
644
+ // Keep an escaping module's exports mangleable when mangling is on.
645
+ Boolean(options.optimization.mangleExports)
614
646
  ).apply(compiler);
615
647
  }
616
648
  if (options.optimization.innerGraph) {
@@ -618,6 +650,19 @@ class WebpackOptionsApply extends OptionsApply {
618
650
 
619
651
  new InnerGraphPlugin().apply(compiler);
620
652
  }
653
+
654
+ if (options.mode === "production") {
655
+ const CircularModulesPlugin = require("./CircularModulesPlugin");
656
+
657
+ new CircularModulesPlugin().apply(compiler);
658
+ }
659
+
660
+ const ConstExportsPlugin = require("./optimize/ConstExportsPlugin");
661
+
662
+ new ConstExportsPlugin({
663
+ inlineExports: options.optimization.inlineExports
664
+ }).apply(compiler);
665
+
621
666
  if (options.optimization.mangleExports) {
622
667
  const MangleExportsPlugin = require("./optimize/MangleExportsPlugin");
623
668
 
@@ -28,14 +28,15 @@ const RuntimeGlobals = require("../RuntimeGlobals");
28
28
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
29
29
  /** @typedef {import("../NormalModule")} NormalModule */
30
30
 
31
- class AssetSourceGenerator extends Generator {
31
+ class AssetBytesGenerator extends Generator {
32
32
  /**
33
- * Creates an instance of AssetSourceGenerator.
33
+ * Creates an instance of AssetBytesGenerator.
34
34
  * @param {ModuleGraph} moduleGraph the module graph
35
35
  */
36
36
  constructor(moduleGraph) {
37
37
  super();
38
38
 
39
+ /** @type {ModuleGraph} */
39
40
  this._moduleGraph = moduleGraph;
40
41
  }
41
42
 
@@ -161,6 +162,13 @@ class AssetSourceGenerator extends Generator {
161
162
  return NO_TYPES;
162
163
  }
163
164
 
165
+ /**
166
+ * @returns {boolean} whether getTypes() depends on the module's incoming connections
167
+ */
168
+ getTypesDependOnIncomingConnections() {
169
+ return true;
170
+ }
171
+
164
172
  /**
165
173
  * Returns the estimated size for the requested source type.
166
174
  * @param {NormalModule} module the module
@@ -179,4 +187,4 @@ class AssetSourceGenerator extends Generator {
179
187
  }
180
188
  }
181
189
 
182
- module.exports = AssetSourceGenerator;
190
+ module.exports = AssetBytesGenerator;
@@ -25,11 +25,14 @@ const {
25
25
  } = require("../ModuleSourceTypeConstants");
26
26
  const { ASSET_MODULE_TYPE } = require("../ModuleTypeConstants");
27
27
  const RuntimeGlobals = require("../RuntimeGlobals");
28
- const CssUrlDependency = require("../dependencies/CssUrlDependency");
29
28
  const createHash = require("../util/createHash");
30
29
  const { makePathsRelative } = require("../util/identifier");
31
30
  const memoize = require("../util/memoize");
32
31
  const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
32
+ const {
33
+ PUBLIC_PATH_AUTO,
34
+ PUBLIC_PATH_FULL_HASH
35
+ } = require("../util/publicPathPlaceholder");
33
36
  const { updateHashFromSource } = require("../util/source");
34
37
 
35
38
  const getMimeTypes = memoize(() => require("../util/mimeTypes"));
@@ -47,7 +50,7 @@ const getMimeTypes = memoize(() => require("../util/mimeTypes"));
47
50
  /** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */
48
51
  /** @typedef {import("../Module")} Module */
49
52
  /** @typedef {import("../Module").NameForCondition} NameForCondition */
50
- /** @typedef {import("../Module").BuildInfo} BuildInfo */
53
+ /** @typedef {import("./AssetModule").AssetModuleBuildInfo} AssetModuleBuildInfo */
51
54
  /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
52
55
  /** @typedef {import("../Module").SourceType} SourceType */
53
56
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
@@ -286,13 +289,15 @@ class AssetGenerator extends Generator {
286
289
  * @param {Pick<AssetResourceGeneratorOptions, "filename" | "outputPath">} generatorOptions generator options
287
290
  * @param {{ runtime: RuntimeSpec, runtimeTemplate: RuntimeTemplate, chunkGraph: ChunkGraph }} generateContext context for generate
288
291
  * @param {string} contentHash the content hash
292
+ * @param {string=} fullContentHash untruncated content hash, so `[contenthash:<digest>]` re-encodes from full entropy
289
293
  * @returns {{ filename: string, originalFilename: string, assetInfo: AssetInfo }} info
290
294
  */
291
295
  static getFilenameWithInfo(
292
296
  module,
293
297
  generatorOptions,
294
298
  { runtime, runtimeTemplate, chunkGraph },
295
- contentHash
299
+ contentHash,
300
+ fullContentHash
296
301
  ) {
297
302
  const assetModuleFilename =
298
303
  generatorOptions.filename ||
@@ -308,7 +313,8 @@ class AssetGenerator extends Generator {
308
313
  runtime,
309
314
  filename: sourceFilename,
310
315
  chunkGraph,
311
- contentHash
316
+ contentHash,
317
+ contentHashFull: fullContentHash
312
318
  });
313
319
 
314
320
  const originalFilename = filename;
@@ -322,7 +328,8 @@ class AssetGenerator extends Generator {
322
328
  runtime,
323
329
  filename: sourceFilename,
324
330
  chunkGraph,
325
- contentHash
331
+ contentHash,
332
+ contentHashFull: fullContentHash
326
333
  }
327
334
  );
328
335
  filename = path.posix.join(outputPath, filename);
@@ -340,6 +347,7 @@ class AssetGenerator extends Generator {
340
347
  * @param {string} filename the filename
341
348
  * @param {AssetInfo} assetInfo the asset info
342
349
  * @param {string} contentHash the content hash
350
+ * @param {string=} fullContentHash untruncated content hash, so `[contenthash:<digest>]` re-encodes from full entropy
343
351
  * @returns {{ assetPath: string, assetInfo: AssetInfo }} asset path and info
344
352
  */
345
353
  static getAssetPathWithInfo(
@@ -348,7 +356,8 @@ class AssetGenerator extends Generator {
348
356
  { runtime, runtimeTemplate, type, chunkGraph, runtimeRequirements },
349
357
  filename,
350
358
  assetInfo,
351
- contentHash
359
+ contentHash,
360
+ fullContentHash
352
361
  ) {
353
362
  const sourceFilename = AssetGenerator.getSourceFileName(
354
363
  module,
@@ -366,7 +375,8 @@ class AssetGenerator extends Generator {
366
375
  runtime,
367
376
  filename: sourceFilename,
368
377
  chunkGraph,
369
- contentHash
378
+ contentHash,
379
+ contentHashFull: fullContentHash
370
380
  }
371
381
  );
372
382
  assetInfo = mergeAssetInfo(assetInfo, info);
@@ -382,7 +392,8 @@ class AssetGenerator extends Generator {
382
392
  runtime,
383
393
  filename: sourceFilename,
384
394
  chunkGraph,
385
- contentHash
395
+ contentHash,
396
+ contentHashFull: fullContentHash
386
397
  }
387
398
  );
388
399
  assetInfo = mergeAssetInfo(assetInfo, info);
@@ -398,15 +409,13 @@ class AssetGenerator extends Generator {
398
409
  const compilation = runtimeTemplate.compilation;
399
410
  const path =
400
411
  compilation.outputOptions.publicPath === "auto"
401
- ? CssUrlDependency.PUBLIC_PATH_AUTO
412
+ ? PUBLIC_PATH_AUTO
402
413
  : compilation.getAssetPath(compilation.outputOptions.publicPath, {
403
- hash:
404
- compilation.hash ||
405
- `${CssUrlDependency.PUBLIC_PATH_FULL_HASH}0__`,
414
+ hash: compilation.hash || `${PUBLIC_PATH_FULL_HASH}0__`,
406
415
  hashWithLength: (length) =>
407
416
  compilation.hash
408
417
  ? compilation.hash.slice(0, length)
409
- : `${CssUrlDependency.PUBLIC_PATH_FULL_HASH}${length}__`
418
+ : `${PUBLIC_PATH_FULL_HASH}${length}__`
410
419
  });
411
420
 
412
421
  assetPath = path + filename;
@@ -564,7 +573,7 @@ class AssetGenerator extends Generator {
564
573
  const data = getData ? getData() : undefined;
565
574
 
566
575
  if (
567
- /** @type {BuildInfo} */
576
+ /** @type {AssetModuleBuildInfo} */
568
577
  (module.buildInfo).dataUrl &&
569
578
  needContent
570
579
  ) {
@@ -588,7 +597,7 @@ class AssetGenerator extends Generator {
588
597
  data.set("contentHash", contentHash);
589
598
  }
590
599
 
591
- /** @type {BuildInfo} */
600
+ /** @type {AssetModuleBuildInfo} */
592
601
  (module.buildInfo).fullContentHash = fullContentHash;
593
602
 
594
603
  const { originalFilename, filename, assetInfo } =
@@ -596,7 +605,8 @@ class AssetGenerator extends Generator {
596
605
  module,
597
606
  { filename: this.filename, outputPath: this.outputPath },
598
607
  generateContext,
599
- contentHash
608
+ contentHash,
609
+ fullContentHash
600
610
  );
601
611
 
602
612
  if (data) {
@@ -610,7 +620,8 @@ class AssetGenerator extends Generator {
610
620
  generateContext,
611
621
  originalFilename,
612
622
  assetInfo,
613
- contentHash
623
+ contentHash,
624
+ fullContentHash
614
625
  );
615
626
 
616
627
  if (data && (type === JAVASCRIPT_TYPE || type === ASSET_URL_TYPE)) {
@@ -632,10 +643,10 @@ class AssetGenerator extends Generator {
632
643
  // Due to code generation caching module.buildInfo.XXX can't used to store such information
633
644
  // It need to be stored in the code generation results instead, where it's cached too
634
645
  // TODO webpack 6 For back-compat reasons we also store in on module.buildInfo
635
- /** @type {BuildInfo} */
646
+ /** @type {AssetModuleBuildInfo} */
636
647
  (module.buildInfo).filename = filename;
637
648
 
638
- /** @type {BuildInfo} */
649
+ /** @type {AssetModuleBuildInfo} */
639
650
  (module.buildInfo).assetInfo = newAssetInfo;
640
651
 
641
652
  content = assetPath;
@@ -704,7 +715,11 @@ class AssetGenerator extends Generator {
704
715
  sourceTypes.add(connection.originModule.type.split("/")[0]);
705
716
  }
706
717
 
707
- if ((module.buildInfo && module.buildInfo.dataUrl) || this.emit === false) {
718
+ if (
719
+ (module.buildInfo &&
720
+ /** @type {AssetModuleBuildInfo} */ (module.buildInfo).dataUrl) ||
721
+ this.emit === false
722
+ ) {
708
723
  if (sourceTypes.size > 0) {
709
724
  if (
710
725
  sourceTypes.has(JAVASCRIPT_TYPE) &&
@@ -735,6 +750,13 @@ class AssetGenerator extends Generator {
735
750
  return ASSET_TYPES;
736
751
  }
737
752
 
753
+ /**
754
+ * @returns {boolean} whether getTypes() depends on the module's incoming connections
755
+ */
756
+ getTypesDependOnIncomingConnections() {
757
+ return true;
758
+ }
759
+
738
760
  /**
739
761
  * Returns the estimated size for the requested source type.
740
762
  * @param {NormalModule} module the module
@@ -753,7 +775,10 @@ class AssetGenerator extends Generator {
753
775
  return originalSource.size();
754
776
  }
755
777
  default:
756
- if (module.buildInfo && module.buildInfo.dataUrl) {
778
+ if (
779
+ module.buildInfo &&
780
+ /** @type {AssetModuleBuildInfo} */ (module.buildInfo).dataUrl
781
+ ) {
757
782
  const originalSource = module.originalSource();
758
783
 
759
784
  if (!originalSource) {
@@ -781,7 +806,7 @@ class AssetGenerator extends Generator {
781
806
  const { module } = updateHashContext;
782
807
 
783
808
  if (
784
- /** @type {BuildInfo} */
809
+ /** @type {AssetModuleBuildInfo} */
785
810
  (module.buildInfo).dataUrl
786
811
  ) {
787
812
  hash.update("data-url");
@@ -0,0 +1,47 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ */
4
+
5
+ "use strict";
6
+
7
+ const NormalModule = require("../NormalModule");
8
+ const makeSerializable = require("../util/makeSerializable");
9
+
10
+ /** @typedef {import("../Compilation").AssetInfo} AssetInfo */
11
+ /** @typedef {import("../NormalModule").NormalModuleBuildInfo} NormalModuleBuildInfo */
12
+ /** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */
13
+
14
+ /**
15
+ * Defines the build info properties specific to asset modules.
16
+ * @typedef {object} KnownAssetModuleBuildInfo
17
+ * @property {boolean=} dataUrl whether the asset is inlined as a data url
18
+ * @property {string=} filename
19
+ * @property {AssetInfo=} assetInfo
20
+ * @property {string=} fullContentHash
21
+ */
22
+
23
+ /** @typedef {NormalModuleBuildInfo & KnownAssetModuleBuildInfo} AssetModuleBuildInfo */
24
+
25
+ /**
26
+ * Module class for all `asset/*` modules. Asset-specific properties should live here instead of `NormalModule`.
27
+ */
28
+ class AssetModule extends NormalModule {
29
+ /**
30
+ * @param {NormalModuleCreateData} options options object
31
+ * @param {boolean=} sideEffectFree whether asset modules are side-effect-free (`AssetModulesPluginOptions`)
32
+ */
33
+ constructor(options, sideEffectFree) {
34
+ super(options);
35
+
36
+ // Redeclared with the asset specific shape
37
+ /** @type {AssetModuleBuildInfo | undefined} */
38
+ this.buildInfo = undefined;
39
+ if (sideEffectFree) {
40
+ this.factoryMeta = { sideEffectFree: true };
41
+ }
42
+ }
43
+ }
44
+
45
+ makeSerializable(AssetModule, "webpack/lib/asset/AssetModule");
46
+
47
+ module.exports = AssetModule;
@@ -23,7 +23,7 @@ const memoize = require("../util/memoize");
23
23
  /** @typedef {import("../../declarations/WebpackOptions").AssetModuleFilename} AssetModuleFilename */
24
24
  /** @typedef {import("../Compilation").AssetInfo} AssetInfo */
25
25
  /** @typedef {import("../Compiler")} Compiler */
26
- /** @typedef {import("../Module").BuildInfo} BuildInfo */
26
+ /** @typedef {import("./AssetModule").AssetModuleBuildInfo} AssetModuleBuildInfo */
27
27
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
28
28
  /** @typedef {import("../NormalModule")} NormalModule */
29
29
 
@@ -56,7 +56,7 @@ const getAssetSourceGenerator = memoize(() =>
56
56
  require("./AssetSourceGenerator")
57
57
  );
58
58
  const getAssetBytesGenerator = memoize(() => require("./AssetBytesGenerator"));
59
- const getNormalModule = memoize(() => require("../NormalModule"));
59
+ const getAssetModule = memoize(() => require("./AssetModule"));
60
60
 
61
61
  const type = ASSET_MODULE_TYPE;
62
62
  const PLUGIN_NAME = "AssetModulesPlugin";
@@ -73,6 +73,7 @@ class AssetModulesPlugin {
73
73
  * @param {AssetModulesPluginOptions} options options
74
74
  */
75
75
  constructor(options) {
76
+ /** @type {AssetModulesPluginOptions} */
76
77
  this.options = options;
77
78
  }
78
79
 
@@ -85,7 +86,7 @@ class AssetModulesPlugin {
85
86
  compiler.hooks.compilation.tap(
86
87
  PLUGIN_NAME,
87
88
  (compilation, { normalModuleFactory }) => {
88
- const NormalModule = getNormalModule();
89
+ const AssetModule = getAssetModule();
89
90
  for (const type of [
90
91
  ASSET_MODULE_TYPE,
91
92
  ASSET_MODULE_TYPE_BYTES,
@@ -95,15 +96,11 @@ class AssetModulesPlugin {
95
96
  ]) {
96
97
  normalModuleFactory.hooks.createModuleClass
97
98
  .for(type)
98
- .tap(PLUGIN_NAME, (createData, _resolveData) => {
99
- // TODO create the module via new AssetModule with its own properties
100
- const module = new NormalModule(createData);
101
- if (this.options.sideEffectFree) {
102
- module.factoryMeta = { sideEffectFree: true };
103
- }
104
-
105
- return module;
106
- });
99
+ .tap(
100
+ PLUGIN_NAME,
101
+ (createData, _resolveData) =>
102
+ new AssetModule(createData, this.options.sideEffectFree)
103
+ );
107
104
  }
108
105
 
109
106
  normalModuleFactory.hooks.createParser
@@ -279,7 +276,9 @@ class AssetModulesPlugin {
279
276
  module,
280
277
  chunk.runtime
281
278
  );
282
- const buildInfo = /** @type {BuildInfo} */ (module.buildInfo);
279
+ const buildInfo = /** @type {AssetModuleBuildInfo} */ (
280
+ module.buildInfo
281
+ );
283
282
  const data =
284
283
  /** @type {NonNullable<CodeGenerationResult["data"]>} */
285
284
  (codeGenResult.data);
@@ -316,7 +315,8 @@ class AssetModulesPlugin {
316
315
  runtimeTemplate,
317
316
  chunkGraph
318
317
  },
319
- contentHash
318
+ contentHash,
319
+ fullContentHash
320
320
  );
321
321
  entryFilename = filename;
322
322
  entryInfo = assetInfo;
@@ -10,7 +10,7 @@ const Parser = require("../Parser");
10
10
  /** @typedef {import("../../declarations/WebpackOptions").AssetParserDataUrlOptions} AssetParserDataUrlOptions */
11
11
  /** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */
12
12
  /** @typedef {import("../Module")} Module */
13
- /** @typedef {import("../Module").BuildInfo} BuildInfo */
13
+ /** @typedef {import("./AssetModule").AssetModuleBuildInfo} AssetModuleBuildInfo */
14
14
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
15
15
  /** @typedef {import("../Parser").ParserState} ParserState */
16
16
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
@@ -40,7 +40,7 @@ class AssetParser extends Parser {
40
40
  }
41
41
 
42
42
  const buildInfo =
43
- /** @type {BuildInfo} */
43
+ /** @type {AssetModuleBuildInfo} */
44
44
  (state.module.buildInfo);
45
45
  buildInfo.strict = true;
46
46
  const buildMeta =
@@ -36,6 +36,7 @@ class AssetSourceGenerator extends Generator {
36
36
  constructor(moduleGraph) {
37
37
  super();
38
38
 
39
+ /** @type {ModuleGraph} */
39
40
  this._moduleGraph = moduleGraph;
40
41
  }
41
42
 
@@ -160,6 +161,13 @@ class AssetSourceGenerator extends Generator {
160
161
  return NO_TYPES;
161
162
  }
162
163
 
164
+ /**
165
+ * @returns {boolean} whether getTypes() depends on the module's incoming connections
166
+ */
167
+ getTypesDependOnIncomingConnections() {
168
+ return true;
169
+ }
170
+
163
171
  /**
164
172
  * Returns the estimated size for the requested source type.
165
173
  * @param {NormalModule} module the module
@@ -29,8 +29,8 @@ const makeSerializable = require("../util/makeSerializable");
29
29
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
30
30
  /** @typedef {import("../RequestShortener")} RequestShortener */
31
31
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
32
- /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
33
- /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
32
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[Buffer | undefined, string, string]>} ObjectDeserializerContext */
33
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[Buffer | undefined, string, string]>} ObjectSerializerContext */
34
34
  /** @typedef {import("../util/Hash")} Hash */
35
35
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
36
36
 
@@ -161,11 +161,10 @@ class RawDataUrlModule extends Module {
161
161
  * @param {ObjectSerializerContext} context context
162
162
  */
163
163
  serialize(context) {
164
- const { write } = context;
165
-
166
- write(this.urlBuffer);
167
- write(this.identifierStr);
168
- write(this.readableIdentifierStr);
164
+ context
165
+ .write(this.urlBuffer)
166
+ .write(this.identifierStr)
167
+ .write(this.readableIdentifierStr);
169
168
 
170
169
  super.serialize(context);
171
170
  }
@@ -175,13 +174,13 @@ class RawDataUrlModule extends Module {
175
174
  * @param {ObjectDeserializerContext} context context
176
175
  */
177
176
  deserialize(context) {
178
- const { read } = context;
179
-
180
- this.urlBuffer = read();
181
- this.identifierStr = read();
182
- this.readableIdentifierStr = read();
177
+ this.urlBuffer = context.read();
178
+ const c1 = context.rest;
179
+ this.identifierStr = c1.read();
180
+ const c2 = c1.rest;
181
+ this.readableIdentifierStr = c2.read();
183
182
 
184
- super.deserialize(context);
183
+ super.deserialize(c2.rest);
185
184
  }
186
185
  }
187
186