webpack 5.101.3 → 5.102.1

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 (339) hide show
  1. package/README.md +21 -26
  2. package/lib/APIPlugin.js +30 -36
  3. package/lib/AsyncDependenciesBlock.js +1 -4
  4. package/lib/BannerPlugin.js +0 -1
  5. package/lib/Cache.js +7 -6
  6. package/lib/CacheFacade.js +0 -1
  7. package/lib/Chunk.js +49 -31
  8. package/lib/ChunkGraph.js +37 -27
  9. package/lib/ChunkGroup.js +8 -10
  10. package/lib/ChunkTemplate.js +1 -1
  11. package/lib/CleanPlugin.js +3 -3
  12. package/lib/CodeGenerationResults.js +3 -2
  13. package/lib/CompatibilityPlugin.js +29 -12
  14. package/lib/Compilation.js +209 -196
  15. package/lib/Compiler.js +36 -35
  16. package/lib/ConcatenationScope.js +6 -1
  17. package/lib/ConditionalInitFragment.js +1 -1
  18. package/lib/ConstPlugin.js +6 -5
  19. package/lib/ContextExclusionPlugin.js +0 -1
  20. package/lib/ContextModule.js +25 -21
  21. package/lib/ContextModuleFactory.js +30 -11
  22. package/lib/ContextReplacementPlugin.js +38 -15
  23. package/lib/DefinePlugin.js +5 -9
  24. package/lib/DelegatedModule.js +7 -11
  25. package/lib/DependenciesBlock.js +0 -2
  26. package/lib/Dependency.js +9 -11
  27. package/lib/DependencyTemplates.js +2 -4
  28. package/lib/DllModule.js +1 -7
  29. package/lib/DllReferencePlugin.js +2 -4
  30. package/lib/DynamicEntryPlugin.js +0 -2
  31. package/lib/EntryOptionPlugin.js +0 -5
  32. package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
  33. package/lib/EvalDevToolModulePlugin.js +4 -3
  34. package/lib/EvalSourceMapDevToolPlugin.js +3 -4
  35. package/lib/ExportsInfo.js +50 -49
  36. package/lib/ExternalModule.js +84 -52
  37. package/lib/ExternalModuleFactoryPlugin.js +27 -7
  38. package/lib/ExternalsPlugin.js +24 -17
  39. package/lib/FileSystemInfo.js +105 -90
  40. package/lib/FlagDependencyUsagePlugin.js +3 -4
  41. package/lib/Generator.js +2 -13
  42. package/lib/GraphHelpers.js +0 -3
  43. package/lib/HookWebpackError.js +0 -2
  44. package/lib/HotModuleReplacementPlugin.js +22 -24
  45. package/lib/HotUpdateChunk.js +0 -3
  46. package/lib/IgnorePlugin.js +5 -2
  47. package/lib/InitFragment.js +41 -29
  48. package/lib/InvalidDependenciesModuleWarning.js +0 -1
  49. package/lib/LibManifestPlugin.js +4 -6
  50. package/lib/LoaderOptionsPlugin.js +1 -10
  51. package/lib/MainTemplate.js +8 -19
  52. package/lib/Module.js +32 -20
  53. package/lib/ModuleFactory.js +1 -1
  54. package/lib/ModuleFilenameHelpers.js +42 -25
  55. package/lib/ModuleGraph.js +30 -16
  56. package/lib/ModuleInfoHeaderPlugin.js +0 -1
  57. package/lib/ModuleTemplate.js +0 -2
  58. package/lib/ModuleTypeConstants.js +11 -1
  59. package/lib/MultiCompiler.js +23 -15
  60. package/lib/MultiWatching.js +6 -10
  61. package/lib/NodeStuffPlugin.js +2 -10
  62. package/lib/NormalModule.js +146 -89
  63. package/lib/NormalModuleFactory.js +132 -42
  64. package/lib/OptionsApply.js +1 -1
  65. package/lib/Parser.js +1 -1
  66. package/lib/ProgressPlugin.js +6 -10
  67. package/lib/ProvidePlugin.js +5 -7
  68. package/lib/RawModule.js +1 -6
  69. package/lib/RecordIdsPlugin.js +10 -6
  70. package/lib/ResolverFactory.js +0 -2
  71. package/lib/RuntimeGlobals.js +5 -0
  72. package/lib/RuntimeModule.js +1 -3
  73. package/lib/RuntimePlugin.js +26 -22
  74. package/lib/RuntimeTemplate.js +22 -12
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
  76. package/lib/SourceMapDevToolPlugin.js +11 -18
  77. package/lib/Stats.js +0 -1
  78. package/lib/Template.js +6 -11
  79. package/lib/TemplatedPathPlugin.js +2 -1
  80. package/lib/WatchIgnorePlugin.js +2 -3
  81. package/lib/Watching.js +15 -15
  82. package/lib/WebpackIsIncludedPlugin.js +0 -2
  83. package/lib/WebpackOptionsApply.js +74 -107
  84. package/lib/asset/AssetBytesGenerator.js +167 -0
  85. package/lib/asset/AssetBytesParser.js +37 -0
  86. package/lib/asset/AssetGenerator.js +22 -37
  87. package/lib/asset/AssetModulesPlugin.js +34 -16
  88. package/lib/asset/AssetParser.js +7 -3
  89. package/lib/asset/AssetSourceGenerator.js +1 -1
  90. package/lib/asset/RawDataUrlModule.js +3 -2
  91. package/lib/async-modules/AsyncModuleHelpers.js +6 -4
  92. package/lib/buildChunkGraph.js +0 -1
  93. package/lib/cache/MemoryCachePlugin.js +0 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
  95. package/lib/cache/PackFileCacheStrategy.js +14 -1
  96. package/lib/cache/ResolverCachePlugin.js +9 -15
  97. package/lib/cache/getLazyHashedEtag.js +1 -1
  98. package/lib/config/browserslistTargetHandler.js +77 -76
  99. package/lib/config/defaults.js +162 -23
  100. package/lib/config/normalization.js +18 -3
  101. package/lib/config/target.js +1 -1
  102. package/lib/container/ContainerEntryDependency.js +0 -1
  103. package/lib/container/ContainerEntryModule.js +3 -7
  104. package/lib/container/ContainerPlugin.js +1 -2
  105. package/lib/container/ContainerReferencePlugin.js +0 -1
  106. package/lib/container/FallbackDependency.js +2 -1
  107. package/lib/container/FallbackModule.js +6 -7
  108. package/lib/container/ModuleFederationPlugin.js +0 -1
  109. package/lib/container/RemoteModule.js +8 -8
  110. package/lib/container/RemoteRuntimeModule.js +2 -2
  111. package/lib/css/CssGenerator.js +3 -6
  112. package/lib/css/CssLoadingRuntimeModule.js +6 -9
  113. package/lib/css/CssModulesPlugin.js +13 -19
  114. package/lib/css/CssParser.js +3 -3
  115. package/lib/css/walkCssTokens.js +2 -2
  116. package/lib/debug/ProfilingPlugin.js +35 -8
  117. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
  118. package/lib/dependencies/AMDPlugin.js +2 -2
  119. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
  120. package/lib/dependencies/CachedConstDependency.js +0 -4
  121. package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
  122. package/lib/dependencies/CommonJsExportsDependency.js +2 -1
  123. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
  124. package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
  125. package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
  126. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  127. package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
  128. package/lib/dependencies/ConstDependency.js +2 -2
  129. package/lib/dependencies/ContextDependency.js +9 -4
  130. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  131. package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
  132. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
  133. package/lib/dependencies/ContextElementDependency.js +22 -11
  134. package/lib/dependencies/CssIcssImportDependency.js +0 -2
  135. package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
  136. package/lib/dependencies/CssImportDependency.js +0 -8
  137. package/lib/dependencies/CssLocalIdentifierDependency.js +4 -7
  138. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
  139. package/lib/dependencies/CssUrlDependency.js +0 -6
  140. package/lib/dependencies/ExportsInfoDependency.js +7 -9
  141. package/lib/dependencies/ExternalModuleDependency.js +0 -3
  142. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  143. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  144. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
  145. package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
  146. package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
  147. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
  148. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
  149. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
  150. package/lib/dependencies/HarmonyImportDependency.js +33 -14
  151. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
  152. package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
  153. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
  154. package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
  155. package/lib/dependencies/ImportContextDependency.js +13 -0
  156. package/lib/dependencies/ImportDependency.js +18 -6
  157. package/lib/dependencies/ImportEagerDependency.js +2 -3
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
  159. package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
  160. package/lib/dependencies/ImportMetaPlugin.js +3 -2
  161. package/lib/dependencies/ImportParserPlugin.js +288 -45
  162. package/lib/dependencies/ImportWeakDependency.js +2 -3
  163. package/lib/dependencies/JsonExportsDependency.js +0 -1
  164. package/lib/dependencies/LoaderDependency.js +0 -3
  165. package/lib/dependencies/LoaderImportDependency.js +0 -3
  166. package/lib/dependencies/LoaderPlugin.js +11 -5
  167. package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
  168. package/lib/dependencies/ModuleDependency.js +3 -9
  169. package/lib/dependencies/NullDependency.js +2 -0
  170. package/lib/dependencies/ProvidedDependency.js +6 -8
  171. package/lib/dependencies/PureExpressionDependency.js +0 -1
  172. package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
  173. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
  174. package/lib/dependencies/RequireIncludeDependency.js +2 -2
  175. package/lib/dependencies/RequireResolveDependency.js +2 -2
  176. package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
  177. package/lib/dependencies/StaticExportsDependency.js +3 -5
  178. package/lib/dependencies/URLDependency.js +2 -7
  179. package/lib/dependencies/URLPlugin.js +1 -2
  180. package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
  181. package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
  182. package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
  183. package/lib/dependencies/WorkerDependency.js +2 -3
  184. package/lib/dependencies/WorkerPlugin.js +4 -12
  185. package/lib/dependencies/processExportInfo.js +2 -3
  186. package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
  187. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
  188. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
  189. package/lib/hmr/LazyCompilationPlugin.js +6 -4
  190. package/lib/hmr/lazyCompilationBackend.js +13 -10
  191. package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
  192. package/lib/ids/HashedModuleIdsPlugin.js +5 -7
  193. package/lib/ids/IdHelpers.js +1 -1
  194. package/lib/ids/NamedChunkIdsPlugin.js +1 -6
  195. package/lib/ids/NamedModuleIdsPlugin.js +1 -5
  196. package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
  197. package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
  198. package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
  199. package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
  200. package/lib/ids/SyncModuleIdsPlugin.js +4 -3
  201. package/lib/index.js +8 -7
  202. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
  203. package/lib/javascript/BasicEvaluatedExpression.js +13 -6
  204. package/lib/javascript/ChunkFormatHelpers.js +1 -1
  205. package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
  206. package/lib/javascript/JavascriptGenerator.js +2 -3
  207. package/lib/javascript/JavascriptModulesPlugin.js +46 -24
  208. package/lib/javascript/JavascriptParser.js +120 -55
  209. package/lib/javascript/JavascriptParserHelpers.js +2 -2
  210. package/lib/javascript/StartupHelpers.js +2 -4
  211. package/lib/json/JsonData.js +1 -1
  212. package/lib/json/JsonGenerator.js +4 -5
  213. package/lib/json/JsonModulesPlugin.js +0 -3
  214. package/lib/json/JsonParser.js +4 -2
  215. package/lib/library/AbstractLibraryPlugin.js +2 -2
  216. package/lib/library/AmdLibraryPlugin.js +0 -1
  217. package/lib/library/AssignLibraryPlugin.js +23 -12
  218. package/lib/library/EnableLibraryPlugin.js +7 -11
  219. package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
  220. package/lib/library/JsonpLibraryPlugin.js +5 -2
  221. package/lib/library/ModuleLibraryPlugin.js +88 -43
  222. package/lib/library/SystemLibraryPlugin.js +15 -6
  223. package/lib/library/UmdLibraryPlugin.js +12 -18
  224. package/lib/logging/Logger.js +12 -10
  225. package/lib/logging/createConsoleLogger.js +15 -14
  226. package/lib/logging/truncateArgs.js +1 -1
  227. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  228. package/lib/node/NodeWatchFileSystem.js +4 -4
  229. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  230. package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
  231. package/lib/node/nodeConsole.js +2 -2
  232. package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
  233. package/lib/optimize/ConcatenatedModule.js +142 -100
  234. package/lib/optimize/InnerGraph.js +17 -11
  235. package/lib/optimize/InnerGraphPlugin.js +0 -3
  236. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  237. package/lib/optimize/RealContentHashPlugin.js +5 -3
  238. package/lib/optimize/RuntimeChunkPlugin.js +0 -1
  239. package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
  240. package/lib/optimize/SplitChunksPlugin.js +46 -40
  241. package/lib/performance/SizeLimitsPlugin.js +2 -1
  242. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
  243. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
  244. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
  245. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
  246. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
  247. package/lib/rules/BasicMatcherRulePlugin.js +0 -2
  248. package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
  249. package/lib/rules/RuleSetCompiler.js +8 -6
  250. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  251. package/lib/runtime/CompatRuntimeModule.js +0 -1
  252. package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
  253. package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
  254. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  255. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  256. package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
  257. package/lib/runtime/SystemContextRuntimeModule.js +0 -2
  258. package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
  259. package/lib/schemes/DataUriPlugin.js +2 -28
  260. package/lib/schemes/FileUriPlugin.js +5 -2
  261. package/lib/schemes/HttpUriPlugin.js +4 -2
  262. package/lib/schemes/VirtualUrlPlugin.js +11 -11
  263. package/lib/serialization/FileMiddleware.js +1 -1
  264. package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
  265. package/lib/serialization/ObjectMiddleware.js +31 -20
  266. package/lib/serialization/SerializerMiddleware.js +1 -3
  267. package/lib/serialization/types.js +1 -1
  268. package/lib/sharing/ConsumeSharedModule.js +3 -5
  269. package/lib/sharing/ConsumeSharedPlugin.js +2 -4
  270. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
  271. package/lib/sharing/ProvideSharedModule.js +3 -7
  272. package/lib/sharing/SharePlugin.js +0 -2
  273. package/lib/sharing/ShareRuntimeModule.js +4 -1
  274. package/lib/sharing/resolveMatchedConfigs.js +14 -6
  275. package/lib/sharing/utils.js +0 -6
  276. package/lib/stats/DefaultStatsFactoryPlugin.js +179 -95
  277. package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
  278. package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
  279. package/lib/stats/StatsFactory.js +14 -11
  280. package/lib/url/URLParserPlugin.js +2 -4
  281. package/lib/util/ArrayHelpers.js +4 -4
  282. package/lib/util/AsyncQueue.js +1 -0
  283. package/lib/util/Hash.js +35 -5
  284. package/lib/util/LazySet.js +2 -2
  285. package/lib/util/StackedCacheMap.js +0 -2
  286. package/lib/util/TupleSet.js +9 -4
  287. package/lib/util/URLAbsoluteSpecifier.js +0 -1
  288. package/lib/util/WeakTupleMap.js +1 -1
  289. package/lib/util/chainedImports.js +3 -1
  290. package/lib/util/cleverMerge.js +15 -18
  291. package/lib/util/comparators.js +2 -4
  292. package/lib/util/compileBooleanMatcher.js +11 -9
  293. package/lib/util/concatenate.js +1 -2
  294. package/lib/util/create-schema-validation.js +1 -2
  295. package/lib/util/createHash.js +85 -15
  296. package/lib/util/dataURL.js +39 -0
  297. package/lib/util/deprecation.js +29 -31
  298. package/lib/util/deterministicGrouping.js +34 -30
  299. package/lib/util/extractSourceMap.js +319 -0
  300. package/lib/util/findGraphRoots.js +15 -5
  301. package/lib/util/fs.js +29 -8
  302. package/lib/util/hash/BatchedHash.js +47 -8
  303. package/lib/util/hash/wasm-hash.js +53 -13
  304. package/lib/util/semver.js +9 -8
  305. package/lib/util/smartGrouping.js +41 -26
  306. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  307. package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
  308. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  309. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
  310. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
  311. package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
  312. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
  313. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
  314. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
  315. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
  316. package/lib/wasm-sync/WebAssemblyParser.js +1 -13
  317. package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
  318. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  319. package/lib/web/JsonpTemplatePlugin.js +0 -1
  320. package/lib/webpack.js +21 -8
  321. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
  322. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  323. package/package.json +21 -21
  324. package/schemas/WebpackOptions.check.js +1 -1
  325. package/schemas/WebpackOptions.json +93 -96
  326. package/schemas/plugins/BannerPlugin.check.js +1 -1
  327. package/schemas/plugins/BannerPlugin.json +4 -0
  328. package/schemas/plugins/IgnorePlugin.json +1 -1
  329. package/schemas/plugins/ProgressPlugin.json +1 -1
  330. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  331. package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
  332. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  333. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  334. package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
  335. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  336. package/types.d.ts +1699 -706
  337. package/SECURITY.md +0 -9
  338. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
  339. package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
