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
@@ -10,9 +10,6 @@
10
10
  /** @typedef {import("./DefaultStatsFactoryPlugin").ChunkId} ChunkId */
11
11
  /** @typedef {import("./DefaultStatsFactoryPlugin").ChunkName} ChunkName */
12
12
  /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAsset} KnownStatsAsset */
13
- /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunk} KnownStatsAssetChunk */
14
- /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkIdHint} KnownStatsAssetChunkIdHint */
15
- /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkName} KnownStatsAssetChunkName */
16
13
  /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunk} KnownStatsChunk */
17
14
  /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkGroup} KnownStatsChunkGroup */
18
15
  /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkOrigin} KnownStatsChunkOrigin */
@@ -128,7 +125,7 @@ const isValidId = (id) => {
128
125
 
129
126
  /**
130
127
  * @template T
131
- * @param {Array<T> | undefined} list of items
128
+ * @param {T[] | undefined} list of items
132
129
  * @param {number} count number of items to show
133
130
  * @returns {string} string representation of list
134
131
  */
@@ -161,21 +158,14 @@ const moreCount = (list, count) =>
161
158
  * @template {object} O
162
159
  * @template {keyof O} K
163
160
  * @template {string} B
164
- * @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? never : `${B}.${K}` : never} PropertyName
161
+ * @typedef {K extends string ? `${B}.${K}` : never} PropertyName
165
162
  */
166
163
 
167
164
  /**
168
165
  * @template {object} O
169
166
  * @template {keyof O} K
170
167
  * @template {string} B
171
- * @typedef {K extends string ? NonNullable<O[K]> extends EXPECTED_ANY[] ? `${B}.${K}[]` : never : never} ArrayPropertyName
172
- */
173
-
174
- /**
175
- * @template {object} O
176
- * @template {keyof O} K
177
- * @template {string} B
178
- * @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? `${B}.${K}` : never : never} MultiplePropertyName
168
+ * @typedef {K extends string ? `${B}.${K}[]` : never} ArrayPropertyName
179
169
  */
180
170
 
181
171
  /**
@@ -190,9 +180,7 @@ const moreCount = (list, count) =>
190
180
  * @template {string} B
191
181
  * @template {string} [R=B]
192
182
  * @typedef {{ [K in keyof O as PropertyName<O, K, B>]?: SimplePrinter<O[K], R> } &
193
- * { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never } &
194
- * { [K in keyof O as MultiplePropertyName<O, K, B>]?: SimplePrinter<O[K], R> }
195
- * } Printers
183
+ * { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never }} Printers
196
184
  */
197
185
 
198
186
  /**
@@ -421,9 +409,9 @@ const COMPILATION_SIMPLE_PRINTERS = {
421
409
  * Printers<KnownStatsAsset["info"], "asset.info"> &
422
410
  * Exclamation<KnownStatsAsset, "asset.separator", "asset"> &
423
411
  * { ["asset.filteredChildren"]?: SimplePrinter<number, "asset"> } &
424
- * { assetChunk?: SimplePrinter<KnownStatsAssetChunk, "asset"> } &
425
- * { assetChunkName?: SimplePrinter<KnownStatsAssetChunkName, "asset"> } &
426
- * { assetChunkIdHint?: SimplePrinter<KnownStatsAssetChunkIdHint, "asset"> }} AssetSimplePrinters
412
+ * { assetChunk?: SimplePrinter<ChunkId, "asset"> } &
413
+ * { assetChunkName?: SimplePrinter<ChunkName, "asset"> } &
414
+ * { assetChunkIdHint?: SimplePrinter<string, "asset"> }} AssetSimplePrinters
427
415
  */
428
416
 
429
417
  /** @type {AssetSimplePrinters} */
@@ -473,7 +461,6 @@ const ASSET_SIMPLE_PRINTERS = {
473
461
  : undefined,
474
462
 
475
463
  assetChunk: (id, { formatChunkId }) => formatChunkId(id),
476
-
477
464
  assetChunkName: (name) => name || undefined,
478
465
  assetChunkIdHint: (name) => name || undefined
479
466
  };
