webpack 5.76.1 → 5.88.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (436) hide show
  1. package/README.md +10 -4
  2. package/bin/webpack.js +26 -2
  3. package/hot/dev-server.js +2 -1
  4. package/hot/lazy-compilation-node.js +10 -0
  5. package/hot/lazy-compilation-web.js +9 -0
  6. package/hot/log-apply-result.js +5 -0
  7. package/hot/log.js +22 -0
  8. package/hot/only-dev-server.js +2 -1
  9. package/hot/poll.js +3 -0
  10. package/hot/signal.js +4 -0
  11. package/lib/APIPlugin.js +174 -116
  12. package/lib/AsyncDependenciesBlock.js +13 -5
  13. package/lib/AutomaticPrefetchPlugin.js +1 -0
  14. package/lib/BannerPlugin.js +4 -0
  15. package/lib/CacheFacade.js +4 -0
  16. package/lib/CaseSensitiveModulesWarning.js +3 -1
  17. package/lib/Chunk.js +36 -18
  18. package/lib/ChunkGraph.js +4 -4
  19. package/lib/ChunkGroup.js +25 -10
  20. package/lib/CleanPlugin.js +30 -7
  21. package/lib/CodeGenerationResults.js +2 -2
  22. package/lib/CompatibilityPlugin.js +85 -46
  23. package/lib/Compilation.js +17 -8
  24. package/lib/Compiler.js +12 -8
  25. package/lib/ConcatenationScope.js +2 -2
  26. package/lib/ConditionalInitFragment.js +11 -1
  27. package/lib/ConstPlugin.js +79 -44
  28. package/lib/ContextModule.js +20 -6
  29. package/lib/ContextModuleFactory.js +2 -1
  30. package/lib/ContextReplacementPlugin.js +13 -0
  31. package/lib/CssModule.js +169 -0
  32. package/lib/DefinePlugin.js +152 -86
  33. package/lib/DelegatedModule.js +22 -4
  34. package/lib/DelegatedModuleFactoryPlugin.js +6 -0
  35. package/lib/DependenciesBlock.js +17 -1
  36. package/lib/Dependency.js +19 -5
  37. package/lib/DllEntryPlugin.js +16 -1
  38. package/lib/DllModule.js +17 -2
  39. package/lib/DllModuleFactory.js +1 -1
  40. package/lib/DllReferencePlugin.js +13 -1
  41. package/lib/Entrypoint.js +1 -1
  42. package/lib/ErrorHelpers.js +62 -22
  43. package/lib/EvalSourceMapDevToolPlugin.js +9 -2
  44. package/lib/ExportsInfo.js +20 -3
  45. package/lib/ExportsInfoApiPlugin.js +30 -14
  46. package/lib/ExternalModule.js +30 -9
  47. package/lib/FileSystemInfo.js +9 -1
  48. package/lib/FlagAllModulesAsUsedPlugin.js +27 -27
  49. package/lib/FlagDependencyExportsPlugin.js +336 -348
  50. package/lib/FlagDependencyUsagePlugin.js +9 -9
  51. package/lib/FlagEntryExportAsUsedPlugin.js +26 -23
  52. package/lib/HookWebpackError.js +1 -1
  53. package/lib/HotModuleReplacementPlugin.js +60 -46
  54. package/lib/IgnoreErrorModuleFactory.js +1 -1
  55. package/lib/InitFragment.js +28 -5
  56. package/lib/JavascriptMetaInfoPlugin.js +27 -15
  57. package/lib/LibManifestPlugin.js +22 -5
  58. package/lib/LoaderOptionsPlugin.js +12 -2
  59. package/lib/MainTemplate.js +2 -2
  60. package/lib/Module.js +44 -12
  61. package/lib/ModuleBuildError.js +9 -0
  62. package/lib/ModuleDependencyError.js +4 -2
  63. package/lib/ModuleDependencyWarning.js +4 -2
  64. package/lib/ModuleError.js +9 -0
  65. package/lib/ModuleFactory.js +1 -1
  66. package/lib/ModuleFilenameHelpers.js +114 -4
  67. package/lib/ModuleGraph.js +33 -23
  68. package/lib/ModuleGraphConnection.js +19 -6
  69. package/lib/ModuleInfoHeaderPlugin.js +9 -2
  70. package/lib/ModuleNotFoundError.js +5 -2
  71. package/lib/ModuleParseError.js +9 -0
  72. package/lib/ModuleProfile.js +1 -0
  73. package/lib/ModuleRestoreError.js +2 -0
  74. package/lib/ModuleStoreError.js +2 -1
  75. package/lib/ModuleTypeConstants.js +169 -0
  76. package/lib/ModuleWarning.js +9 -0
  77. package/lib/MultiWatching.js +4 -0
  78. package/lib/NodeStuffPlugin.js +65 -35
  79. package/lib/NormalModule.js +12 -2
  80. package/lib/NormalModuleFactory.js +56 -8
  81. package/lib/NormalModuleReplacementPlugin.js +5 -3
  82. package/lib/NullFactory.js +1 -1
  83. package/lib/PrefetchPlugin.js +4 -0
  84. package/lib/ProgressPlugin.js +71 -15
  85. package/lib/ProvidePlugin.js +30 -14
  86. package/lib/RawModule.js +13 -2
  87. package/lib/RecordIdsPlugin.js +4 -4
  88. package/lib/RequireJsStuffPlugin.js +22 -15
  89. package/lib/RuntimeGlobals.js +5 -0
  90. package/lib/RuntimeModule.js +12 -11
  91. package/lib/RuntimePlugin.js +10 -3
  92. package/lib/RuntimeTemplate.js +29 -11
  93. package/lib/SelfModuleFactory.js +12 -0
  94. package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
  95. package/lib/SourceMapDevToolPlugin.js +47 -11
  96. package/lib/Template.js +5 -3
  97. package/lib/UseStrictPlugin.js +29 -11
  98. package/lib/WarnCaseSensitiveModulesPlugin.js +12 -0
  99. package/lib/WarnDeprecatedOptionPlugin.js +7 -0
  100. package/lib/WatchIgnorePlugin.js +4 -0
  101. package/lib/WebpackError.js +14 -5
  102. package/lib/WebpackIsIncludedPlugin.js +22 -13
  103. package/lib/WebpackOptionsApply.js +41 -44
  104. package/lib/WebpackOptionsDefaulter.js +10 -3
  105. package/lib/asset/AssetGenerator.js +24 -9
  106. package/lib/asset/AssetModulesPlugin.js +28 -12
  107. package/lib/asset/AssetParser.js +15 -7
  108. package/lib/asset/AssetSourceParser.js +8 -3
  109. package/lib/asset/RawDataUrlModule.js +15 -4
  110. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
  111. package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
  112. package/lib/cache/IdleFileCachePlugin.js +2 -1
  113. package/lib/cache/MemoryWithGcCachePlugin.js +2 -0
  114. package/lib/cache/PackFileCacheStrategy.js +42 -15
  115. package/lib/cache/ResolverCachePlugin.js +3 -0
  116. package/lib/config/browserslistTargetHandler.js +10 -10
  117. package/lib/config/defaults.js +306 -105
  118. package/lib/config/normalization.js +110 -71
  119. package/lib/config/target.js +37 -10
  120. package/lib/container/ContainerEntryModule.js +11 -1
  121. package/lib/container/ContainerEntryModuleFactory.js +1 -1
  122. package/lib/container/ContainerExposedDependency.js +9 -0
  123. package/lib/container/ContainerPlugin.js +3 -1
  124. package/lib/container/FallbackDependency.js +13 -0
  125. package/lib/container/FallbackItemDependency.js +3 -0
  126. package/lib/container/FallbackModule.js +12 -2
  127. package/lib/container/FallbackModuleFactory.js +1 -1
  128. package/lib/container/RemoteModule.js +11 -1
  129. package/lib/container/RemoteRuntimeModule.js +3 -2
  130. package/lib/container/RemoteToExternalDependency.js +3 -0
  131. package/lib/css/CssExportsGenerator.js +9 -0
  132. package/lib/css/CssGenerator.js +5 -1
  133. package/lib/css/CssLoadingRuntimeModule.js +53 -22
  134. package/lib/css/CssModulesPlugin.js +253 -74
  135. package/lib/css/CssParser.js +697 -282
  136. package/lib/css/walkCssTokens.js +269 -138
  137. package/lib/debug/ProfilingPlugin.js +33 -12
  138. package/lib/dependencies/AMDDefineDependency.js +54 -10
  139. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +13 -2
  140. package/lib/dependencies/AMDPlugin.js +33 -20
  141. package/lib/dependencies/AMDRequireArrayDependency.js +13 -0
  142. package/lib/dependencies/AMDRequireContextDependency.js +15 -0
  143. package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
  144. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
  145. package/lib/dependencies/AMDRequireDependency.js +16 -1
  146. package/lib/dependencies/AMDRequireItemDependency.js +6 -0
  147. package/lib/dependencies/AMDRuntimeModules.js +2 -2
  148. package/lib/dependencies/CachedConstDependency.js +14 -0
  149. package/lib/dependencies/CommonJsDependencyHelpers.js +9 -0
  150. package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
  151. package/lib/dependencies/CommonJsExportsDependency.js +16 -0
  152. package/lib/dependencies/CommonJsExportsParserPlugin.js +77 -5
  153. package/lib/dependencies/CommonJsFullRequireDependency.js +10 -1
  154. package/lib/dependencies/CommonJsImportsParserPlugin.js +174 -63
  155. package/lib/dependencies/CommonJsPlugin.js +51 -26
  156. package/lib/dependencies/CommonJsRequireContextDependency.js +17 -0
  157. package/lib/dependencies/CommonJsRequireDependency.js +7 -0
  158. package/lib/dependencies/CommonJsSelfReferenceDependency.js +16 -0
  159. package/lib/dependencies/ConstDependency.js +11 -2
  160. package/lib/dependencies/ContextDependency.js +15 -2
  161. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  162. package/lib/dependencies/ContextElementDependency.js +8 -0
  163. package/lib/dependencies/CreateScriptUrlDependency.js +10 -1
  164. package/lib/dependencies/CriticalDependencyWarning.js +3 -0
  165. package/lib/dependencies/CssExportDependency.js +8 -0
  166. package/lib/dependencies/CssImportDependency.js +55 -3
  167. package/lib/dependencies/CssLocalIdentifierDependency.js +15 -1
  168. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +10 -1
  169. package/lib/dependencies/CssUrlDependency.js +46 -16
  170. package/lib/dependencies/DelegatedSourceDependency.js +3 -0
  171. package/lib/dependencies/DllEntryDependency.js +14 -0
  172. package/lib/dependencies/DynamicExports.js +10 -6
  173. package/lib/dependencies/ExportsInfoDependency.js +25 -4
  174. package/lib/dependencies/HarmonyAcceptDependency.js +10 -1
  175. package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
  176. package/lib/dependencies/HarmonyCompatibilityDependency.js +2 -1
  177. package/lib/dependencies/HarmonyDetectionParserPlugin.js +22 -2
  178. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +32 -6
  179. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +5 -0
  180. package/lib/dependencies/HarmonyExportExpressionDependency.js +20 -3
  181. package/lib/dependencies/HarmonyExportHeaderDependency.js +13 -0
  182. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +22 -6
  183. package/lib/dependencies/HarmonyExportInitFragment.js +2 -1
  184. package/lib/dependencies/HarmonyExportSpecifierDependency.js +12 -0
  185. package/lib/dependencies/HarmonyExports.js +11 -5
  186. package/lib/dependencies/HarmonyImportDependency.js +10 -1
  187. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +53 -22
  188. package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -2
  189. package/lib/dependencies/HarmonyImportSpecifierDependency.js +139 -16
  190. package/lib/dependencies/HarmonyModulesPlugin.js +23 -5
  191. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
  192. package/lib/dependencies/ImportContextDependency.js +15 -0
  193. package/lib/dependencies/ImportDependency.js +15 -4
  194. package/lib/dependencies/ImportEagerDependency.js +7 -4
  195. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +51 -13
  196. package/lib/dependencies/ImportMetaContextPlugin.js +18 -5
  197. package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
  198. package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
  199. package/lib/dependencies/ImportMetaPlugin.js +103 -51
  200. package/lib/dependencies/ImportParserPlugin.js +83 -25
  201. package/lib/dependencies/ImportPlugin.js +21 -7
  202. package/lib/dependencies/ImportWeakDependency.js +7 -4
  203. package/lib/dependencies/JsonExportsDependency.js +9 -1
  204. package/lib/dependencies/LocalModule.js +16 -0
  205. package/lib/dependencies/LocalModuleDependency.js +15 -0
  206. package/lib/dependencies/LocalModulesHelpers.js +18 -0
  207. package/lib/dependencies/ModuleDecoratorDependency.js +8 -0
  208. package/lib/dependencies/ModuleDependency.js +9 -1
  209. package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
  210. package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
  211. package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
  212. package/lib/dependencies/PrefetchDependency.js +3 -0
  213. package/lib/dependencies/ProvidedDependency.js +14 -2
  214. package/lib/dependencies/PureExpressionDependency.js +10 -1
  215. package/lib/dependencies/RequireContextDependency.js +6 -0
  216. package/lib/dependencies/RequireContextDependencyParserPlugin.js +13 -5
  217. package/lib/dependencies/RequireContextPlugin.js +19 -6
  218. package/lib/dependencies/RequireEnsureDependenciesBlock.js +7 -0
  219. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +6 -1
  220. package/lib/dependencies/RequireEnsureDependency.js +16 -2
  221. package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
  222. package/lib/dependencies/RequireEnsurePlugin.js +27 -7
  223. package/lib/dependencies/RequireHeaderDependency.js +14 -1
  224. package/lib/dependencies/RequireIncludeDependency.js +5 -0
  225. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +29 -5
  226. package/lib/dependencies/RequireIncludePlugin.js +25 -5
  227. package/lib/dependencies/RequireResolveContextDependency.js +17 -0
  228. package/lib/dependencies/RequireResolveDependency.js +6 -0
  229. package/lib/dependencies/RequireResolveHeaderDependency.js +18 -0
  230. package/lib/dependencies/RuntimeRequirementsDependency.js +8 -0
  231. package/lib/dependencies/StaticExportsDependency.js +8 -0
  232. package/lib/dependencies/SystemPlugin.js +48 -21
  233. package/lib/dependencies/SystemRuntimeModule.js +1 -1
  234. package/lib/dependencies/URLDependency.js +13 -4
  235. package/lib/dependencies/URLPlugin.js +31 -18
  236. package/lib/dependencies/UnsupportedDependency.js +13 -0
  237. package/lib/dependencies/WebAssemblyExportImportedDependency.js +14 -0
  238. package/lib/dependencies/WebAssemblyImportDependency.js +9 -1
  239. package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
  240. package/lib/dependencies/WorkerDependency.js +47 -3
  241. package/lib/dependencies/WorkerPlugin.js +105 -32
  242. package/lib/dependencies/getFunctionExpression.js +7 -0
  243. package/lib/esm/ExportWebpackRequireRuntimeModule.js +3 -2
  244. package/lib/esm/ModuleChunkFormatPlugin.js +21 -8
  245. package/lib/esm/ModuleChunkLoadingPlugin.js +9 -0
  246. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +19 -12
  247. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
  248. package/lib/hmr/LazyCompilationPlugin.js +14 -5
  249. package/lib/ids/ChunkModuleIdRangePlugin.js +11 -0
  250. package/lib/ids/DeterministicChunkIdsPlugin.js +11 -2
  251. package/lib/ids/DeterministicModuleIdsPlugin.js +11 -7
  252. package/lib/ids/HashedModuleIdsPlugin.js +9 -2
  253. package/lib/ids/IdHelpers.js +6 -0
  254. package/lib/ids/NamedChunkIdsPlugin.js +13 -1
  255. package/lib/ids/NamedModuleIdsPlugin.js +14 -3
  256. package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
  257. package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
  258. package/lib/ids/SyncModuleIdsPlugin.js +3 -2
  259. package/lib/index.js +8 -0
  260. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +3 -3
  261. package/lib/javascript/BasicEvaluatedExpression.js +137 -11
  262. package/lib/javascript/ChunkHelpers.js +2 -2
  263. package/lib/javascript/CommonJsChunkFormatPlugin.js +7 -3
  264. package/lib/javascript/EnableChunkLoadingPlugin.js +4 -0
  265. package/lib/javascript/JavascriptModulesPlugin.js +194 -194
  266. package/lib/javascript/JavascriptParser.js +941 -256
  267. package/lib/javascript/JavascriptParserHelpers.js +37 -15
  268. package/lib/javascript/StartupHelpers.js +2 -2
  269. package/lib/json/JsonData.js +26 -1
  270. package/lib/json/JsonGenerator.js +21 -7
  271. package/lib/json/JsonModulesPlugin.js +14 -5
  272. package/lib/json/JsonParser.js +27 -13
  273. package/lib/library/AbstractLibraryPlugin.js +4 -0
  274. package/lib/library/AmdLibraryPlugin.js +22 -6
  275. package/lib/library/AssignLibraryPlugin.js +6 -4
  276. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  277. package/lib/library/ModuleLibraryPlugin.js +8 -4
  278. package/lib/library/SystemLibraryPlugin.js +1 -0
  279. package/lib/library/UmdLibraryPlugin.js +4 -0
  280. package/lib/logging/runtime.js +1 -1
  281. package/lib/logging/truncateArgs.js +4 -0
  282. package/lib/node/CommonJsChunkLoadingPlugin.js +17 -2
  283. package/lib/node/NodeTargetPlugin.js +3 -0
  284. package/lib/node/NodeTemplatePlugin.js +10 -2
  285. package/lib/node/NodeWatchFileSystem.js +1 -1
  286. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +18 -9
  287. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +12 -2
  288. package/lib/node/ReadFileCompileWasmPlugin.js +21 -3
  289. package/lib/node/RequireChunkLoadingRuntimeModule.js +15 -8
  290. package/lib/node/nodeConsole.js +2 -4
  291. package/lib/optimize/AggressiveMergingPlugin.js +8 -0
  292. package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
  293. package/lib/optimize/ConcatenatedModule.js +8 -6
  294. package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
  295. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
  296. package/lib/optimize/InnerGraph.js +5 -5
  297. package/lib/optimize/InnerGraphPlugin.js +57 -48
  298. package/lib/optimize/LimitChunkCountPlugin.js +29 -4
  299. package/lib/optimize/MangleExportsPlugin.js +1 -1
  300. package/lib/optimize/MinMaxSizeWarning.js +5 -0
  301. package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
  302. package/lib/optimize/RealContentHashPlugin.js +86 -30
  303. package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
  304. package/lib/optimize/RuntimeChunkPlugin.js +9 -1
  305. package/lib/optimize/SideEffectsFlagPlugin.js +53 -44
  306. package/lib/optimize/SplitChunksPlugin.js +71 -31
  307. package/lib/performance/SizeLimitsPlugin.js +7 -4
  308. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
  309. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
  310. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +6 -3
  311. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -2
  312. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -2
  313. package/lib/rules/BasicEffectRulePlugin.js +4 -0
  314. package/lib/rules/BasicMatcherRulePlugin.js +5 -0
  315. package/lib/rules/RuleSetCompiler.js +3 -3
  316. package/lib/rules/UseEffectRulePlugin.js +6 -4
  317. package/lib/runtime/AsyncModuleRuntimeModule.js +9 -6
  318. package/lib/runtime/AutoPublicPathRuntimeModule.js +16 -5
  319. package/lib/runtime/BaseUriRuntimeModule.js +8 -4
  320. package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
  321. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
  322. package/lib/runtime/CompatRuntimeModule.js +7 -2
  323. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +5 -2
  324. package/lib/runtime/CreateScriptRuntimeModule.js +4 -2
  325. package/lib/runtime/CreateScriptUrlRuntimeModule.js +4 -2
  326. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +5 -2
  327. package/lib/runtime/EnsureChunkRuntimeModule.js +18 -4
  328. package/lib/runtime/GetChunkFilenameRuntimeModule.js +45 -26
  329. package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
  330. package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
  331. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +27 -6
  332. package/lib/runtime/GlobalRuntimeModule.js +1 -1
  333. package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
  334. package/lib/runtime/LoadScriptRuntimeModule.js +65 -50
  335. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
  336. package/lib/runtime/NonceRuntimeModule.js +1 -1
  337. package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
  338. package/lib/runtime/PublicPathRuntimeModule.js +9 -2
  339. package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
  340. package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
  341. package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
  342. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +13 -4
  343. package/lib/runtime/StartupEntrypointRuntimeModule.js +11 -7
  344. package/lib/runtime/SystemContextRuntimeModule.js +1 -1
  345. package/lib/schemes/DataUriPlugin.js +16 -3
  346. package/lib/schemes/HttpUriPlugin.js +38 -0
  347. package/lib/serialization/ArraySerializer.js +22 -6
  348. package/lib/serialization/BinaryMiddleware.js +164 -1
  349. package/lib/serialization/DateObjectSerializer.js +15 -4
  350. package/lib/serialization/ErrorObjectSerializer.js +23 -8
  351. package/lib/serialization/FileMiddleware.js +17 -0
  352. package/lib/serialization/MapObjectSerializer.js +24 -8
  353. package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
  354. package/lib/serialization/ObjectMiddleware.js +33 -2
  355. package/lib/serialization/PlainObjectSerializer.js +23 -12
  356. package/lib/serialization/RegExpObjectSerializer.js +16 -5
  357. package/lib/serialization/SetObjectSerializer.js +21 -6
  358. package/lib/serialization/types.js +1 -1
  359. package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
  360. package/lib/sharing/ConsumeSharedModule.js +13 -2
  361. package/lib/sharing/ConsumeSharedPlugin.js +4 -0
  362. package/lib/sharing/ConsumeSharedRuntimeModule.js +22 -7
  363. package/lib/sharing/ProvideSharedDependency.js +17 -0
  364. package/lib/sharing/ProvideSharedModule.js +11 -1
  365. package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
  366. package/lib/sharing/ProvideSharedPlugin.js +22 -21
  367. package/lib/sharing/ShareRuntimeModule.js +19 -9
  368. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  369. package/lib/sharing/utils.js +320 -7
  370. package/lib/stats/DefaultStatsFactoryPlugin.js +105 -29
  371. package/lib/stats/DefaultStatsPresetPlugin.js +9 -0
  372. package/lib/stats/DefaultStatsPrinterPlugin.js +43 -0
  373. package/lib/util/AsyncQueue.js +4 -2
  374. package/lib/util/LazySet.js +10 -2
  375. package/lib/util/MapHelpers.js +19 -5
  376. package/lib/util/ParallelismFactorCalculator.js +10 -0
  377. package/lib/util/Semaphore.js +1 -1
  378. package/lib/util/StackedCacheMap.js +6 -0
  379. package/lib/util/StringXor.js +51 -0
  380. package/lib/util/binarySearchBounds.js +49 -0
  381. package/lib/util/compileBooleanMatcher.js +31 -0
  382. package/lib/util/createHash.js +35 -13
  383. package/lib/util/deprecation.js +18 -3
  384. package/lib/util/deterministicGrouping.js +50 -11
  385. package/lib/util/findGraphRoots.js +4 -2
  386. package/lib/util/hash/md4.js +2 -2
  387. package/lib/util/hash/xxhash64.js +1 -1
  388. package/lib/util/identifier.js +4 -0
  389. package/lib/util/internalSerializables.js +1 -0
  390. package/lib/util/makeSerializable.js +7 -0
  391. package/lib/util/memoize.js +3 -3
  392. package/lib/util/numberHash.js +75 -21
  393. package/lib/util/processAsyncTree.js +7 -1
  394. package/lib/util/propertyAccess.js +9 -54
  395. package/lib/util/propertyName.js +79 -0
  396. package/lib/util/registerExternalSerializer.js +1 -1
  397. package/lib/util/runtime.js +14 -1
  398. package/lib/util/semver.js +1 -1
  399. package/lib/util/serialization.js +10 -0
  400. package/lib/util/smartGrouping.js +1 -1
  401. package/lib/validateSchema.js +6 -2
  402. package/lib/wasm/EnableWasmLoadingPlugin.js +4 -0
  403. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +15 -2
  404. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
  405. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +14 -3
  406. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +28 -8
  407. package/lib/wasm-async/AsyncWebAssemblyParser.js +11 -4
  408. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +39 -8
  409. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +17 -6
  410. package/lib/wasm-sync/WebAssemblyGenerator.js +19 -5
  411. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  412. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +53 -43
  413. package/lib/wasm-sync/WebAssemblyParser.js +15 -4
  414. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  415. package/lib/web/FetchCompileAsyncWasmPlugin.js +11 -1
  416. package/lib/web/FetchCompileWasmPlugin.js +59 -42
  417. package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
  418. package/lib/web/JsonpChunkLoadingRuntimeModule.js +26 -9
  419. package/lib/webpack.js +12 -3
  420. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +9 -0
  421. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +20 -17
  422. package/module.d.ts +55 -37
  423. package/package.json +59 -56
  424. package/schemas/WebpackOptions.check.js +1 -1
  425. package/schemas/WebpackOptions.json +132 -5
  426. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  427. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  428. package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
  429. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  430. package/schemas/plugins/container/ContainerPlugin.json +8 -0
  431. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  432. package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
  433. package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
  434. package/schemas/plugins/css/CssParserOptions.json +1 -1
  435. package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
  436. package/types.d.ts +1608 -667