@@ -12,6 +12,8 @@ const WebpackError = require("../WebpackError");
12
12
  const { compareSelect, compareStrings } = require("../util/comparators");
13
13
  const createHash = require("../util/createHash");
14
14
 
15
+ /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
16
+ /** @typedef {import("../../declarations/WebpackOptions").HashDigest} HashDigest */
15
17
  /** @typedef {import("webpack-sources").Source} Source */
16
18
  /** @typedef {import("../Cache").Etag} Etag */
17
19
  /** @typedef {import("../Compilation").AssetInfo} AssetInfo */
@@ -109,8 +111,8 @@ const compilationHooksMap = new WeakMap();
109
111
 
110
112
  /**
111
113
  * @typedef {object} RealContentHashPluginOptions
112
- * @property {string | Hash} hashFunction the hash function to use
113
- * @property {string=} hashDigest the hash digest to use
114
+ * @property {HashFunction} hashFunction the hash function to use
115
+ * @property {HashDigest} hashDigest the hash digest to use
114
116
  */
115
117
 
116
118
  const PLUGIN_NAME = "RealContentHashPlugin";
@@ -432,7 +434,7 @@ ${referencingAssets
432
434
  hash.update(content);
433
435
  }
434
436
  const digest = hash.digest(this._hashDigest);