@@ -1463,7 +1450,12 @@ const AVAILABLE_COLORS = {
1463
1450
  * @typedef {T extends [infer Head, ...infer Tail] ? Tail : undefined} Tail
1464
1451
  */
1465
1452
 
1466
- /** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }>} AvailableFormats */
1453
+ /**
1454
+ * @template {(...args: EXPECTED_ANY[]) => EXPECTED_ANY} T
1455
+ * @typedef {T extends (firstArg: EXPECTED_ANY, ...rest: infer R) => EXPECTED_ANY ? R : never} TailParameters
1456
+ */
1457
+
1458
+ /** @typedef {{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: TailParameters<NonNullable<KnownStatsPrinterFormatters[Key]>>) => string }} AvailableFormats */
1467
1459
 
1468
1460
  /** @type {AvailableFormats} */
1469
1461
  const AVAILABLE_FORMATS = {
@@ -1639,16 +1631,14 @@ class DefaultStatsPrinterPlugin {
1639
1631
  context[color] = (str) => str;
1640
1632
  }
1641
1633
  }
1642
- for (const _format of Object.keys(AVAILABLE_FORMATS)) {
1643
- const format =
1644
- /** @type {keyof KnownStatsPrinterFormatters} */
1645
- (_format);
1646
-
1634
+ for (const format of /** @type {(keyof KnownStatsPrinterFormatters)[]} */ (
1635
+ Object.keys(AVAILABLE_FORMATS)
1636
+ )) {
1647
1637
  context[format] =
1648
1638
  /** @type {(content: Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>[0], ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>>) => string} */
1649
1639
  (content, ...args) =>
1650
- /** @type {TODO} */
1651
- (AVAILABLE_FORMATS)[format](
1640
+ /** @type {EXPECTED_ANY} */
1641
+ (AVAILABLE_FORMATS[format])(
1652
1642
  content,
1653
1643
  /** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
1654
1644
  (context),
@@ -1658,15 +1648,12 @@ class DefaultStatsPrinterPlugin {
1658
1648
  context.timeReference = compilation.time;
1659
1649
  });
1660
1650
 
1661
- for (const key of Object.keys(COMPILATION_SIMPLE_PRINTERS)) {
1651
+ for (const key of /** @type {(keyof CompilationSimplePrinters)[]} */ (
1652
+ Object.keys(COMPILATION_SIMPLE_PRINTERS)
1653
+ )) {
1662
1654
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1663
- /** @type {TODO} */
1664
- (
1665
- COMPILATION_SIMPLE_PRINTERS[
1666
- /** @type {keyof CompilationSimplePrinters} */
1667
- (key)
1668
- ]
1669
- )(
1655
+ /** @type {EXPECTED_ANY} */
1656
+ (COMPILATION_SIMPLE_PRINTERS)[key](
1670
1657
  obj,
1671
1658
  /** @type {DefineStatsPrinterContext<"compilation">} */
1672
1659
  (ctx),
@@ -1675,15 +1662,12 @@ class DefaultStatsPrinterPlugin {
1675
1662
  );
1676
1663
  }
1677
1664
 
1678
- for (const key of Object.keys(ASSET_SIMPLE_PRINTERS)) {
1665
+ for (const key of /** @type {(keyof AssetSimplePrinters)[]} */ (
1666
+ Object.keys(ASSET_SIMPLE_PRINTERS)
1667
+ )) {
1679
1668
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1680
1669
  /** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */
1681
- (
1682
- ASSET_SIMPLE_PRINTERS[
1683
- /** @type {keyof AssetSimplePrinters} */
1684
- (key)
1685
- ]
1686
- )(
1670
+ (ASSET_SIMPLE_PRINTERS[key])(
1687
1671
  obj,
1688
1672
  /** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */
1689
1673
  (ctx),
@@ -1692,15 +1676,12 @@ class DefaultStatsPrinterPlugin {
1692
1676
  );
1693
1677
  }
1694
1678
 
1695
- for (const key of Object.keys(MODULE_SIMPLE_PRINTERS)) {
1679
+ for (const key of /** @type {(keyof ModuleSimplePrinters)[]} */ (
1680
+ Object.keys(MODULE_SIMPLE_PRINTERS)
1681
+ )) {
1696
1682
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1697
- /** @type {TODO} */
1698
- (
1699
- MODULE_SIMPLE_PRINTERS[
1700
- /** @type {keyof ModuleSimplePrinters} */
1701
- (key)
1702
- ]
1703
- )(
1683
+ /** @type {EXPECTED_ANY} */
1684
+ (MODULE_SIMPLE_PRINTERS)[key](
1704
1685
  obj,
1705
1686
  /** @type {DefineStatsPrinterContext<"module">} */
1706
1687
  (ctx),
@@ -1709,15 +1690,12 @@ class DefaultStatsPrinterPlugin {
1709
1690
  );
1710
1691
  }
1711
1692
 
1712
- for (const key of Object.keys(MODULE_ISSUER_PRINTERS)) {
1693
+ for (const key of /** @type {(keyof ModuleIssuerPrinters)[]} */ (
1694
+ Object.keys(MODULE_ISSUER_PRINTERS)
1695
+ )) {
1713
1696
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1714
1697
  /** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */
1715
- (
1716
- MODULE_ISSUER_PRINTERS[
1717
- /** @type {keyof ModuleIssuerPrinters} */
1718
- (key)
1719
- ]
1720
- )(
1698
+ (MODULE_ISSUER_PRINTERS[key])(
1721
1699
  obj,
1722
1700
  /** @type {DefineStatsPrinterContext<"moduleIssuer">} */
1723
1701
  (ctx),
@@ -1726,15 +1704,12 @@ class DefaultStatsPrinterPlugin {
1726
1704
  );
1727
1705
  }
1728
1706
 
1729
- for (const key of Object.keys(MODULE_REASON_PRINTERS)) {
1707
+ for (const key of /** @type {(keyof ModuleReasonsPrinters)[]} */ (
1708
+ Object.keys(MODULE_REASON_PRINTERS)
1709
+ )) {
1730
1710
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1731
- /** @type {TODO} */
1732
- (
1733
- MODULE_REASON_PRINTERS[
1734
- /** @type {keyof ModuleReasonsPrinters} */
1735
- (key)
1736
- ]
1737
- )(
1711
+ /** @type {EXPECTED_ANY} */
1712
+ (MODULE_REASON_PRINTERS)[key](
1738
1713
  obj,
1739
1714
  /** @type {DefineStatsPrinterContext<"moduleReason">} */
1740
1715
  (ctx),
@@ -1743,15 +1718,12 @@ class DefaultStatsPrinterPlugin {
1743
1718
  );
1744
1719
  }
1745
1720
 
1746
- for (const key of Object.keys(MODULE_PROFILE_PRINTERS)) {
1721
+ for (const key of /** @type {(keyof ModuleProfilePrinters)[]} */ (
1722
+ Object.keys(MODULE_PROFILE_PRINTERS)
1723
+ )) {
1747
1724
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1748
1725
  /** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */
1749
- (
1750
- MODULE_PROFILE_PRINTERS[
1751
- /** @type {keyof ModuleProfilePrinters} */
1752
- (key)
1753
- ]
1754
- )(
1726
+ (MODULE_PROFILE_PRINTERS[key])(
1755
1727
  obj,
1756
1728
  /** @type {DefineStatsPrinterContext<"profile">} */
1757
1729
  (ctx),
@@ -1760,15 +1732,12 @@ class DefaultStatsPrinterPlugin {
1760
1732
  );
1761
1733
  }
1762
1734
 
1763
- for (const key of Object.keys(CHUNK_GROUP_PRINTERS)) {
1735
+ for (const key of /** @type {(keyof ChunkGroupPrinters)[]} */ (
1736
+ Object.keys(CHUNK_GROUP_PRINTERS)
1737
+ )) {
1764
1738
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1765
- /** @type {TODO} */
1766
- (
1767
- CHUNK_GROUP_PRINTERS[
1768
- /** @type {keyof ChunkGroupPrinters} */
1769
- (key)
1770
- ]
1771
- )(
1739
+ /** @type {EXPECTED_ANY} */
1740
+ (CHUNK_GROUP_PRINTERS)[key](
1772
1741
  obj,
1773
1742
  /** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */
1774
1743
  (ctx),
@@ -1777,10 +1746,12 @@ class DefaultStatsPrinterPlugin {
1777
1746
  );
1778
1747
  }
1779
1748
 
1780
- for (const key of Object.keys(CHUNK_PRINTERS)) {
1749
+ for (const key of /** @type {(keyof ChunkPrinters)[]} */ (
1750
+ Object.keys(CHUNK_PRINTERS)
1751
+ )) {
1781
1752
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1782
- /** @type {TODO} */
1783
- (CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])(
1753
+ /** @type {EXPECTED_ANY} */
1754
+ (CHUNK_PRINTERS)[key](
1784
1755
  obj,
1785
1756
  /** @type {DefineStatsPrinterContext<"chunk">} */
1786
1757
  (ctx),
@@ -1789,10 +1760,12 @@ class DefaultStatsPrinterPlugin {
1789
1760
  );
1790
1761
  }
1791
1762
 
1792
- for (const key of Object.keys(ERROR_PRINTERS)) {
1763
+ for (const key of /** @type {(keyof ErrorPrinters)[]} */ (
1764
+ Object.keys(ERROR_PRINTERS)
1765
+ )) {
1793
1766
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1794
- /** @type {TODO} */
1795
- (ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])(
1767
+ /** @type {EXPECTED_ANY} */
1768
+ (ERROR_PRINTERS)[key](
1796
1769
  obj,
1797
1770
  /** @type {DefineStatsPrinterContext<"error">} */
1798
1771
  (ctx),
@@ -1801,15 +1774,12 @@ class DefaultStatsPrinterPlugin {
1801
1774
  );
1802
1775
  }
1803
1776
 
1804
- for (const key of Object.keys(LOG_ENTRY_PRINTERS)) {
1777
+ for (const key of /** @type {(keyof LogEntryPrinters)[]} */ (
1778
+ Object.keys(LOG_ENTRY_PRINTERS)
1779
+ )) {
1805
1780
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1806
- /** @type {TODO} */
1807
- (
1808
- LOG_ENTRY_PRINTERS[
1809
- /** @type {keyof LogEntryPrinters} */
1810
- (key)
1811
- ]
1812
- )(
1781
+ /** @type {EXPECTED_ANY} */
1782
+ (LOG_ENTRY_PRINTERS)[key](
1813
1783
  obj,
1814
1784
  /** @type {DefineStatsPrinterContext<"logging">} */
1815
1785
  (ctx),
@@ -1818,15 +1788,12 @@ class DefaultStatsPrinterPlugin {
1818
1788
  );
1819
1789
  }
1820
1790
 
1821
- for (const key of Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)) {
1791
+ for (const key of /** @type {(keyof ModuleTraceDependencyPrinters)[]} */ (
1792
+ Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)
1793
+ )) {
1822
1794
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1823
1795
  /** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */
1824
- (
1825
- MODULE_TRACE_DEPENDENCY_PRINTERS[
1826
- /** @type {keyof ModuleTraceDependencyPrinters} */
1827
- (key)
1828
- ]
1829
- )(
1796
+ (MODULE_TRACE_DEPENDENCY_PRINTERS[key])(
1830
1797
  obj,
1831
1798
  /** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */
1832
1799
  (ctx),
@@ -1835,15 +1802,12 @@ class DefaultStatsPrinterPlugin {
1835
1802
  );
1836
1803
  }
1837
1804
 
1838
- for (const key of Object.keys(MODULE_TRACE_ITEM_PRINTERS)) {
1805
+ for (const key of /** @type {(keyof ModuleTraceItemPrinters)[]} */ (
1806
+ Object.keys(MODULE_TRACE_ITEM_PRINTERS)
1807
+ )) {
1839
1808
  stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1840
1809
  /** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */
1841
- (
1842
- MODULE_TRACE_ITEM_PRINTERS[
1843
- /** @type {keyof ModuleTraceItemPrinters} */
1844
- (key)
1845
- ]
1846
- )(
1810
+ (MODULE_TRACE_ITEM_PRINTERS[key])(
1847
1811
  obj,
1848
1812
  /** @type {DefineStatsPrinterContext<"moduleTraceItem">} */
1849
1813
  (ctx),
@@ -1877,10 +1841,10 @@ class DefaultStatsPrinterPlugin {
1877
1841
  }
1878
1842
 
1879
1843
  for (const key of Object.keys(SIMPLE_ELEMENT_JOINERS)) {
1880
- const joiner = SIMPLE_ELEMENT_JOINERS[key];
1881
- stats.hooks.printElements
1882
- .for(key)
1883
- .tap(PLUGIN_NAME, /** @type {TODO} */ (joiner));
1844
+ const joiner =
1845
+ /** @type {(items: Item[], context: StatsPrinterContext) => string} */
1846
+ (SIMPLE_ELEMENT_JOINERS[key]);
1847
+ stats.hooks.printElements.for(key).tap(PLUGIN_NAME, joiner);
1884
1848
  }
1885
1849
 
1886
1850
  for (const key of Object.keys(RESULT_MODIFIER)) {
@@ -21,7 +21,10 @@ const smartGrouping = require("../util/smartGrouping");
21
21
  /** @typedef {import("../WebpackError")} WebpackError */
22
22
  /** @typedef {import("../util/comparators").Comparator<EXPECTED_ANY>} Comparator */
23
23
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
24
- /** @typedef {import("../util/smartGrouping").GroupConfig<EXPECTED_ANY, EXPECTED_OBJECT>} GroupConfig */
24
+ /**
25
+ * @template T, R
26
+ * @typedef {import("../util/smartGrouping").GroupConfig<T, R>} GroupConfig
27
+ */
25
28
  /** @typedef {import("./DefaultStatsFactoryPlugin").ChunkGroupInfoWithName} ChunkGroupInfoWithName */
26
29
  /** @typedef {import("./DefaultStatsFactoryPlugin").ModuleIssuerPath} ModuleIssuerPath */
27
30
  /** @typedef {import("./DefaultStatsFactoryPlugin").ModuleTrace} ModuleTrace */
@@ -41,14 +44,14 @@ const smartGrouping = require("../util/smartGrouping");
41
44
  /**
42
45
  * @typedef {object} KnownStatsFactoryContext
43
46
  * @property {string} type
44
- * @property {(path: string) => string} makePathsRelative
45
47
  * @property {Compilation} compilation
48
+ * @property {(path: string) => string} makePathsRelative
46
49
  * @property {Set<Module>} rootModules
47
50
  * @property {Map<string, Chunk[]>} compilationFileToChunks
48
51
  * @property {Map<string, Chunk[]>} compilationAuxiliaryFileToChunks
49
52
  * @property {RuntimeSpec} runtime
50
- * @property {(compilation: Compilation) => WebpackError[]} cachedGetErrors
51
- * @property {(compilation: Compilation) => WebpackError[]} cachedGetWarnings
53
+ * @property {(compilation: Compilation) => Error[]} cachedGetErrors
54
+ * @property {(compilation: Compilation) => Error[]} cachedGetWarnings
52
55
  */
53
56
 
54
57
  /** @typedef {KnownStatsFactoryContext & Record<string, EXPECTED_ANY>} StatsFactoryContext */
@@ -67,10 +70,10 @@ const smartGrouping = require("../util/smartGrouping");
67
70
  * @typedef {T extends ChunkGroupInfoWithName[] ? Record<string, StatsObject<ChunkGroupInfoWithName, F>> : T extends (infer V)[] ? StatsObject<V, F>[] : StatsObject<T, F>} CreatedObject
68
71
  */
69
72
 
70
- /** @typedef {TODO} FactoryData */
71
- /** @typedef {TODO} FactoryDataItem */
72
- /** @typedef {TODO} Result */
73
- /** @typedef {Record<string, TODO>} ObjectForExtract */
73
+ /** @typedef {EXPECTED_ANY} ObjectForExtract */
74
+ /** @typedef {EXPECTED_ANY} FactoryData */
75
+ /** @typedef {EXPECTED_ANY} FactoryDataItem */
76
+ /** @typedef {EXPECTED_ANY} Result */
74
77
 
75
78
  /**
76
79
  * @typedef {object} StatsFactoryHooks
@@ -78,7 +81,7 @@ const smartGrouping = require("../util/smartGrouping");
78
81
  * @property {HookMap<SyncBailHook<[FactoryDataItem, StatsFactoryContext, number, number], boolean | void>>} filter
79
82
  * @property {HookMap<SyncBailHook<[Comparator[], StatsFactoryContext], void>>} sort
80
83
  * @property {HookMap<SyncBailHook<[FactoryDataItem, StatsFactoryContext, number, number], boolean | void>>} filterSorted
81
- * @property {HookMap<SyncBailHook<[GroupConfig[], StatsFactoryContext], void>>} groupResults
84
+ * @property {HookMap<SyncBailHook<[GroupConfig<EXPECTED_ANY, EXPECTED_ANY>[], StatsFactoryContext], void>>} groupResults
82
85
  * @property {HookMap<SyncBailHook<[Comparator[], StatsFactoryContext], void>>} sortResults
83
86
  * @property {HookMap<SyncBailHook<[FactoryDataItem, StatsFactoryContext, number, number], boolean | void>>} filterResults
84
87
  * @property {HookMap<SyncBailHook<[FactoryDataItem[], StatsFactoryContext], Result | void>>} merge
@@ -198,7 +201,7 @@ class StatsFactory {
198
201
  * @param {T} hookMap hook map
199
202
  * @param {Caches<H>} cache cache
200
203
  * @param {string} type type
201
- * @param {Array<FactoryData>} items items
204
+ * @param {FactoryData[]} items items
202
205
  * @param {(hook: H, item: R, idx: number, i: number) => R | undefined} fn fn
203
206
  * @param {boolean} forceClone force clone
204
207
  * @returns {R[]} result for each level
@@ -341,7 +344,7 @@ class StatsFactory {
341
344
  }
342
345
 
343
346
  // group result items
344
- /** @type {GroupConfig[]} */
347
+ /** @type {GroupConfig<EXPECTED_ANY, EXPECTED_ANY>[]} */
345
348
  const groupConfigs = [];
346
349
  this._forEachLevel(
347
350
  this.hooks.groupResults,
@@ -20,11 +20,9 @@ const InnerGraph = require("../optimize/InnerGraph");
20
20
  /** @typedef {import("estree").MemberExpression} MemberExpression */
21
21
  /** @typedef {import("estree").NewExpression} NewExpressionNode */
22
22
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
23
- /** @typedef {import("../ContextModule").ContextMode} ContextMode */
24
23
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
25
24
  /** @typedef {import("../NormalModule")} NormalModule */
26
25
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
27
- /** @typedef {import("../javascript/JavascriptParser")} Parser */
28
26
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
29
27
 
30
28
  const PLUGIN_NAME = "URLParserPlugin";
@@ -36,7 +34,7 @@ const PLUGIN_NAME = "URLParserPlugin";
36
34
  const getUrl = (module) => pathToFileURL(module.resource);
37
35
 
38
36
  /**
39
- * @param {Parser} parser parser parser
37
+ * @param {JavascriptParser} parser parser parser
40
38
  * @param {MemberExpression} arg arg
41
39
  * @returns {boolean} true when it is `meta.url`, otherwise false
42
40
  */
@@ -63,7 +61,7 @@ const getEvaluatedExprCache = new WeakMap();
63
61
 
64
62
  /**
65
63
  * @param {NewExpressionNode} expr expression
66
- * @param {Parser} parser parser parser
64
+ * @param {JavascriptParser} parser parser parser
67
65
  * @returns {BasicEvaluatedExpression | undefined} basic evaluated expression
68
66
  */
69
67
  const getEvaluatedExpr = (expr, parser) => {
@@ -23,9 +23,9 @@ module.exports.equals = (a, b) => {
23
23
  /**
24
24
  * Partition an array by calling a predicate function on each value.
25
25
  * @template T
26
- * @param {Array<T>} arr Array of values to be partitioned
26
+ * @param {T[]} arr Array of values to be partitioned
27
27
  * @param {(value: T) => boolean} fn Partition function which partitions based on truthiness of result.
28
- * @returns {[Array<T>, Array<T>]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
28
+ * @returns {[T[], T[]]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
29
29
  */
30
30
  module.exports.groupBy = (
31
31
  // eslint-disable-next-line default-param-last
@@ -34,9 +34,9 @@ module.exports.groupBy = (
34
34
  ) =>
35
35
  arr.reduce(
36
36
  /**
37
- * @param {[Array<T>, Array<T>]} groups An accumulator storing already partitioned values returned from previous call.
37
+ * @param {[T[], T[]]} groups An accumulator storing already partitioned values returned from previous call.
38
38
  * @param {T} value The value of the current element
39
- * @returns {[Array<T>, Array<T>]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value.
39
+ * @returns {[T[], T[]]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value.
40
40
  */
41
41
  (groups, value) => {
42
42
  groups[fn(value) ? 0 : 1].push(value);
@@ -21,6 +21,7 @@ let inHandleResult = 0;
21
21
  * @callback Callback
22
22
  * @param {(WebpackError | null)=} err
23
23
  * @param {(T | null)=} result
24
+ * @returns {void}
24
25
  */
25
26
 
26
27
  /**
package/lib/util/Hash.js CHANGED
@@ -5,14 +5,31 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ /** @typedef {import("../../declarations/WebpackOptions").HashDigest} Encoding */
9
+
8
10
  class Hash {
9
11
  /* istanbul ignore next */
10
12
  /**
11
13
  * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
12
14
  * @abstract
13
- * @param {string|Buffer} data data
14
- * @param {string=} inputEncoding data encoding
15
- * @returns {this} updated hash
15
+ * @overload
16
+ * @param {string | Buffer} data data
17
+ * @returns {Hash} updated hash
18
+ */
19
+ /**
20
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
21
+ * @abstract
22
+ * @overload
23
+ * @param {string} data data
24
+ * @param {Encoding} inputEncoding data encoding
25
+ * @returns {Hash} updated hash
26
+ */
27
+ /**
28
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
29
+ * @abstract
30
+ * @param {string | Buffer} data data
31
+ * @param {Encoding=} inputEncoding data encoding
32
+ * @returns {Hash} updated hash
16
33
  */
17
34
  update(data, inputEncoding) {
18
35
  const AbstractMethodError = require("../AbstractMethodError");
@@ -24,8 +41,21 @@ class Hash {
24
41
  /**
25
42
  * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
26
43
  * @abstract
27
- * @param {string=} encoding encoding of the return value
28
- * @returns {string|Buffer} digest
44
+ * @overload
45
+ * @returns {Buffer} digest
46
+ */
47
+ /**
48
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
49
+ * @abstract
50
+ * @overload
51
+ * @param {Encoding} encoding encoding of the return value
52
+ * @returns {string} digest
53
+ */
54
+ /**
55
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
56
+ * @abstract
57
+ * @param {Encoding=} encoding encoding of the return value
58
+ * @returns {string | Buffer} digest
29
59
  */
30
60
  digest(encoding) {
31
61
  const AbstractMethodError = require("../AbstractMethodError");
@@ -24,7 +24,7 @@ const merge = (targetSet, toMerge) => {
24
24
  /**
25
25
  * @template T
26
26
  * @param {Set<Iterable<T>>} targetSet set where iterables should be added
27
- * @param {Array<LazySet<T>>} toDeepMerge lazy sets to be flattened
27
+ * @param {LazySet<T>[]} toDeepMerge lazy sets to be flattened
28
28
  * @returns {void}
29
29
  */
30
30
  const flatten = (targetSet, toDeepMerge) => {
@@ -59,7 +59,7 @@ class LazySet {
59
59
  this._set = new Set(iterable);
60
60
  /** @type {Set<Iterable<T>>} */
61
61
  this._toMerge = new Set();
62
- /** @type {Array<LazySet<T>>} */
62
+ /** @type {LazySet<T>[]} */
63
63
  this._toDeepMerge = [];
64
64
  this._needMerge = false;
65
65
  this._deopt = false;
@@ -5,8 +5,6 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- new Map().entries();
9
-
10
8
  /**
11
9
  * The StackedCacheMap is a data structure designed as an alternative to a Map
12
10
  * in situations where you need to handle multiple item additions and
@@ -112,9 +112,14 @@ class TupleSet {
112
112
  * @returns {Iterator<[T, V, ...EXPECTED_ANY]>} iterator
113
113
  */
114
114
  [Symbol.iterator]() {
115
+ /**
116
+ * @template T, V
117
+ * @typedef {MapIterator<[T, InnerMap<T, V> | Set<V>]>} IteratorStack
118
+ */
119
+
115
120
  // This is difficult to type because we can have a map inside a map inside a map, etc. where the end is a set (each key is an argument)
116
121
  // But in basic use we only have 2 arguments in our methods, so we have `Map<K, Set<V>>`
117
- /** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>[]} */
122
+ /** @type {IteratorStack<T, V>[]} */
118
123
  const iteratorStack = [];
119
124
  /** @type {[T?, V?, ...EXPECTED_ANY]} */
120
125
  const tuple = [];
@@ -122,7 +127,7 @@ class TupleSet {
122
127
  let currentSetIterator;
123
128
 
124
129
  /**
125
- * @param {MapIterator<[T, InnerMap<T, V> | Set<V>]>} it iterator
130
+ * @param {IteratorStack<T, V>} it iterator
126
131
  * @returns {boolean} result
127
132
  */
128
133
  const next = (it) => {
@@ -131,7 +136,7 @@ class TupleSet {
131
136
  if (iteratorStack.length === 0) return false;
132
137
  tuple.pop();
133
138
  return next(
134
- /** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>} */
139
+ /** @type {IteratorStack<T, V>} */
135
140
  (iteratorStack.pop())
136
141
  );
137
142
  }
@@ -155,7 +160,7 @@ class TupleSet {
155
160
  tuple.pop();
156
161
  if (
157
162
  !next(
158
- /** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>} */
163
+ /** @type {IteratorStack<T, V>} */
159
164
  (iteratorStack.pop())
160
165
  )
161
166
  ) {
@@ -5,7 +5,6 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /** @typedef {import("./fs").InputFileSystem} InputFileSystem */
9
8
  /** @typedef {(error: Error|null, result?: Buffer) => void} ErrorFirstCallback */
10
9
 
11
10
  const backSlashCharCode = "\\".charCodeAt(0);
@@ -25,7 +25,7 @@ const isWeakKey = (thing) => typeof thing === "object" && thing !== null;
25
25
 
26
26
  /**
27
27
  * @template {unknown[]} T
28
- * @typedef {T extends readonly (infer ElementType)[] ? ElementType : never} ArrayElement
28
+ * @typedef {T extends ReadonlyArray<infer ElementType> ? ElementType : never} ArrayElement
29
29
  */
30
30
 
31
31
  /**
@@ -10,6 +10,8 @@
10
10
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
11
11
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
12
12
 
13
+ /** @typedef {Range[]} IdRanges */
14
+
13
15
  /**
14
16
  * @summary Get the subset of ids and their corresponding range in an id chain that should be re-rendered by webpack.
15
17
  * Only those in the chain that are actually referring to namespaces or imports should be re-rendered.
@@ -18,7 +20,7 @@
18
20
  * because minifiers treat quoted accessors differently. e.g. import { a } from "./module"; a["b"] vs a.b
19
21
  * @param {string[]} untrimmedIds chained ids
20
22
  * @param {Range} untrimmedRange range encompassing allIds
21
- * @param {Range[] | undefined} ranges cumulative range of ids for each of allIds
23
+ * @param {IdRanges | undefined} ranges cumulative range of ids for each of allIds
22
24
  * @param {ModuleGraph} moduleGraph moduleGraph
23
25
  * @param {Dependency} dependency dependency
24
26
  * @returns {{trimmedIds: string[], trimmedRange: Range}} computed trimmed ids and cumulative range of those ids