@@ -78,7 +78,7 @@ exports.arrayToSetDeprecation = (set, name) => {
78
78
  );
79
79
  /**
80
80
  * @deprecated
81
- * @this {Set}
81
+ * @this {Set<any>}
82
82
  * @returns {number} count
83
83
  */
84
84
  set[method] = function () {
@@ -101,7 +101,7 @@ exports.arrayToSetDeprecation = (set, name) => {
101
101
  );
102
102
  /**
103
103
  * @deprecated
104
- * @this {Set}
104
+ * @this {Set<any>}
105
105
  * @returns {number} count
106
106
  */
107
107
  set.push = function () {
@@ -119,9 +119,13 @@ exports.arrayToSetDeprecation = (set, name) => {
119
119
  );
120
120
  };
121
121
  }
122
+ /**
123
+ * @param {number} index index
124
+ * @returns {any} value
125
+ */
122
126
  const createIndexGetter = index => {
123
127
  /**
124
- * @this {Set} a Set
128
+ * @this {Set<any>} a Set
125
129
  * @returns {any} the value at this location
126
130
  */
127
131
  const fn = function () {
@@ -134,6 +138,9 @@ exports.arrayToSetDeprecation = (set, name) => {
134
138
  };
135
139
  return fn;
136
140
  };
141
+ /**
142
+ * @param {number} index index
143
+ */
137
144
  const defineIndexGetter = index => {
138
145
  Object.defineProperty(set, index, {
139
146
  get: createIndexGetter(index),
@@ -178,6 +185,14 @@ exports.createArrayToSetDeprecationSet = name => {
178
185
  return SetDeprecatedArray;
179
186
  };
180
187
 
188
+ /**
189
+ * @template T
190
+ * @param {Object} obj object
191
+ * @param {string} name property name
192
+ * @param {string} code deprecation code
193
+ * @param {string} note additional note
194
+ * @returns {Object} frozen object with deprecation when modifying
195
+ */
181
196
  exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
182
197
  const message = `${name} will be frozen in future, all modifications are deprecated.${
183
198
  note && `\n${note}`
@@ -94,7 +94,8 @@ const subtractSizeFrom = (total, size) => {
94
94
  };
95
95
 
96
96
  /**
97
- * @param {Iterable<Node>} nodes some nodes
97
+ * @template T
98
+ * @param {Iterable<Node<T>>} nodes some nodes
98
99
  * @returns {Record<string, number>} total size
99
100
  */
100
101
  const sumSize = nodes => {
@@ -105,6 +106,11 @@ const sumSize = nodes => {
105
106
  return sum;
106
107
  };
107
108
 
109
+ /**
110
+ * @param {Record<string, number>} size size
111
+ * @param {Record<string, number>} maxSize minimum size
112
+ * @returns {boolean} true, when size is too big
113
+ */
108
114
  const isTooBig = (size, maxSize) => {
109
115
  for (const key of Object.keys(size)) {
110
116
  const s = size[key];
@@ -117,6 +123,11 @@ const isTooBig = (size, maxSize) => {
117
123
  return false;
118
124
  };
119
125
 
126
+ /**
127
+ * @param {Record<string, number>} size size
128
+ * @param {Record<string, number>} minSize minimum size
129
+ * @returns {boolean} true, when size is too small
130
+ */
120
131
  const isTooSmall = (size, minSize) => {
121
132
  for (const key of Object.keys(size)) {
122
133
  const s = size[key];
@@ -129,6 +140,11 @@ const isTooSmall = (size, minSize) => {
129
140
  return false;
130
141
  };
131
142
 
143
+ /**
144
+ * @param {Record<string, number>} size size
145
+ * @param {Record<string, number>} minSize minimum size
146
+ * @returns {Set<string>} set of types that are too small
147
+ */
132
148
  const getTooSmallTypes = (size, minSize) => {
133
149
  const types = new Set();
134
150
  for (const key of Object.keys(size)) {
@@ -142,6 +158,12 @@ const getTooSmallTypes = (size, minSize) => {
142
158
  return types;
143
159
  };
144
160
 
161
+ /**
162
+ * @template T
163
+ * @param {TODO} size size
164
+ * @param {Set<string>} types types
165
+ * @returns {number} number of matching size types
166
+ */
145
167
  const getNumberOfMatchingSizeTypes = (size, types) => {
146
168
  let i = 0;
147
169
  for (const key of Object.keys(size)) {
@@ -150,6 +172,11 @@ const getNumberOfMatchingSizeTypes = (size, types) => {
150
172
  return i;
151
173
  };
152
174
 
175
+ /**
176
+ * @param {Record<string, number>} size size
177
+ * @param {Set<string>} types types
178
+ * @returns {number} selective size sum
179
+ */
153
180
  const selectiveSizeSum = (size, types) => {
154
181
  let sum = 0;
155
182
  for (const key of Object.keys(size)) {
@@ -180,20 +207,20 @@ class Node {
180
207
  class Group {
181
208
  /**
182
209
  * @param {Node<T>[]} nodes nodes
183
- * @param {number[]} similarities similarities between the nodes (length = nodes.length - 1)
210
+ * @param {number[] | null} similarities similarities between the nodes (length = nodes.length - 1)
184
211
  * @param {Record<string, number>=} size size of the group
185
212
  */
186
213
  constructor(nodes, similarities, size) {
187
214
  this.nodes = nodes;
188
215
  this.similarities = similarities;
189
216
  this.size = size || sumSize(nodes);
190
- /** @type {string} */
217
+ /** @type {string | undefined} */
191
218
  this.key = undefined;
192
219
  }
193
220
 
194
221
  /**
195
- * @param {function(Node): boolean} filter filter function
196
- * @returns {Node[]} removed nodes
222
+ * @param {function(Node<T>): boolean} filter filter function
223
+ * @returns {Node<T>[] | undefined} removed nodes
197
224
  */
198
225
  popNodes(filter) {
199
226
  const newNodes = [];
@@ -208,7 +235,7 @@ class Group {
208
235
  if (newNodes.length > 0) {
209
236
  newSimilarities.push(
210
237
  lastNode === this.nodes[i - 1]
211
- ? this.similarities[i - 1]
238
+ ? /** @type {number[]} */ (this.similarities)[i - 1]
212
239
  : similarity(lastNode.key, node.key)
213
240
  );
214
241
  }
@@ -225,7 +252,8 @@ class Group {
225
252
  }
226
253
 
227
254
  /**
228
- * @param {Iterable<Node>} nodes nodes
255
+ * @template T
256
+ * @param {Iterable<Node<T>>} nodes nodes
229
257
  * @returns {number[]} similarities
230
258
  */
231
259
  const getSimilarities = nodes => {
@@ -297,6 +325,11 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
297
325
  if (initialNodes.length > 0) {
298
326
  const initialGroup = new Group(initialNodes, getSimilarities(initialNodes));
299
327
 
328
+ /**
329
+ * @param {Group<T>} group group
330
+ * @param {Record<string, number>} consideredSize size of the group to consider
331
+ * @returns {boolean} true, if the group was modified
332
+ */
300
333
  const removeProblematicNodes = (group, consideredSize = group.size) => {
301
334
  const problemTypes = getTooSmallTypes(consideredSize, minSize);
302
335
  if (problemTypes.size > 0) {
@@ -347,7 +380,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
347
380
  const queue = [initialGroup];
348
381
 
349
382
  while (queue.length) {
350
- const group = queue.pop();
383
+ const group = /** @type {Group<T>} */ (queue.pop());
351
384
  // only groups bigger than maxSize need to be splitted
352
385
  if (!isTooBig(group.size, maxSize)) {
353
386
  result.push(group);
@@ -428,7 +461,9 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
428
461
  // rightSize ^^^^^^^^^^^^^^^
429
462
 
430
463
  while (pos <= right + 1) {
431
- const similarity = group.similarities[pos - 1];
464
+ const similarity = /** @type {number[]} */ (group.similarities)[
465
+ pos - 1
466
+ ];
432
467
  if (
433
468
  similarity < bestSimilarity &&
434
469
  !isTooSmall(leftSize, minSize) &&
@@ -458,7 +493,9 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
458
493
  /** @type {number[]} */
459
494
  const rightSimilarities = [];
460
495
  for (let i = right + 2; i < group.nodes.length; i++) {
461
- rightSimilarities.push(group.similarities[i - 1]);
496
+ rightSimilarities.push(
497
+ /** @type {number[]} */ (group.similarities)[i - 1]
498
+ );
462
499
  rightNodes.push(group.nodes[i]);
463
500
  }
464
501
  queue.push(new Group(rightNodes, rightSimilarities));
@@ -467,7 +504,9 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
467
504
  /** @type {number[]} */
468
505
  const leftSimilarities = [];
469
506
  for (let i = 1; i < left; i++) {
470
- leftSimilarities.push(group.similarities[i - 1]);
507
+ leftSimilarities.push(
508
+ /** @type {number[]} */ (group.similarities)[i - 1]
509
+ );
471
510
  leftNodes.push(group.nodes[i]);
472
511
  }
473
512
  queue.push(new Group(leftNodes, leftSimilarities));
@@ -109,7 +109,9 @@ module.exports = (items, getDependencies) => {
109
109
  // Are there still edges unprocessed in the current node?
110
110
  if (topOfStack.openEdges.length > 0) {
111
111
  // Process one dependency
112
- const dependency = topOfStack.openEdges.pop();
112
+ const dependency =
113
+ /** @type {Node<T>} */
114
+ (topOfStack.openEdges.pop());
113
115
  switch (dependency.marker) {
114
116
  case NO_MARKER:
115
117
  // dependency has not be visited yet
@@ -169,7 +171,7 @@ module.exports = (items, getDependencies) => {
169
171
  // so it's not really a root cycle
170
172
  // remove the cycle from the root cycles
171
173
  // and convert it to a normal node
172
- rootCycles.delete(dependency.cycle);
174
+ rootCycles.delete(/** @type {Cycle<T>} */ (dependency.cycle));
173
175
  dependency.marker = DONE_MARKER;
174
176
  break;
175
177
  // DONE_MARKER: nothing to do, don't recurse into dependencies
@@ -10,8 +10,8 @@ const create = require("./wasm-hash");
10
10
  //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
11
11
  const md4 = new WebAssembly.Module(
12
12
  Buffer.from(
13
- // 2156 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwUEAQA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D+DQgiGhCIEQo+AvIDwgcAHg0IIhiAEQvCBwIeAnoD4AINCBIiEIgRChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IARCsODAgYOGjJgwhHw3AwBBGCMErSIEQv//A4MgBEKAgPz/D4NCEIaEIgRC/4GAgPAfgyAEQoD+g4CA4D+DQgiGhCIEQo+AvIDwgcAHg0IIhiAEQvCBwIeAnoD4AINCBIiEIgRChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IARCsODAgYOGjJgwhHw3AwAL",
15
15
  "base64"
16
16
  )
17
17
  );
@@ -11,7 +11,7 @@ const create = require("./wasm-hash");
11
11
  const xxhash64 = new WebAssembly.Module(
12
12
  Buffer.from(
13
13
  // 1170 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrIIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLqAYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gA0LP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAEQs/W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goSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
15
15
  "base64"
16
16
  )
17
17
  );
@@ -15,6 +15,10 @@ const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
15
15
  * @property {Map<string, Map<string, string>>=} relativePaths
16
16
  */
17
17
 
18
+ /**
19
+ * @param {string} relativePath relative path
20
+ * @returns {string} request
21
+ */
18
22
  const relativePathToRequest = relativePath => {
19
23
  if (relativePath === "") return "./.";
20
24
  if (relativePath === "..") return "../.";
@@ -189,6 +189,7 @@ module.exports = {
189
189
  ModuleParseError: () => require("../ModuleParseError"),
190
190
  ModuleWarning: () => require("../ModuleWarning"),
191
191
  NormalModule: () => require("../NormalModule"),
192
+ CssModule: () => require("../CssModule"),
192
193
  RawDataUrlModule: () => require("../asset/RawDataUrlModule"),
193
194
  RawModule: () => require("../RawModule"),
194
195
  "sharing/ConsumeSharedModule": () =>
@@ -6,6 +6,8 @@
6
6
 
7
7
  const { register } = require("./serialization");
8
8
 
9
+ /** @typedef {import("../serialization/ObjectMiddleware").Constructor} Constructor */
10
+
9
11
  class ClassSerializer {
10
12
  constructor(Constructor) {
11
13
  this.Constructor = Constructor;
@@ -25,6 +27,11 @@ class ClassSerializer {
25
27
  }
26
28
  }
27
29
 
30
+ /**
31
+ * @param {Constructor} Constructor the constructor
32
+ * @param {string} request the request which will be required when deserializing
33
+ * @param {string | null} [name] the name to make multiple serializer unique when sharing a request
34
+ */
28
35
  module.exports = (Constructor, request, name = null) => {
29
36
  register(Constructor, request, name, new ClassSerializer(Constructor));
30
37
  };
@@ -13,18 +13,18 @@
13
13
  */
14
14
  const memoize = fn => {
15
15
  let cache = false;
16
- /** @type {T} */
16
+ /** @type {T | undefined} */
17
17
  let result = undefined;
18
18
  return () => {
19
19
  if (cache) {
20
- return result;
20
+ return /** @type {T} */ (result);
21
21
  } else {
22
22
  result = fn();
23
23
  cache = true;
24
24
  // Allow to clean up memory for fn
25
25
  // and all dependent resources
26
26
  fn = undefined;
27
- return result;
27
+ return /** @type {T} */ (result);
28
28
  }
29
29
  };
30
30
  };
@@ -5,41 +5,95 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ /**
9
+ * The maximum safe integer value for 32-bit integers.
10
+ * @type {number}
11
+ */
8
12
  const SAFE_LIMIT = 0x80000000;
13
+
14
+ /**
15
+ * The maximum safe integer value for 32-bit integers minus one. This is used
16
+ * in the algorithm to ensure that intermediate hash values do not exceed the
17
+ * 32-bit integer limit.
18
+ * @type {number}
19
+ */
9
20
  const SAFE_PART = SAFE_LIMIT - 1;
21
+
22
+ /**
23
+ * The number of 32-bit integers used to store intermediate hash values.
24
+ * @type {number}
25
+ */
10
26
  const COUNT = 4;
27
+
28
+ /**
29
+ * An array used to store intermediate hash values during the calculation.
30
+ * @type {number[]}
31
+ */
11
32
  const arr = [0, 0, 0, 0, 0];
33
+
34
+ /**
35
+ * An array of prime numbers used in the hash calculation.
36
+ * @type {number[]}
37
+ */
12
38
  const primes = [3, 7, 17, 19];
13
39
 
40
+ /**
41
+ * Computes a hash value for the given string and range. This hashing algorithm is a modified
42
+ * version of the [FNV-1a algorithm](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function).
43
+ * It is optimized for speed and does **not** generate a cryptographic hash value.
44
+ *
45
+ * We use `numberHash` in `lib/ids/IdHelpers.js` to generate hash values for the module identifier. The generated
46
+ * hash is used as a prefix for the module id's to avoid collisions with other modules.
47
+ *
48
+ * @param {string} str The input string to hash.
49
+ * @param {number} range The range of the hash value (0 to range-1).
50
+ * @returns {number} - The computed hash value.
51
+ *
52
+ * @example
53
+ *
54
+ * ```js
55
+ * const numberHash = require("webpack/lib/util/numberHash");
56
+ * numberHash("hello", 1000); // 57
57
+ * numberHash("hello world"); // 990
58
+ * ```
59
+ *
60
+ */
14
61
  module.exports = (str, range) => {
62
+ /**
63
+ * Initialize the array with zeros before it is used
64
+ * to store intermediate hash values.
65
+ */
15
66
  arr.fill(0);
67
+ // For each character in the string
16
68
  for (let i = 0; i < str.length; i++) {
69
+ // Get the character code.
17
70
  const c = str.charCodeAt(i);
18
- for (let j = 0; j < COUNT; j++) {
19
- const p = (j + COUNT - 1) % COUNT;
20
- arr[j] = (arr[j] + c * primes[j] + arr[p]) & SAFE_PART;
21
- }
22
- for (let j = 0; j < COUNT; j++) {
23
- const q = arr[j] % COUNT;
24
- arr[j] = arr[j] ^ (arr[q] >> 1);
25
- }
71
+
72
+ // For each 32-bit integer used to store the hash value
73
+ // add the character code to the current hash value and multiply by the prime number and
74
+ // add the previous 32-bit integer.
75
+ arr[0] = (arr[0] + c * primes[0] + arr[3]) & SAFE_PART;
76
+ arr[1] = (arr[1] + c * primes[1] + arr[0]) & SAFE_PART;
77
+ arr[2] = (arr[2] + c * primes[2] + arr[1]) & SAFE_PART;
78
+ arr[3] = (arr[3] + c * primes[3] + arr[2]) & SAFE_PART;
79
+
80
+ // For each 32-bit integer used to store the hash value
81
+ // XOR the current hash value with the value of the next 32-bit integer.
82
+ arr[0] = arr[0] ^ (arr[arr[0] % COUNT] >> 1);
83
+ arr[1] = arr[1] ^ (arr[arr[1] % COUNT] >> 1);
84
+ arr[2] = arr[2] ^ (arr[arr[2] % COUNT] >> 1);
85
+ arr[3] = arr[3] ^ (arr[arr[3] % COUNT] >> 1);
26
86
  }
87
+
27
88
  if (range <= SAFE_PART) {
28
- let sum = 0;
29
- for (let j = 0; j < COUNT; j++) {
30
- sum = (sum + arr[j]) % range;
31
- }
32
- return sum;
89
+ return (arr[0] + arr[1] + arr[2] + arr[3]) % range;
33
90
  } else {
34
- let sum1 = 0;
35
- let sum2 = 0;
91
+ // Calculate the range extension.
36
92
  const rangeExt = Math.floor(range / SAFE_LIMIT);
37
- for (let j = 0; j < COUNT; j += 2) {
38
- sum1 = (sum1 + arr[j]) & SAFE_PART;
39
- }
40
- for (let j = 1; j < COUNT; j += 2) {
41
- sum2 = (sum2 + arr[j]) % rangeExt;
42
- }
93
+
94
+ const sum1 = (arr[0] + arr[2]) & SAFE_PART;
95
+ const sum2 = (arr[0] + arr[2]) % rangeExt;
96
+
43
97
  return (sum2 * SAFE_LIMIT + sum1) % range;
44
98
  }
45
99
  };
@@ -21,6 +21,9 @@ const processAsyncTree = (items, concurrency, processor, callback) => {
21
21
  let finished = false;
22
22
  let processScheduled = true;
23
23
 
24
+ /**
25
+ * @param {T} item item
26
+ */
24
27
  const push = item => {
25
28
  queue.push(item);
26
29
  if (!processScheduled && processing < concurrency) {
@@ -29,6 +32,9 @@ const processAsyncTree = (items, concurrency, processor, callback) => {
29
32
  }
30
33
  };
31
34
 
35
+ /**
36
+ * @param {E | null | undefined} err error
37
+ */
32
38
  const processorCallback = err => {
33
39
  processing--;
34
40
  if (err && !finished) {
@@ -46,7 +52,7 @@ const processAsyncTree = (items, concurrency, processor, callback) => {
46
52
  if (finished) return;
47
53
  while (processing < concurrency && queue.length > 0) {
48
54
  processing++;
49
- const item = queue.pop();
55
+ const item = /** @type {T} */ (queue.pop());
50
56
  processor(item, push, processorCallback);
51
57
  }
52
58
  processScheduled = false;
@@ -5,61 +5,16 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const SAFE_IDENTIFIER = /^[_a-zA-Z$][_a-zA-Z$0-9]*$/;
9
- const RESERVED_IDENTIFIER = new Set([
10
- "break",
11
- "case",
12
- "catch",
13
- "class",
14
- "const",
15
- "continue",
16
- "debugger",
17
- "default",
18
- "delete",
19
- "do",
20
- "else",
21
- "export",
22
- "extends",
23
- "finally",
24
- "for",
25
- "function",
26
- "if",
27
- "import",
28
- "in",
29
- "instanceof",
30
- "new",
31
- "return",
32
- "super",
33
- "switch",
34
- "this",
35
- "throw",
36
- "try",
37
- "typeof",
38
- "var",
39
- "void",
40
- "while",
41
- "with",
42
- "enum",
43
- // strict mode
44
- "implements",
45
- "interface",
46
- "let",
47
- "package",
48
- "private",
49
- "protected",
50
- "public",
51
- "static",
52
- "yield",
53
- "yield",
54
- // module code
55
- "await",
56
- // skip future reserved keywords defined under ES1 till ES3
57
- // additional
58
- "null",
59
- "true",
60
- "false"
61
- ]);
8
+ const {
9
+ SAFE_IDENTIFIER,
10
+ RESERVED_IDENTIFIER
11
+ } = require("../util/propertyName");
62
12
 
13
+ /**
14
+ * @param {ArrayLike<string>} properties properties
15
+ * @param {number} start start index
16
+ * @returns {string} chain of property accesses
17
+ */
63
18
  const propertyAccess = (properties, start = 0) => {
64
19
  let str = "";
65
20
  for (let i = start; i < properties.length; i++) {
@@ -0,0 +1,79 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const SAFE_IDENTIFIER = /^[_a-zA-Z$][_a-zA-Z$0-9]*$/;
9
+ const RESERVED_IDENTIFIER = new Set([
10
+ "break",
11
+ "case",
12
+ "catch",
13
+ "class",
14
+ "const",
15
+ "continue",
16
+ "debugger",
17
+ "default",
18
+ "delete",
19
+ "do",
20
+ "else",
21
+ "export",
22
+ "extends",
23
+ "finally",
24
+ "for",
25
+ "function",
26
+ "if",
27
+ "import",
28
+ "in",
29
+ "instanceof",
30
+ "new",
31
+ "return",
32
+ "super",
33
+ "switch",
34
+ "this",
35
+ "throw",
36
+ "try",
37
+ "typeof",
38
+ "var",
39
+ "void",
40
+ "while",
41
+ "with",
42
+ "enum",
43
+ // strict mode
44
+ "implements",
45
+ "interface",
46
+ "let",
47
+ "package",
48
+ "private",
49
+ "protected",
50
+ "public",
51
+ "static",
52
+ "yield",
53
+ "yield",
54
+ // module code
55
+ "await",
56
+ // skip future reserved keywords defined under ES1 till ES3
57
+ // additional
58
+ "null",
59
+ "true",
60
+ "false"
61
+ ]);
62
+
63
+ /**
64
+ * @summary Returns a valid JS property name for the given property.
65
+ * Certain strings like "default", "null", and names with whitespace are not
66
+ * valid JS property names, so they are returned as strings.
67
+ *
68
+ * @param {string} prop property name to analyze
69
+ * @returns {string} valid JS property name
70
+ */
71
+ const propertyName = prop => {
72
+ if (SAFE_IDENTIFIER.test(prop) && !RESERVED_IDENTIFIER.has(prop)) {
73
+ return prop;
74
+ } else {
75
+ return JSON.stringify(prop);
76
+ }
77
+ };
78
+
79
+ module.exports = { SAFE_IDENTIFIER, RESERVED_IDENTIFIER, propertyName };
@@ -26,7 +26,7 @@ const {
26
26
  /** @typedef {import("./serialization").ObjectDeserializerContext} ObjectDeserializerContext */
27
27
  /** @typedef {import("./serialization").ObjectSerializerContext} ObjectSerializerContext */
28
28
 
29
- /** @typedef {ObjectSerializerContext & { writeLazy?: (any) => void }} WebpackObjectSerializerContext */
29
+ /** @typedef {ObjectSerializerContext & { writeLazy?: (value: any) => void }} WebpackObjectSerializerContext */
30
30
 
31
31
  const CURRENT_MODULE = "webpack/lib/util/registerExternalSerializer";
32
32