435
- newHash = /** @type {string} */ (digest.slice(0, oldHash.length));
437
+ newHash = digest.slice(0, oldHash.length);
436
438
  }
437
439
  hashToNewHash.set(oldHash, newHash);
438
440
  }
@@ -7,7 +7,6 @@
7
7
 
8
8
  /** @typedef {import("../Compilation").EntryData} EntryData */
9
9
  /** @typedef {import("../Compiler")} Compiler */
10
- /** @typedef {import("../Entrypoint")} Entrypoint */
11
10
 
12
11
  const PLUGIN_NAME = "RuntimeChunkPlugin";
13
12
 
@@ -21,7 +21,6 @@ const formatLocation = require("../formatLocation");
21
21
  /** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
22
22
  /** @typedef {import("estree").Statement} Statement */
23
23
  /** @typedef {import("../Compiler")} Compiler */
24
- /** @typedef {import("../Dependency")} Dependency */
25
24
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
26
25
  /** @typedef {import("../Module")} Module */
27
26
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
@@ -37,11 +36,7 @@ const formatLocation = require("../formatLocation");
37
36
  * @property {boolean} checked if the export is conditional
38
37
  */
39
38
 
40
- /**
41
- * @typedef {object} ReexportInfo
42
- * @property {Map<string, ExportInModule[]>} static
43
- * @property {Map<Module, Set<string>>} dynamic
44
- */
39
+ /** @typedef {string | boolean | string[] | undefined} SideEffectsFlagValue */
45
40
 
46
41
  /** @typedef {Map<string, RegExp>} CacheItem */
47
42
 
@@ -105,9 +100,7 @@ class SideEffectsFlagPlugin {
105
100
  }
106
101
  const hasSideEffects = SideEffectsFlagPlugin.moduleHasSideEffects(
107
102
  resolveData.relativePath,
108
- /** @type {string | boolean | string[] | undefined} */ (
109
- sideEffects
110
- ),
103
+ /** @type {SideEffectsFlagValue} */ (sideEffects),
111
104
  /** @type {CacheItem} */ (cache)
112
105
  );
113
106
  module.factoryMeta.sideEffectFree = !hasSideEffects;
@@ -397,7 +390,7 @@ class SideEffectsFlagPlugin {
397
390
 
398
391
  /**
399
392
  * @param {string} moduleName the module name
400
- * @param {undefined | boolean | string | string[]} flagValue the flag value
393
+ * @param {SideEffectsFlagValue} flagValue the flag value
401
394
  * @param {Map<string, RegExp>} cache cache for glob to regexp
402
395
  * @returns {boolean | undefined} true, when the module has side effects, undefined or false when not
403
396
  */
@@ -21,12 +21,11 @@ const { makePathsRelative } = require("../util/identifier");
21
21
  const memoize = require("../util/memoize");
22
22
  const MinMaxSizeWarning = require("./MinMaxSizeWarning");
23
23
 
24
- /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
25
24
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksCacheGroup} OptimizationSplitChunksCacheGroup */
26
25
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksGetCacheGroups} OptimizationSplitChunksGetCacheGroups */
27
26
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
28
27
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
29
- /** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
28
+ /** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
30
29
  /** @typedef {import("../Chunk").ChunkName} ChunkName */
31
30
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
32
31
  /** @typedef {import("../ChunkGroup")} ChunkGroup */
@@ -37,10 +36,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
37
36
  /** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
38
37
  /** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
39
38
 
40
- /** @typedef {Record<string, number>} SplitChunksSizes */
41
-
42
39
  /**
43
- * @callback ChunkFilterFunction
40
+ * @callback ChunkFilterFn
44
41
  * @param {Chunk} chunk
45
42
  * @returns {boolean | undefined}
46
43
  */
@@ -52,12 +49,17 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
52
49
  * @returns {number}
53
50
  */
54
51
 
52
+ /** @typedef {string} SourceType */
53
+ /** @typedef {SourceType[]} SourceTypes */
54
+ /** @typedef {SourceType[]} DefaultSizeTypes */
55
+ /** @typedef {Record<SourceType, number>} SplitChunksSizes */
56
+
55
57
  /**
56
58
  * @typedef {object} CacheGroupSource
57
59
  * @property {string} key
58
60
  * @property {number=} priority
59
- * @property {GetName=} getName
60
- * @property {ChunkFilterFunction=} chunksFilter
61
+ * @property {GetNameFn=} getName
62
+ * @property {ChunkFilterFn=} chunksFilter
61
63
  * @property {boolean=} enforce
62
64
  * @property {SplitChunksSizes} minSize
63
65
  * @property {SplitChunksSizes} minSizeReduction
@@ -79,8 +81,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
79
81
  * @typedef {object} CacheGroup
80
82
  * @property {string} key
81
83
  * @property {number} priority
82
- * @property {GetName=} getName
83
- * @property {ChunkFilterFunction} chunksFilter
84
+ * @property {GetNameFn=} getName
85
+ * @property {ChunkFilterFn} chunksFilter
84
86
  * @property {SplitChunksSizes} minSize
85
87
  * @property {SplitChunksSizes} minSizeReduction
86
88
  * @property {SplitChunksSizes} minRemainingSize
@@ -103,7 +105,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
103
105
 
104
106
  /**
105
107
  * @typedef {object} FallbackCacheGroup
106
- * @property {ChunkFilterFunction} chunksFilter
108
+ * @property {ChunkFilterFn} chunksFilter
107
109
  * @property {SplitChunksSizes} minSize
108
110
  * @property {SplitChunksSizes} maxAsyncSize
109
111
  * @property {SplitChunksSizes} maxInitialSize
@@ -124,17 +126,17 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
124
126
  */
125
127
 
126
128
  /**
127
- * @callback GetName
129
+ * @callback GetNameFn
128
130
  * @param {Module} module
129
131
  * @param {Chunk[]} chunks
130
132
  * @param {string} key
131
- * @returns {string=}
133
+ * @returns {string | undefined}
132
134
  */
133
135
 
134
136
  /**
135
137
  * @typedef {object} SplitChunksOptions
136
- * @property {ChunkFilterFunction} chunksFilter
137
- * @property {string[]} defaultSizeTypes
138
+ * @property {ChunkFilterFn} chunksFilter
139
+ * @property {DefaultSizeTypes} defaultSizeTypes
138
140
  * @property {SplitChunksSizes} minSize
139
141
  * @property {SplitChunksSizes} minSizeReduction
140
142
  * @property {SplitChunksSizes} minRemainingSize
@@ -148,7 +150,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
148
150
  * @property {TemplatePath=} filename
149
151
  * @property {string} automaticNameDelimiter
150
152
  * @property {GetCacheGroups} getCacheGroups
151
- * @property {GetName} getName
153
+ * @property {GetNameFn} getName
152
154
  * @property {boolean} usedExports
153
155
  * @property {FallbackCacheGroup} fallbackCacheGroup
154
156
  */
@@ -159,13 +161,13 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
159
161
  * @property {CacheGroup} cacheGroup
160
162
  * @property {number} cacheGroupIndex
161
163
  * @property {string=} name
162
- * @property {Record<string, number>} sizes
164
+ * @property {Record<SourceType, number>} sizes
163
165
  * @property {Set<Chunk>} chunks
164
166
  * @property {Set<Chunk>} reusableChunks
165
167
  * @property {Set<bigint | Chunk>} chunksKeys
166
168
  */
167
169
 
168
- /** @type {GetName} */
170
+ /** @type {GetNameFn} */
169
171
  const defaultGetName = () => undefined;
170
172
 
171
173
  const deterministicGroupingForModules =
@@ -184,7 +186,7 @@ const hashFilename = (name, outputOptions) => {
184
186
  const digest =
185
187
  /** @type {string} */
186
188
  (
187
- createHash(/** @type {HashFunction} */ (outputOptions.hashFunction))
189
+ createHash(outputOptions.hashFunction)
188
190
  .update(name)
189
191
  .digest(outputOptions.hashDigest)
190
192
  );
@@ -286,7 +288,7 @@ const ALL_CHUNK_FILTER = (_chunk) => true;
286
288
 
287
289
  /**
288
290
  * @param {OptimizationSplitChunksSizes | undefined} value the sizes
289
- * @param {string[]} defaultSizeTypes the default size types
291
+ * @param {DefaultSizeTypes} defaultSizeTypes the default size types
290
292
  * @returns {SplitChunksSizes} normalized representation
291
293
  */
292
294
  const normalizeSizes = (value, defaultSizeTypes) => {
@@ -379,7 +381,7 @@ const checkMinSizeReduction = (sizes, minSizeReduction, chunkCount) => {
379
381
  /**
380
382
  * @param {SplitChunksSizes} sizes the sizes
381
383
  * @param {SplitChunksSizes} minSize the min sizes
382
- * @returns {undefined | string[]} list of size types that are below min size
384
+ * @returns {undefined | SourceTypes} list of size types that are below min size
383
385
  */
384
386
  const getViolatingMinSizes = (sizes, minSize) => {
385
387
  let list;
@@ -408,20 +410,20 @@ const totalSize = (sizes) => {
408
410
 
409
411
  /**
410
412
  * @param {OptimizationSplitChunksCacheGroup["name"]} name the chunk name
411
- * @returns {GetName | undefined} a function to get the name of the chunk
413
+ * @returns {GetNameFn | undefined} a function to get the name of the chunk
412
414
  */
413
415
  const normalizeName = (name) => {
414
416
  if (typeof name === "string") {
415
417
  return () => name;
416
418
  }
417
419
  if (typeof name === "function") {
418
- return /** @type {GetName} */ (name);
420
+ return /** @type {GetNameFn} */ (name);
419
421
  }
420
422
  };
421
423
 
422
424
  /**
423
425
  * @param {OptimizationSplitChunksCacheGroup["chunks"]} chunks the chunk filter option
424
- * @returns {ChunkFilterFunction | undefined} the chunk filter function
426
+ * @returns {ChunkFilterFn | undefined} the chunk filter function
425
427
  */
426
428
  const normalizeChunksFilter = (chunks) => {
427
429
  if (chunks === "initial") {
@@ -443,7 +445,7 @@ const normalizeChunksFilter = (chunks) => {
443
445
 
444
446
  /**
445
447
  * @param {undefined | GetCacheGroups | Record<string, false | string | RegExp | OptimizationSplitChunksGetCacheGroups | OptimizationSplitChunksCacheGroup>} cacheGroups the cache group options
446
- * @param {string[]} defaultSizeTypes the default size types
448
+ * @param {DefaultSizeTypes} defaultSizeTypes the default size types
447
449
  * @returns {GetCacheGroups} a function to get the cache groups
448
450
  */
449
451
  const normalizeCacheGroups = (cacheGroups, defaultSizeTypes) => {
@@ -586,7 +588,7 @@ const checkModuleLayer = (test, module) => {
586
588
  /**
587
589
  * @param {OptimizationSplitChunksCacheGroup} options the group options
588
590
  * @param {string} key key of cache group
589
- * @param {string[]} defaultSizeTypes the default size types
591
+ * @param {DefaultSizeTypes} defaultSizeTypes the default size types
590
592
  * @returns {CacheGroupSource} the normalized cached group
591
593
  */
592
594
  const createCacheGroupSource = (options, key, defaultSizeTypes) => {
@@ -653,7 +655,7 @@ module.exports = class SplitChunksPlugin {
653
655
  /** @type {SplitChunksOptions} */
654
656
  this.options = {
655
657
  chunksFilter:
656
- /** @type {ChunkFilterFunction} */
658
+ /** @type {ChunkFilterFn} */
657
659
  (normalizeChunksFilter(options.chunks || "all")),
658
660
  defaultSizeTypes,
659
661
  minSize,
@@ -684,13 +686,13 @@ module.exports = class SplitChunksPlugin {
684
686
  defaultSizeTypes
685
687
  ),
686
688
  getName: options.name
687
- ? /** @type {GetName} */ (normalizeName(options.name))
689
+ ? /** @type {GetNameFn} */ (normalizeName(options.name))
688
690
  : defaultGetName,
689
691
  automaticNameDelimiter: options.automaticNameDelimiter || "-",
690
692
  usedExports: options.usedExports || false,
691
693
  fallbackCacheGroup: {
692
694
  chunksFilter:
693
- /** @type {ChunkFilterFunction} */
695
+ /** @type {ChunkFilterFn} */
694
696
  (
695
697
  normalizeChunksFilter(
696
698
  fallbackCacheGroup.chunks || options.chunks || "all"
@@ -947,15 +949,17 @@ module.exports = class SplitChunksPlugin {
947
949
  return { chunkSetsInGraph, singleChunkSets };
948
950
  });
949
951
 
952
+ /** @typedef {Map<number, Set<Chunk>[]>} ChunkSetsByCount */
953
+
950
954
  // group these set of chunks by count
951
955
  // to allow to check less sets via isSubset
952
956
  // (only smaller sets can be subset)
953
957
  /**
954
958
  * @param {IterableIterator<Set<Chunk>>} chunkSets set of sets of chunks
955
- * @returns {Map<number, Array<Set<Chunk>>>} map of sets of chunks by count
959
+ * @returns {ChunkSetsByCount} map of sets of chunks by count
956
960
  */
957
961
  const groupChunkSetsByCount = (chunkSets) => {
958
- /** @type {Map<number, Array<Set<Chunk>>>} */
962
+ /** @type {ChunkSetsByCount} */
959
963
  const chunkSetsByCount = new Map();
960
964
  for (const chunksSet of chunkSets) {
961
965
  const count = chunksSet.size;
@@ -979,19 +983,21 @@ module.exports = class SplitChunksPlugin {
979
983
  )
980
984
  );
981
985
 
986
+ /** @typedef {(Set<Chunk> | Chunk)[]} Combinations */
987
+
982
988
  // Create a list of possible combinations
983
989
  /**
984
990
  * @param {Map<bigint | Chunk, Set<Chunk>>} chunkSets chunk sets
985
991
  * @param {Set<Chunk>} singleChunkSets single chunks sets
986
992
  * @param {Map<number, Set<Chunk>[]>} chunkSetsByCount chunk sets by count
987
- * @returns {(key: bigint | Chunk) => (Set<Chunk> | Chunk)[]} combinations
993
+ * @returns {(key: bigint | Chunk) => Combinations} combinations
988
994
  */
989
995
  const createGetCombinations = (
990
996
  chunkSets,
991
997
  singleChunkSets,
992
998
  chunkSetsByCount
993
999
  ) => {
994
- /** @type {Map<bigint | Chunk, (Set<Chunk> | Chunk)[]>} */
1000
+ /** @type {Map<bigint | Chunk, Combinations>} */
995
1001
  const combinationsCache = new Map();
996
1002
 
997
1003
  return (key) => {
@@ -1005,7 +1011,7 @@ module.exports = class SplitChunksPlugin {
1005
1011
  const chunksSet =
1006
1012
  /** @type {Set<Chunk>} */
1007
1013
  (chunkSets.get(key));
1008
- /** @type {(Set<Chunk> | Chunk)[]} */
1014
+ /** @type {Combinations} */
1009
1015
  const array = [chunksSet];
1010
1016
  for (const [count, setArray] of chunkSetsByCount) {
1011
1017
  // "equal" is not needed because they would have been merge in the first step
@@ -1038,7 +1044,7 @@ module.exports = class SplitChunksPlugin {
1038
1044
 
1039
1045
  /**
1040
1046
  * @param {bigint | Chunk} key key
1041
- * @returns {(Set<Chunk> | Chunk)[]} combinations by key
1047
+ * @returns {Combinations} combinations by key
1042
1048
  */
1043
1049
  const getCombinations = (key) => getCombinationsFactory()(key);
1044
1050
 
@@ -1053,7 +1059,7 @@ module.exports = class SplitChunksPlugin {
1053
1059
  });
1054
1060
  /**
1055
1061
  * @param {bigint | Chunk} key key
1056
- * @returns {(Set<Chunk> | Chunk)[]} exports combinations by key
1062
+ * @returns {Combinations} exports combinations by key
1057
1063
  */
1058
1064
  const getExportsCombinations = (key) =>
1059
1065
  getExportsCombinationsFactory()(key);
@@ -1064,14 +1070,14 @@ module.exports = class SplitChunksPlugin {
1064
1070
  * @property {bigint | Chunk} key a key of the list
1065
1071
  */
1066
1072
 
1067
- /** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFunction, SelectedChunksResult>>} */
1073
+ /** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */
1068
1074
  const selectedChunksCacheByChunksSet = new WeakMap();
1069
1075
 
1070
1076
  /**
1071
1077
  * get list and key by applying the filter function to the list
1072
1078
  * It is cached for performance reasons
1073
1079
  * @param {Set<Chunk> | Chunk} chunks list of chunks
1074
- * @param {ChunkFilterFunction} chunkFilter filter function for chunks
1080
+ * @param {ChunkFilterFn} chunkFilter filter function for chunks
1075
1081
  * @returns {SelectedChunksResult} list and key
1076
1082
  */
1077
1083
  const getSelectedChunks = (chunks, chunkFilter) => {
@@ -1132,7 +1138,7 @@ module.exports = class SplitChunksPlugin {
1132
1138
  // Determine name for split chunk
1133
1139
 
1134
1140
  const name =
1135
- /** @type {GetName} */
1141
+ /** @type {GetNameFn} */
1136
1142
  (cacheGroup.getName)(module, selectedChunks, cacheGroup.key);
1137
1143
  // Check if the name is ok
1138
1144
  const existingChunk = name && compilation.namedChunks.get(name);
@@ -1294,7 +1300,7 @@ module.exports = class SplitChunksPlugin {
1294
1300
  const { chunks: selectedChunks, key: selectedChunksKey } =
1295
1301
  getSelectedChunks(
1296
1302
  chunkCombination,
1297
- /** @type {ChunkFilterFunction} */
1303
+ /** @type {ChunkFilterFn} */
1298
1304
  (cacheGroup.chunksFilter)
1299
1305
  );
1300
1306
 
@@ -1316,7 +1322,7 @@ module.exports = class SplitChunksPlugin {
1316
1322
 
1317
1323
  /**
1318
1324
  * @param {ChunksInfoItem} info entry
1319
- * @param {string[]} sourceTypes source types to be removed
1325
+ * @param {SourceTypes} sourceTypes source types to be removed
1320
1326
  */
1321
1327
  const removeModulesWithSourceType = (info, sourceTypes) => {
1322
1328
  for (const module of info.modules) {
@@ -31,6 +31,7 @@ const NoAsyncChunksWarning = require("./NoAsyncChunksWarning");
31
31
  * @property {string[]} files
32
32
  */
33
33
 
34
+ /** @type {WeakSet<Entrypoint | ChunkGroup | Source>} */
34
35
  const isOverSizeLimitSet = new WeakSet();
35
36
 
36
37
  /**
@@ -55,7 +56,7 @@ module.exports = class SizeLimitsPlugin {
55
56
  }
56
57
 
57
58
  /**
58
- * @param {ChunkGroup | Source} thing the resource to test
59
+ * @param {Entrypoint | ChunkGroup | Source} thing the resource to test
59
60
  * @returns {boolean} true if over the limit
60
61
  */
61
62
  static isOverSizeLimit(thing) {
@@ -8,17 +8,15 @@ const RuntimeModule = require("../RuntimeModule");
8
8
  const Template = require("../Template");
9
9
 
10
10
  /** @typedef {import("../Compilation")} Compilation */
11
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
12
11
 
13
12
  class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
14
13
  /**
15
- * @param {string} childType TODO
16
- * @param {string} runtimeFunction TODO
17
- * @param {string} runtimeHandlers TODO
14
+ * @param {"prefetch" | "preload"} type "prefetch" or "preload" chunk type function
15
+ * @param {string} runtimeFunction the runtime function name
16
+ * @param {string} runtimeHandlers the runtime handlers
18
17
  */
19
- constructor(childType, runtimeFunction, runtimeHandlers) {
20
- super(`chunk ${childType} function`);
21
- this.childType = childType;
18
+ constructor(type, runtimeFunction, runtimeHandlers) {
19
+ super(`chunk ${type} function`);
22
20
  this.runtimeFunction = runtimeFunction;
23
21
  this.runtimeHandlers = runtimeHandlers;
24
22
  }
@@ -11,8 +11,6 @@ const ChunkPrefetchStartupRuntimeModule = require("./ChunkPrefetchStartupRuntime
11
11
  const ChunkPrefetchTriggerRuntimeModule = require("./ChunkPrefetchTriggerRuntimeModule");
12
12
  const ChunkPreloadTriggerRuntimeModule = require("./ChunkPreloadTriggerRuntimeModule");
13
13
 
14
- /** @typedef {import("../Chunk")} Chunk */
15
- /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
16
14
  /** @typedef {import("../Compiler")} Compiler */
17
15
 
18
16
  const PLUGIN_NAME = "ChunkPrefetchPreloadPlugin";
@@ -10,7 +10,6 @@ const Template = require("../Template");
10
10
 
11
11
  /** @typedef {import("../Chunk")} Chunk */
12
12
  /** @typedef {import("../Compilation")} Compilation */
13
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
14
13
 
15
14
  class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
16
15
  /**
@@ -9,11 +9,11 @@ const RuntimeModule = require("../RuntimeModule");
9
9
  const Template = require("../Template");
10
10
 
11
11
  /** @typedef {import("../Compilation")} Compilation */
12
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
12
+ /** @typedef {import("../Chunk").ChunkChildIdsByOrdersMap} ChunkChildIdsByOrdersMap */
13
13
 
14
14
  class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule {
15
15
  /**
16
- * @param {Record<string|number, (string|number)[]>} chunkMap map from chunk to
16
+ * @param {ChunkChildIdsByOrdersMap} chunkMap map from chunk to
17
17
  */
18
18
  constructor(chunkMap) {
19
19
  super("chunk prefetch trigger", RuntimeModule.STAGE_TRIGGER);
@@ -9,11 +9,11 @@ const RuntimeModule = require("../RuntimeModule");
9
9
  const Template = require("../Template");
10
10
 
11
11
  /** @typedef {import("../Compilation")} Compilation */
12
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
12
+ /** @typedef {import("../Chunk").ChunkChildIdsByOrdersMap} ChunkChildIdsByOrdersMap */
13
13
 
14
14
  class ChunkPreloadTriggerRuntimeModule extends RuntimeModule {
15
15
  /**
16
- * @param {Record<string|number, (string|number)[]>} chunkMap map from chunk to chunks
16
+ * @param {ChunkChildIdsByOrdersMap} chunkMap map from chunk to chunks
17
17
  */
18
18
  constructor(chunkMap) {
19
19
  super("chunk preload trigger", RuntimeModule.STAGE_TRIGGER);
@@ -7,10 +7,8 @@
7
7
 
8
8
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditions} RuleSetConditionOrConditions */
9
9
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditionsAbsolute} RuleSetConditionOrConditionsAbsolute */
10
- /** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
11
10
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
12
11
  /** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
13
- /** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
14
12
 
15
13
  /**
16
14
  * @template T
@@ -9,7 +9,6 @@
9
9
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
10
10
  /** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
11
11
  /** @typedef {import("./RuleSetCompiler").EffectData} EffectData */
12
- /** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
13
12
  /** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */
14
13
 
15
14
  /**
@@ -7,10 +7,10 @@
7
7
 
8
8
  const { SyncHook } = require("tapable");
9
9
 
10
+ /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
10
11
  /** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */
11
12
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
12
13
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
13
- /** @typedef {import("../NormalModule").LoaderItem} LoaderItem */
14
14
 
15
15
  /** @typedef {(Falsy | RuleSetRule)[]} RuleSetRules */
16
16
 
@@ -38,10 +38,10 @@ const { SyncHook } = require("tapable");
38
38
  * @property {string=} resourceQuery
39
39
  * @property {string=} resourceFragment
40
40
  * @property {string=} scheme
41
- * @property {ImportAttributes=} assertions
41
+ * @property {ImportAttributes=} attributes
42
42
  * @property {string=} mimetype
43
43
  * @property {string} dependency
44
- * @property {Record<string, EXPECTED_ANY>=} descriptionData
44
+ * @property {ResolveRequest["descriptionFileData"]=} descriptionData
45
45
  * @property {string=} compiler
46
46
  * @property {string} issuer
47
47
  * @property {string} issuerLayer
@@ -85,6 +85,8 @@ const { SyncHook } = require("tapable");
85
85
  * @typedef {({ [P in keyof Required<T>]: Required<T>[P] extends V ? P : never })[keyof T]} KeysOfTypes
86
86
  */
87
87
 
88
+ /** @typedef {Set<string>} UnhandledProperties */
89
+
88
90
  /** @typedef {{ apply: (ruleSetCompiler: RuleSetCompiler) => void }} RuleSetPlugin */
89
91
 
90
92
  class RuleSetCompiler {
@@ -93,7 +95,7 @@ class RuleSetCompiler {
93
95
  */
94
96
  constructor(plugins) {
95
97
  this.hooks = Object.freeze({
96
- /** @type {SyncHook<[string, RuleSetRule, Set<string>, CompiledRule, References]>} */
98
+ /** @type {SyncHook<[string, RuleSetRule, UnhandledProperties, CompiledRule, References]>} */
97
99
  rule: new SyncHook([
98
100
  "path",
99
101
  "rule",
@@ -127,7 +129,7 @@ class RuleSetCompiler {
127
129
  for (const condition of rule.conditions) {
128
130
  const p = condition.property;
129
131
  if (Array.isArray(p)) {
130
- /** @type {EffectData | EffectData[keyof EffectData] | undefined} */
132
+ /** @type {EXPECTED_ANY} */
131
133
  let current = data;
132
134
  for (const subProperty of p) {
133
135
  if (
@@ -219,7 +221,7 @@ class RuleSetCompiler {
219
221
  * @returns {CompiledRule} normalized and compiled rule for processing
220
222
  */
221
223
  compileRule(path, rule, refs) {
222
- /** @type {Set<string>} */
224
+ /** @type {UnhandledProperties} */
223
225
  const unhandledProperties = new Set(
224
226
  Object.keys(rule).filter(
225
227
  (key) => rule[/** @type {keyof RuleSetRule} */ (key)] !== undefined
@@ -8,7 +8,7 @@
8
8
  const RuntimeGlobals = require("../RuntimeGlobals");
9
9
  const RuntimeModule = require("../RuntimeModule");
10
10
 
11
- /** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */
11
+ /** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */
12
12
  /** @typedef {import("../Chunk")} Chunk */
13
13
 
14
14
  class BaseUriRuntimeModule extends RuntimeModule {
@@ -22,7 +22,7 @@ class BaseUriRuntimeModule extends RuntimeModule {
22
22
  generate() {
23
23
  const chunk = /** @type {Chunk} */ (this.chunk);
24
24
  const options =
25
- /** @type {EntryDescriptionNormalized} */
25
+ /** @type {EntryDescription} */
26
26
  (chunk.getEntryOptions());
27
27
  return `${RuntimeGlobals.baseURI} = ${
28
28
  options.baseUri === undefined
@@ -10,7 +10,6 @@ const RuntimeModule = require("../RuntimeModule");
10
10
  /** @typedef {import("../Chunk")} Chunk */
11
11
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
12
12
  /** @typedef {import("../Compilation")} Compilation */
13
- /** @typedef {import("../MainTemplate")} MainTemplate */
14
13
 
15
14
  class CompatRuntimeModule extends RuntimeModule {
16
15
  constructor() {
@@ -13,7 +13,6 @@ const { first } = require("../util/SetHelpers");
13
13
  /** @typedef {import("../Chunk").ChunkId} ChunkId */
14
14
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
15
15
  /** @typedef {import("../Compilation")} Compilation */
16
- /** @typedef {import("../Compilation").AssetInfo} AssetInfo */
17
16
  /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
18
17
 
19
18
  class GetChunkFilenameRuntimeModule extends RuntimeModule {
@@ -125,7 +124,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
125
124
  */
126
125
  const addStaticUrl = (c, chunkFilename) => {
127
126
  /**
128
- * @param {string | number} value a value
127
+ * @param {ChunkId} value a value
129
128
  * @returns {string} string to put in quotes
130
129
  */
131
130
  const unquotedStringify = (value) => {
@@ -194,10 +193,10 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
194
193
  * @returns {string} code with static mapping of results of fn
195
194
  */
196
195
  const createMap = (fn) => {
197
- /** @type {Record<number | string, number | string>} */
196
+ /** @type {Record<ChunkId, ChunkId>} */
198
197
  const obj = {};
199
198
  let useId = false;
200
- /** @type {number | string | undefined} */
199
+ /** @type {ChunkId | undefined} */
201
200
  let lastKey;
202
201
  let entries = 0;
203
202
  for (const c of dynamicUrlChunks) {
@@ -205,8 +204,8 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
205
204
  if (value === c.id) {
206
205
  useId = true;
207
206
  } else {
208
- obj[/** @type {number | string} */ (c.id)] = value;
209
- lastKey = /** @type {number | string} */ (c.id);
207
+ obj[/** @type {ChunkId} */ (c.id)] = value;
208
+ lastKey = /** @type {ChunkId} */ (c.id);
210
209
  entries++;
211
210
  }
212
211
  }
@@ -214,9 +213,9 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
214
213
  if (entries === 1) {
215
214
  return useId
216
215
  ? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify(
217
- obj[/** @type {number | string} */ (lastKey)]
216
+ obj[/** @type {ChunkId} */ (lastKey)]
218
217
  )} : chunkId)`
219
- : JSON.stringify(obj[/** @type {number | string} */ (lastKey)]);
218
+ : JSON.stringify(obj[/** @type {ChunkId} */ (lastKey)]);
220
219
  }
221
220
  return useId
222
221
  ? `(${JSON.stringify(obj)}[chunkId] || chunkId)`
@@ -248,7 +247,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
248
247
  hashWithLength: mapExprWithLength(
249
248
  (c) => /** @type {string} */ (c.renderedHash)
250
249
  ),
251
- name: mapExpr((c) => c.name || /** @type {number | string} */ (c.id)),
250
+ name: mapExpr((c) => c.name || /** @type {ChunkId} */ (c.id)),
252
251
  contentHash: {
253
252
  [contentType]: mapExpr((c) => c.contentHash[contentType])
254
253
  },