webpack 5.104.1 → 5.105.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 (323) hide show
  1. package/README.md +2 -2
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +85 -15
  4. package/lib/AbstractMethodError.js +1 -0
  5. package/lib/AsyncDependenciesBlock.js +17 -2
  6. package/lib/AsyncDependencyToInitialChunkError.js +3 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -1
  8. package/lib/BannerPlugin.js +5 -1
  9. package/lib/CacheFacade.js +2 -2
  10. package/lib/CaseSensitiveModulesWarning.js +1 -0
  11. package/lib/Chunk.js +9 -5
  12. package/lib/ChunkGraph.js +30 -9
  13. package/lib/ChunkGroup.js +6 -3
  14. package/lib/ChunkRenderError.js +9 -2
  15. package/lib/CleanPlugin.js +4 -1
  16. package/lib/CodeGenerationError.js +7 -1
  17. package/lib/CodeGenerationResults.js +10 -3
  18. package/lib/CommentCompilationWarning.js +2 -1
  19. package/lib/Compilation.js +284 -236
  20. package/lib/Compiler.js +4 -3
  21. package/lib/ConcatenationScope.js +2 -1
  22. package/lib/ConcurrentCompilationError.js +3 -3
  23. package/lib/ContextModule.js +248 -111
  24. package/lib/ContextModuleFactory.js +14 -2
  25. package/lib/DefinePlugin.js +15 -8
  26. package/lib/DelegatedModule.js +6 -0
  27. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  28. package/lib/Dependency.js +6 -1
  29. package/lib/DependencyTemplates.js +3 -2
  30. package/lib/DllModule.js +2 -0
  31. package/lib/DllReferencePlugin.js +1 -0
  32. package/lib/DotenvPlugin.js +11 -5
  33. package/lib/DynamicEntryPlugin.js +8 -1
  34. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  35. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  36. package/lib/ExportsInfo.js +8 -4
  37. package/lib/ExternalModule.js +16 -0
  38. package/lib/ExternalModuleFactoryPlugin.js +9 -2
  39. package/lib/ExternalsPlugin.js +2 -1
  40. package/lib/FalseIIFEUmdWarning.js +1 -0
  41. package/lib/FileSystemInfo.js +49 -25
  42. package/lib/FlagDependencyExportsPlugin.js +8 -1
  43. package/lib/FlagDependencyUsagePlugin.js +9 -7
  44. package/lib/HarmonyLinkingError.js +1 -0
  45. package/lib/HookWebpackError.js +2 -0
  46. package/lib/HotModuleReplacementPlugin.js +16 -2
  47. package/lib/IgnoreWarningsPlugin.js +5 -2
  48. package/lib/InitFragment.js +1 -0
  49. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  50. package/lib/LibManifestPlugin.js +1 -0
  51. package/lib/ManifestPlugin.js +8 -1
  52. package/lib/Module.js +7 -4
  53. package/lib/ModuleBuildError.js +3 -1
  54. package/lib/ModuleDependencyError.js +1 -0
  55. package/lib/ModuleDependencyWarning.js +1 -0
  56. package/lib/ModuleError.js +4 -1
  57. package/lib/ModuleFilenameHelpers.js +4 -2
  58. package/lib/ModuleGraph.js +3 -0
  59. package/lib/ModuleGraphConnection.js +10 -1
  60. package/lib/ModuleHashingError.js +2 -0
  61. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  62. package/lib/ModuleNotFoundError.js +1 -0
  63. package/lib/ModuleParseError.js +5 -1
  64. package/lib/ModuleProfile.js +1 -1
  65. package/lib/ModuleRestoreError.js +2 -0
  66. package/lib/ModuleSourceTypeConstants.js +1 -11
  67. package/lib/ModuleStoreError.js +2 -0
  68. package/lib/ModuleWarning.js +3 -1
  69. package/lib/MultiCompiler.js +11 -7
  70. package/lib/MultiWatching.js +2 -2
  71. package/lib/NoModeWarning.js +1 -0
  72. package/lib/NodeStuffInWebError.js +1 -0
  73. package/lib/NormalModule.js +28 -5
  74. package/lib/NormalModuleFactory.js +20 -4
  75. package/lib/OptionsApply.js +3 -1
  76. package/lib/ProgressPlugin.js +4 -0
  77. package/lib/RawModule.js +2 -0
  78. package/lib/RuntimeModule.js +10 -0
  79. package/lib/RuntimePlugin.js +7 -9
  80. package/lib/RuntimeTemplate.js +14 -7
  81. package/lib/SourceMapDevToolPlugin.js +30 -23
  82. package/lib/Template.js +10 -5
  83. package/lib/TemplatedPathPlugin.js +4 -2
  84. package/lib/UnhandledSchemeError.js +1 -0
  85. package/lib/UnsupportedFeatureWarning.js +3 -0
  86. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  87. package/lib/WatchIgnorePlugin.js +1 -1
  88. package/lib/Watching.js +5 -0
  89. package/lib/WebpackError.js +4 -0
  90. package/lib/WebpackOptionsApply.js +61 -41
  91. package/lib/asset/AssetBytesGenerator.js +1 -0
  92. package/lib/asset/AssetGenerator.js +18 -3
  93. package/lib/asset/AssetModulesPlugin.js +33 -2
  94. package/lib/asset/AssetParser.js +4 -0
  95. package/lib/asset/AssetSourceGenerator.js +1 -0
  96. package/lib/asset/RawDataUrlModule.js +4 -0
  97. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  98. package/lib/buildChunkGraph.js +31 -2
  99. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  100. package/lib/cache/PackFileCacheStrategy.js +41 -8
  101. package/lib/cache/getLazyHashedEtag.js +13 -4
  102. package/lib/cache/mergeEtags.js +3 -1
  103. package/lib/cli.js +3 -1
  104. package/lib/config/defaults.js +65 -44
  105. package/lib/config/normalization.js +96 -0
  106. package/lib/container/ContainerEntryDependency.js +3 -0
  107. package/lib/container/ContainerEntryModule.js +7 -0
  108. package/lib/container/ContainerExposedDependency.js +1 -0
  109. package/lib/container/FallbackDependency.js +1 -0
  110. package/lib/container/FallbackItemDependency.js +1 -0
  111. package/lib/container/FallbackModule.js +4 -0
  112. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  113. package/lib/container/ModuleFederationPlugin.js +1 -1
  114. package/lib/container/RemoteModule.js +24 -0
  115. package/lib/css/CssGenerator.js +31 -4
  116. package/lib/css/CssModulesPlugin.js +26 -30
  117. package/lib/css/CssParser.js +12 -9
  118. package/lib/debug/ProfilingPlugin.js +1 -0
  119. package/lib/dependencies/AMDDefineDependency.js +3 -1
  120. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  121. package/lib/dependencies/AMDPlugin.js +1 -1
  122. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  123. package/lib/dependencies/CachedConstDependency.js +1 -0
  124. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  125. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  126. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  127. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  128. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  129. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  130. package/lib/dependencies/ConstDependency.js +1 -0
  131. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  132. package/lib/dependencies/ContextElementDependency.js +1 -0
  133. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  134. package/lib/dependencies/CssIcssExportDependency.js +7 -4
  135. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  136. package/lib/dependencies/CssUrlDependency.js +2 -3
  137. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  138. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  139. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  140. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
  141. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  142. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  143. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  144. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  145. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  146. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +269 -5
  147. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  148. package/lib/dependencies/ImportDependency.js +1 -0
  149. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  150. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  151. package/lib/dependencies/ImportParserPlugin.js +7 -12
  152. package/lib/dependencies/LoaderPlugin.js +3 -0
  153. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  154. package/lib/dependencies/ModuleDependency.js +1 -0
  155. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  156. package/lib/dependencies/ProvidedDependency.js +1 -0
  157. package/lib/dependencies/RequireContextPlugin.js +1 -0
  158. package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
  159. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  160. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  161. package/lib/dependencies/WorkerDependency.js +9 -3
  162. package/lib/dependencies/WorkerPlugin.js +1 -0
  163. package/lib/dependencies/getFunctionExpression.js +3 -1
  164. package/lib/electron/ElectronTargetPlugin.js +3 -1
  165. package/lib/errors/BuildCycleError.js +4 -1
  166. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  167. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  168. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  169. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  170. package/lib/hmr/lazyCompilationBackend.js +3 -2
  171. package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
  172. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
  173. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
  174. package/lib/ids/HashedModuleIdsPlugin.js +3 -8
  175. package/lib/ids/IdHelpers.js +10 -8
  176. package/lib/ids/NamedChunkIdsPlugin.js +7 -5
  177. package/lib/ids/NamedModuleIdsPlugin.js +1 -0
  178. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  179. package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
  180. package/lib/ids/SyncModuleIdsPlugin.js +30 -20
  181. package/lib/index.js +2 -2
  182. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  183. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  184. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  185. package/lib/javascript/JavascriptParser.js +47 -14
  186. package/lib/json/JsonGenerator.js +1 -0
  187. package/lib/json/JsonParser.js +9 -2
  188. package/lib/library/AbstractLibraryPlugin.js +4 -1
  189. package/lib/library/AmdLibraryPlugin.js +2 -1
  190. package/lib/library/AssignLibraryPlugin.js +6 -2
  191. package/lib/library/EnableLibraryPlugin.js +1 -0
  192. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  193. package/lib/library/JsonpLibraryPlugin.js +1 -1
  194. package/lib/library/ModuleLibraryPlugin.js +130 -13
  195. package/lib/library/SystemLibraryPlugin.js +4 -1
  196. package/lib/library/UmdLibraryPlugin.js +4 -3
  197. package/lib/logging/Logger.js +9 -5
  198. package/lib/logging/createConsoleLogger.js +4 -0
  199. package/lib/logging/truncateArgs.js +1 -1
  200. package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
  201. package/lib/node/NodeEnvironmentPlugin.js +1 -0
  202. package/lib/node/NodeTargetPlugin.js +10 -1
  203. package/lib/node/NodeTemplatePlugin.js +1 -0
  204. package/lib/node/NodeWatchFileSystem.js +6 -0
  205. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
  206. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  207. package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
  208. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
  209. package/lib/node/nodeConsole.js +18 -1
  210. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  211. package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
  212. package/lib/optimize/ConcatenatedModule.js +33 -19
  213. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  214. package/lib/optimize/InnerGraph.js +5 -3
  215. package/lib/optimize/InnerGraphPlugin.js +25 -25
  216. package/lib/optimize/LimitChunkCountPlugin.js +3 -2
  217. package/lib/optimize/MangleExportsPlugin.js +14 -2
  218. package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
  219. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  220. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  221. package/lib/optimize/RealContentHashPlugin.js +37 -27
  222. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  223. package/lib/optimize/RuntimeChunkPlugin.js +3 -5
  224. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  225. package/lib/optimize/SplitChunksPlugin.js +23 -5
  226. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  227. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  228. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  229. package/lib/performance/SizeLimitsPlugin.js +6 -6
  230. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
  231. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
  232. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
  233. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
  234. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  235. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  236. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  237. package/lib/rules/RuleSetCompiler.js +6 -0
  238. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  239. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  240. package/lib/runtime/CompatRuntimeModule.js +1 -0
  241. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  242. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
  243. package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
  244. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  245. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  246. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
  248. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  249. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  250. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  251. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  252. package/lib/schemes/HttpUriPlugin.js +39 -20
  253. package/lib/schemes/VirtualUrlPlugin.js +28 -2
  254. package/lib/serialization/BinaryMiddleware.js +4 -0
  255. package/lib/serialization/FileMiddleware.js +9 -4
  256. package/lib/serialization/ObjectMiddleware.js +34 -11
  257. package/lib/serialization/PlainObjectSerializer.js +2 -0
  258. package/lib/sharing/ConsumeSharedModule.js +60 -0
  259. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  260. package/lib/sharing/ProvideSharedModule.js +4 -0
  261. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  262. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  263. package/lib/sharing/utils.js +8 -6
  264. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -12
  265. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  266. package/lib/stats/StatsFactory.js +2 -2
  267. package/lib/url/URLParserPlugin.js +5 -3
  268. package/lib/util/AppendOnlyStackedSet.js +57 -0
  269. package/lib/util/Hash.js +1 -0
  270. package/lib/util/IterableHelpers.js +1 -0
  271. package/lib/util/LazyBucketSortedSet.js +1 -0
  272. package/lib/util/LazySet.js +1 -0
  273. package/lib/util/ParallelismFactorCalculator.js +1 -0
  274. package/lib/util/SortableSet.js +1 -0
  275. package/lib/util/StringXor.js +1 -0
  276. package/lib/util/binarySearchBounds.js +15 -8
  277. package/lib/util/chainedImports.js +1 -1
  278. package/lib/util/cleverMerge.js +6 -1
  279. package/lib/util/comparators.js +21 -1
  280. package/lib/util/compileBooleanMatcher.js +3 -3
  281. package/lib/util/concatenate.js +3 -2
  282. package/lib/util/conventions.js +3 -2
  283. package/lib/util/deterministicGrouping.js +13 -1
  284. package/lib/util/extractSourceMap.js +12 -13
  285. package/lib/util/fs.js +15 -19
  286. package/lib/util/hash/BatchedHash.js +4 -0
  287. package/lib/util/hash/BulkUpdateHash.js +8 -1
  288. package/lib/util/hash/hash-digest.js +1 -0
  289. package/lib/util/hash/wasm-hash.js +18 -2
  290. package/lib/util/identifier.js +7 -2
  291. package/lib/util/magicComment.js +1 -1
  292. package/lib/util/propertyName.js +1 -1
  293. package/lib/util/registerExternalSerializer.js +1 -0
  294. package/lib/util/runtime.js +15 -1
  295. package/lib/util/semver.js +1 -0
  296. package/lib/util/serialization.js +2 -2
  297. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
  298. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  299. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  300. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  301. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  302. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  303. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  304. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  305. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  306. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  307. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  308. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  309. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  310. package/lib/webpack.js +16 -4
  311. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  312. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
  313. package/package.json +33 -36
  314. package/schemas/WebpackOptions.check.js +1 -1
  315. package/schemas/WebpackOptions.json +121 -55
  316. package/schemas/plugins/BannerPlugin.json +2 -2
  317. package/schemas/plugins/IgnorePlugin.json +1 -1
  318. package/schemas/plugins/ManifestPlugin.json +3 -3
  319. package/schemas/plugins/ProgressPlugin.json +1 -1
  320. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  321. package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
  322. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  323. package/types.d.ts +440 -137
@@ -120,10 +120,10 @@ class InnerGraphPlugin {
120
120
  statement.type === "FunctionDeclaration"
121
121
  ) {
122
122
  const name = statement.id ? statement.id.name : "*default*";
123
- const fn =
123
+ const symbol =
124
124
  /** @type {TopLevelSymbol} */
125
125
  (InnerGraph.tagTopLevelSymbol(parser, name));
126
- statementWithTopLevelSymbol.set(statement, fn);
126
+ statementWithTopLevelSymbol.set(statement, symbol);
127
127
  return true;
128
128
  }
129
129
  });
@@ -140,15 +140,15 @@ class InnerGraphPlugin {
140
140
  )
141
141
  ) {
142
142
  const name = statement.id ? statement.id.name : "*default*";
143
- const fn = /** @type {TopLevelSymbol} */ (
143
+ const symbol = /** @type {TopLevelSymbol} */ (
144
144
  InnerGraph.tagTopLevelSymbol(parser, name)
145
145
  );
146
- classWithTopLevelSymbol.set(statement, fn);
146
+ classWithTopLevelSymbol.set(statement, symbol);
147
147
  return true;
148
148
  }
149
149
  if (statement.type === "ExportDefaultDeclaration") {
150
150
  const name = "*default*";
151
- const fn =
151
+ const symbol =
152
152
  /** @type {TopLevelSymbol} */
153
153
  (InnerGraph.tagTopLevelSymbol(parser, name));
154
154
  const decl = statement.declaration;
@@ -165,7 +165,7 @@ class InnerGraphPlugin {
165
165
  classWithTopLevelSymbol.set(
166
166
  /** @type {ClassExpression | ClassDeclaration} */
167
167
  (decl),
168
- fn
168
+ symbol
169
169
  );
170
170
  } else if (
171
171
  parser.isPure(
@@ -175,7 +175,7 @@ class InnerGraphPlugin {
175
175
  (statement.range)[0]
176
176
  )
177
177
  ) {
178
- statementWithTopLevelSymbol.set(statement, fn);
178
+ statementWithTopLevelSymbol.set(statement, symbol);
179
179
  if (
180
180
  !decl.type.endsWith("FunctionExpression") &&
181
181
  !decl.type.endsWith("Declaration") &&
@@ -207,20 +207,20 @@ class InnerGraphPlugin {
207
207
  /** @type {Range} */ (decl.id.range)[1]
208
208
  )
209
209
  ) {
210
- const fn =
210
+ const symbol =
211
211
  /** @type {TopLevelSymbol} */
212
212
  (InnerGraph.tagTopLevelSymbol(parser, name));
213
- classWithTopLevelSymbol.set(decl.init, fn);
213
+ classWithTopLevelSymbol.set(decl.init, symbol);
214
214
  } else if (
215
215
  parser.isPure(
216
216
  decl.init,
217
217
  /** @type {Range} */ (decl.id.range)[1]
218
218
  )
219
219
  ) {
220
- const fn =
220
+ const symbol =
221
221
  /** @type {TopLevelSymbol} */
222
222
  (InnerGraph.tagTopLevelSymbol(parser, name));
223
- declWithTopLevelSymbol.set(decl, fn);
223
+ declWithTopLevelSymbol.set(decl, symbol);
224
224
  if (
225
225
  !decl.init.type.endsWith("FunctionExpression") &&
226
226
  decl.init.type !== "Literal"
@@ -252,9 +252,9 @@ class InnerGraphPlugin {
252
252
  if (parser.scope.topLevelScope === true) {
253
253
  InnerGraph.setTopLevelSymbol(parser.state, undefined);
254
254
 
255
- const fn = statementWithTopLevelSymbol.get(statement);
256
- if (fn) {
257
- InnerGraph.setTopLevelSymbol(parser.state, fn);
255
+ const symbol = statementWithTopLevelSymbol.get(statement);
256
+ if (symbol) {
257
+ InnerGraph.setTopLevelSymbol(parser.state, symbol);
258
258
  const purePart = statementPurePart.get(statement);
259
259
  if (purePart) {
260
260
  InnerGraph.onUsage(parser.state, (usedByExports) => {
@@ -285,9 +285,9 @@ class InnerGraphPlugin {
285
285
  (expr, statement) => {
286
286
  if (!InnerGraph.isEnabled(parser.state)) return;
287
287
  if (parser.scope.topLevelScope === true) {
288
- const fn = classWithTopLevelSymbol.get(statement);
288
+ const symbol = classWithTopLevelSymbol.get(statement);
289
289
  if (
290
- fn &&
290
+ symbol &&
291
291
  parser.isPure(
292
292
  expr,
293
293
  statement.id
@@ -295,7 +295,7 @@ class InnerGraphPlugin {
295
295
  : /** @type {Range} */ (statement.range)[0]
296
296
  )
297
297
  ) {
298
- InnerGraph.setTopLevelSymbol(parser.state, fn);
298
+ InnerGraph.setTopLevelSymbol(parser.state, symbol);
299
299
  onUsageSuper(expr);
300
300
  }
301
301
  }
@@ -307,8 +307,8 @@ class InnerGraphPlugin {
307
307
  (element, classDefinition) => {
308
308
  if (!InnerGraph.isEnabled(parser.state)) return;
309
309
  if (parser.scope.topLevelScope === true) {
310
- const fn = classWithTopLevelSymbol.get(classDefinition);
311
- if (fn) {
310
+ const symbol = classWithTopLevelSymbol.get(classDefinition);
311
+ if (symbol) {
312
312
  InnerGraph.setTopLevelSymbol(parser.state, undefined);
313
313
  }
314
314
  }
@@ -320,8 +320,8 @@ class InnerGraphPlugin {
320
320
  (expression, element, classDefinition) => {
321
321
  if (!InnerGraph.isEnabled(parser.state)) return;
322
322
  if (parser.scope.topLevelScope === true) {
323
- const fn = classWithTopLevelSymbol.get(classDefinition);
324
- if (fn) {
323
+ const symbol = classWithTopLevelSymbol.get(classDefinition);
324
+ if (symbol) {
325
325
  if (
326
326
  !element.static ||
327
327
  parser.isPure(
@@ -331,7 +331,7 @@ class InnerGraphPlugin {
331
331
  : /** @type {Range} */ (element.range)[0]
332
332
  )
333
333
  ) {
334
- InnerGraph.setTopLevelSymbol(parser.state, fn);
334
+ InnerGraph.setTopLevelSymbol(parser.state, symbol);
335
335
  if (element.type !== "MethodDefinition" && element.static) {
336
336
  InnerGraph.onUsage(parser.state, (usedByExports) => {
337
337
  switch (usedByExports) {
@@ -362,10 +362,10 @@ class InnerGraphPlugin {
362
362
 
363
363
  parser.hooks.declarator.tap(PLUGIN_NAME, (decl, _statement) => {
364
364
  if (!InnerGraph.isEnabled(parser.state)) return;
365
- const fn = declWithTopLevelSymbol.get(decl);
365
+ const symbol = declWithTopLevelSymbol.get(decl);
366
366
 
367
- if (fn) {
368
- InnerGraph.setTopLevelSymbol(parser.state, fn);
367
+ if (symbol) {
368
+ InnerGraph.setTopLevelSymbol(parser.state, symbol);
369
369
  if (pureDeclarators.has(decl)) {
370
370
  if (
371
371
  /** @type {ClassExpression} */
@@ -57,9 +57,10 @@ class LimitChunkCountPlugin {
57
57
  /**
58
58
  * @param {LimitChunkCountPluginOptions=} options options object
59
59
  */
60
- constructor(options) {
60
+ constructor(options = { maxChunks: 1 }) {
61
61
  validate(options);
62
- this.options = /** @type {LimitChunkCountPluginOptions} */ (options);
62
+ /** @type {LimitChunkCountPluginOptions} */
63
+ this.options = options;
63
64
  }
64
65
 
65
66
  /**
@@ -17,6 +17,12 @@ const { compareSelect, compareStringsNumeric } = require("../util/comparators");
17
17
  /** @typedef {import("../Compiler")} Compiler */
18
18
  /** @typedef {import("../ExportsInfo")} ExportsInfo */
19
19
  /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
20
+ /** @typedef {import("../util/concatenate").UsedNames} UsedNames */
21
+
22
+ /**
23
+ * @template T
24
+ * @typedef {import("../util/comparators").Comparator<T>} Comparator
25
+ */
20
26
 
21
27
  /**
22
28
  * @param {ExportsInfo} exportsInfo exports info
@@ -36,6 +42,7 @@ const canMangle = (exportsInfo) => {
36
42
  };
37
43
 
38
44
  // Sort by name
45
+ /** @type {Comparator<ExportInfo>} */
39
46
  const comparator = compareSelect((e) => e.name, compareStringsNumeric);
40
47
  /**
41
48
  * @param {boolean} deterministic use deterministic names
@@ -45,6 +52,7 @@ const comparator = compareSelect((e) => e.name, compareStringsNumeric);
45
52
  */
46
53
  const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
47
54
  if (!canMangle(exportsInfo)) return;
55
+ /** @type {UsedNames} */
48
56
  const usedNames = new Set();
49
57
  /** @type {ExportInfo[]} */
50
58
  const mangleableExports = [];
@@ -69,11 +77,11 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
69
77
  // Can the export be mangled?
70
78
  exportInfo.canMangle !== true ||
71
79
  // Never rename 1 char exports
72
- (name.length === 1 && /^[a-zA-Z0-9_$]/.test(name)) ||
80
+ (name.length === 1 && /^[a-z0-9_$]/i.test(name)) ||
73
81
  // Don't rename 2 char exports in deterministic mode
74
82
  (deterministic &&
75
83
  name.length === 2 &&
76
- /^[a-zA-Z_$][a-zA-Z0-9_$]|^[1-9][0-9]/.test(name)) ||
84
+ /^[a-z_$][a-z0-9_$]|^[1-9][0-9]/i.test(name)) ||
77
85
  // Don't rename exports that are not provided
78
86
  (avoidMangleNonProvided && exportInfo.provided !== true)
79
87
  ) {
@@ -119,7 +127,9 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
119
127
  usedNames.size
120
128
  );
121
129
  } else {
130
+ /** @type {ExportInfo[]} */
122
131
  const usedExports = [];
132
+ /** @type {ExportInfo[]} */
123
133
  const unusedExports = [];
124
134
  for (const exportInfo of mangleableExports) {
125
135
  if (exportInfo.getUsed(undefined) === UsageState.Unused) {
@@ -133,6 +143,7 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
133
143
  let i = 0;
134
144
  for (const list of [usedExports, unusedExports]) {
135
145
  for (const exportInfo of list) {
146
+ /** @type {string} */
136
147
  let name;
137
148
  do {
138
149
  name = numberToIdentifier(i++);
@@ -150,6 +161,7 @@ class MangleExportsPlugin {
150
161
  * @param {boolean} deterministic use deterministic names
151
162
  */
152
163
  constructor(deterministic) {
164
+ /** @type {boolean} */
153
165
  this._deterministic = deterministic;
154
166
  }
155
167
 
@@ -11,6 +11,7 @@ const { runtimeEqual } = require("../util/runtime");
11
11
 
12
12
  /** @typedef {import("../../declarations/plugins/optimize/MergeDuplicateChunksPlugin").MergeDuplicateChunksPluginOptions} MergeDuplicateChunksPluginOptions */
13
13
  /** @typedef {import("../Compiler")} Compiler */
14
+ /** @typedef {import("../Chunk")} Chunk */
14
15
 
15
16
  const validate = createSchemaValidation(
16
17
  require("../../schemas/plugins/optimize/MergeDuplicateChunksPlugin.check"),
@@ -26,10 +27,11 @@ const PLUGIN_NAME = "MergeDuplicateChunksPlugin";
26
27
 
27
28
  class MergeDuplicateChunksPlugin {
28
29
  /**
29
- * @param {MergeDuplicateChunksPluginOptions} options options object
30
+ * @param {MergeDuplicateChunksPluginOptions=} options options object
30
31
  */
31
32
  constructor(options = { stage: STAGE_BASIC }) {
32
33
  validate(options);
34
+ /** @type {MergeDuplicateChunksPluginOptions} */
33
35
  this.options = options;
34
36
  }
35
37
 
@@ -48,11 +50,13 @@ class MergeDuplicateChunksPlugin {
48
50
  const { chunkGraph, moduleGraph } = compilation;
49
51
 
50
52
  // remember already tested chunks for performance
53
+ /** @type {Set<Chunk>} */
51
54
  const notDuplicates = new Set();
52
55
 
53
56
  // for each chunk
54
57
  for (const chunk of chunks) {
55
58
  // track a Set of all chunk that could be duplicates
59
+ /** @type {Set<Chunk> | undefined} */
56
60
  let possibleDuplicates;
57
61
  for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
58
62
  if (possibleDuplicates === undefined) {
@@ -29,6 +29,7 @@ class MinChunkSizePlugin {
29
29
  */
30
30
  constructor(options) {
31
31
  validate(options);
32
+ /** @type {MinChunkSizePluginOptions} */
32
33
  this.options = options;
33
34
  }
34
35
 
@@ -53,11 +54,13 @@ class MinChunkSizePlugin {
53
54
  entryChunkMultiplicator: 1
54
55
  };
55
56
 
57
+ /** @type {Map<Chunk, number>} */
56
58
  const chunkSizesMap = new Map();
57
59
  /** @type {[Chunk, Chunk][]} */
58
60
  const combinations = [];
59
61
  /** @type {Chunk[]} */
60
62
  const smallChunks = [];
63
+ /** @type {Chunk[]} */
61
64
  const visitedChunks = [];
62
65
  for (const a of chunks) {
63
66
  // check if one of the chunks sizes is smaller than the minChunkSize
@@ -83,8 +86,8 @@ class MinChunkSizePlugin {
83
86
  const sortedSizeFilteredExtendedPairCombinations = combinations
84
87
  .map((pair) => {
85
88
  // extend combination pairs with size and integrated size
86
- const a = chunkSizesMap.get(pair[0]);
87
- const b = chunkSizesMap.get(pair[1]);
89
+ const a = /** @type {number} */ (chunkSizesMap.get(pair[0]));
90
+ const b = /** @type {number} */ (chunkSizesMap.get(pair[1]));
88
91
  const ab = chunkGraph.getIntegratedChunksSize(
89
92
  pair[0],
90
93
  pair[1],
@@ -28,6 +28,8 @@ const ConcatenatedModule = require("./ConcatenatedModule");
28
28
  /** @typedef {import("../RequestShortener")} RequestShortener */
29
29
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
30
30
 
31
+ /** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
32
+
31
33
  /**
32
34
  * @typedef {object} Statistics
33
35
  * @property {number} cached
@@ -104,7 +106,7 @@ class ModuleConcatenationPlugin {
104
106
 
105
107
  /**
106
108
  * @param {Module} module the module
107
- * @param {Module | ((requestShortener: RequestShortener) => string)} problem the problem
109
+ * @param {Problem} problem the problem
108
110
  * @returns {(requestShortener: RequestShortener) => string} the reason
109
111
  */
110
112
  const formatBailoutWarning = (module, problem) => (requestShortener) => {
@@ -143,7 +145,9 @@ class ModuleConcatenationPlugin {
143
145
  "webpack.ModuleConcatenationPlugin"
144
146
  );
145
147
  const { chunkGraph, moduleGraph } = compilation;
148
+ /** @type {Module[]} */
146
149
  const relevantModules = [];
150
+ /** @type {Set<Module>} */
147
151
  const possibleInners = new Set();
148
152
  const context = {
149
153
  chunkGraph,
@@ -265,7 +269,9 @@ class ModuleConcatenationPlugin {
265
269
  let statsEmptyConfigurations = 0;
266
270
 
267
271
  logger.time("find modules to concatenate");
272
+ /** @type {ConcatConfiguration[]} */
268
273
  const concatConfigurations = [];
274
+ /** @type {Set<Module>} */
269
275
  const usedAsInner = new Set();
270
276
  for (const currentRoot of relevantModules) {
271
277
  // when used by another configuration as inner:
@@ -273,6 +279,7 @@ class ModuleConcatenationPlugin {
273
279
  // TODO reconsider that when it's only used in a different runtime
274
280
  if (usedAsInner.has(currentRoot)) continue;
275
281
 
282
+ /** @type {RuntimeSpec} */
276
283
  let chunkRuntime;
277
284
  for (const r of chunkGraph.getModuleRuntimes(currentRoot)) {
278
285
  chunkRuntime = mergeRuntimeOwned(chunkRuntime, r);
@@ -295,6 +302,7 @@ class ModuleConcatenationPlugin {
295
302
  );
296
303
 
297
304
  // cache failures to add modules
305
+ /** @type {Map<Module, Problem>} */
298
306
  const failureCache = new Map();
299
307
 
300
308
  // potential optional import candidates
@@ -311,6 +319,7 @@ class ModuleConcatenationPlugin {
311
319
  }
312
320
 
313
321
  for (const imp of candidates) {
322
+ /** @type {Set<Module>} */
314
323
  const impCandidates = new Set();
315
324
  const problem = this._tryToAdd(
316
325
  compilation,
@@ -373,6 +382,7 @@ class ModuleConcatenationPlugin {
373
382
  logger.time("sort concat configurations");
374
383
  concatConfigurations.sort((a, b) => b.modules.size - a.modules.size);
375
384
  logger.timeEnd("sort concat configurations");
385
+ /** @type {Set<Module>} */
376
386
  const usedModules = new Set();
377
387
 
378
388
  logger.time("create concatenated modules");
@@ -515,6 +525,7 @@ class ModuleConcatenationPlugin {
515
525
  */
516
526
  _getImports(compilation, module, runtime) {
517
527
  const moduleGraph = compilation.moduleGraph;
528
+ /** @type {Set<Module>} */
518
529
  const set = new Set();
519
530
  for (const dep of module.dependencies) {
520
531
  // Get reference info only for harmony Dependencies
@@ -555,11 +566,11 @@ class ModuleConcatenationPlugin {
555
566
  * @param {RuntimeSpec} activeRuntime the runtime scope of the root module
556
567
  * @param {Set<Module>} possibleModules modules that are candidates
557
568
  * @param {Set<Module>} candidates list of potential candidates (will be added to)
558
- * @param {Map<Module, Module | ((requestShortener: RequestShortener) => string)>} failureCache cache for problematic modules to be more performant
569
+ * @param {Map<Module, Problem>} failureCache cache for problematic modules to be more performant
559
570
  * @param {ChunkGraph} chunkGraph the chunk graph
560
571
  * @param {boolean} avoidMutateOnFailure avoid mutating the config when adding fails
561
572
  * @param {Statistics} statistics gathering metrics
562
- * @returns {null | Module | ((requestShortener: RequestShortener) => string)} the problematic module
573
+ * @returns {null | Problem} the problematic module
563
574
  */
564
575
  _tryToAdd(
565
576
  compilation,
@@ -646,6 +657,7 @@ class ModuleConcatenationPlugin {
646
657
  * @returns {string} problem description
647
658
  */
648
659
  const problem = (requestShortener) => {
660
+ /** @type {Set<string>} */
649
661
  const importingExplanations = new Set(
650
662
  activeNonModulesConnections
651
663
  .map((c) => c.explanation)
@@ -674,6 +686,7 @@ class ModuleConcatenationPlugin {
674
686
  if (chunkGraph.getNumberOfModuleChunks(originModule) === 0) continue;
675
687
 
676
688
  // We don't care for connections from other runtimes
689
+ /** @type {RuntimeSpec} */
677
690
  let originRuntime;
678
691
  for (const r of chunkGraph.getModuleRuntimes(originModule)) {
679
692
  originRuntime = mergeRuntimeOwned(originRuntime, r);
@@ -822,6 +835,7 @@ class ModuleConcatenationPlugin {
822
835
  }
823
836
  }
824
837
 
838
+ /** @type {undefined | number} */
825
839
  let backup;
826
840
  if (avoidMutateOnFailure) {
827
841
  backup = config.snapshot();
@@ -864,7 +878,6 @@ class ModuleConcatenationPlugin {
864
878
  }
865
879
  }
866
880
 
867
- /** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
868
881
  /** @typedef {Map<Module, Problem>} Warnings */
869
882
 
870
883
  class ConcatConfiguration {
@@ -873,7 +886,9 @@ class ConcatConfiguration {
873
886
  * @param {RuntimeSpec} runtime the runtime
874
887
  */
875
888
  constructor(rootModule, runtime) {
889
+ /** @type {Module} */
876
890
  this.rootModule = rootModule;
891
+ /** @type {RuntimeSpec} */
877
892
  this.runtime = runtime;
878
893
  /** @type {Set<Module>} */
879
894
  this.modules = new Set();
@@ -20,6 +20,12 @@ const createHash = require("../util/createHash");
20
20
  /** @typedef {import("../Compiler")} Compiler */
21
21
  /** @typedef {typeof import("../util/Hash")} Hash */
22
22
 
23
+ /**
24
+ * @template T
25
+ * @typedef {import("../util/comparators").Comparator<T>} Comparator
26
+ */
27
+
28
+ /** @type {Hashes} */
23
29
  const EMPTY_SET = new Set();
24
30
 
25
31
  /**
@@ -47,6 +53,7 @@ const mapAndDeduplicateBuffers = (input, fn) => {
47
53
  // Buffer.equals compares size first so this should be efficient enough
48
54
  // If it becomes a performance problem we can use a map and group by size
49
55
  // instead of looping over all assets.
56
+ /** @type {Buffer[]} */
50
57
  const result = [];
51
58
  outer: for (const value of input) {
52
59
  const buf = fn(value);
@@ -65,6 +72,7 @@ const mapAndDeduplicateBuffers = (input, fn) => {
65
72
  */
66
73
  const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
67
74
 
75
+ /** @type {WeakMap<Source, CachedSource>} */
68
76
  const cachedSourceMap = new WeakMap();
69
77
 
70
78
  /**
@@ -82,8 +90,6 @@ const toCachedSource = (source) => {
82
90
  return newSource;
83
91
  };
84
92
 
85
- /** @typedef {Set<string>} OwnHashes */
86
- /** @typedef {Set<string>} ReferencedHashes */
87
93
  /** @typedef {Set<string>} Hashes */
88
94
 
89
95
  /**
@@ -94,10 +100,10 @@ const toCachedSource = (source) => {
94
100
  * @property {RawSource | undefined} newSource
95
101
  * @property {RawSource | undefined} newSourceWithoutOwn
96
102
  * @property {string} content
97
- * @property {OwnHashes | undefined} ownHashes
103
+ * @property {Hashes | undefined} ownHashes
98
104
  * @property {Promise<void> | undefined} contentComputePromise
99
105
  * @property {Promise<void> | undefined} contentComputeWithoutOwnPromise
100
- * @property {ReferencedHashes | undefined} referencedHashes
106
+ * @property {Hashes | undefined} referencedHashes
101
107
  * @property {Hashes} hashes
102
108
  */
103
109
 
@@ -142,7 +148,9 @@ class RealContentHashPlugin {
142
148
  * @param {RealContentHashPluginOptions} options options
143
149
  */
144
150
  constructor({ hashFunction, hashDigest }) {
151
+ /** @type {HashFunction} */
145
152
  this._hashFunction = hashFunction;
153
+ /** @type {HashDigest} */
146
154
  this._hashDigest = hashDigest;
147
155
  }
148
156
 
@@ -220,7 +228,9 @@ class RealContentHashPlugin {
220
228
  );
221
229
  [asset.referencedHashes, asset.ownHashes] =
222
230
  await cacheAnalyse.providePromise(name, etag, () => {
231
+ /** @type {Hashes} */
223
232
  const referencedHashes = new Set();
233
+ /** @type {Hashes} */
224
234
  const ownHashes = new Set();
225
235
  const inContent = content.match(hashRegExp);
226
236
  if (inContent) {
@@ -238,15 +248,13 @@ class RealContentHashPlugin {
238
248
  );
239
249
  /**
240
250
  * @param {string} hash the hash
241
- * @returns {undefined | ReferencedHashes} the referenced hashes
251
+ * @returns {undefined | Hashes} the referenced hashes
242
252
  */
243
253
  const getDependencies = (hash) => {
244
254
  const assets = hashToAssets.get(hash);
245
255
  if (!assets) {
246
256
  const referencingAssets = assetsWithInfo.filter((asset) =>
247
- /** @type {ReferencedHashes} */ (asset.referencedHashes).has(
248
- hash
249
- )
257
+ /** @type {Hashes} */ (asset.referencedHashes).has(hash)
250
258
  );
251
259
  const err = new WebpackError(`RealContentHashPlugin
252
260
  Some kind of unexpected caching problem occurred.
@@ -264,16 +272,15 @@ ${referencingAssets
264
272
  compilation.errors.push(err);
265
273
  return;
266
274
  }
275
+ /** @type {Hashes} */
267
276
  const hashes = new Set();
268
277
  for (const { referencedHashes, ownHashes } of assets) {
269
- if (!(/** @type {OwnHashes} */ (ownHashes).has(hash))) {
270
- for (const hash of /** @type {OwnHashes} */ (ownHashes)) {
278
+ if (!(/** @type {Hashes} */ (ownHashes).has(hash))) {
279
+ for (const hash of /** @type {Hashes} */ (ownHashes)) {
271
280
  hashes.add(hash);
272
281
  }
273
282
  }
274
- for (const hash of /** @type {ReferencedHashes} */ (
275
- referencedHashes
276
- )) {
283
+ for (const hash of /** @type {Hashes} */ (referencedHashes)) {
277
284
  hashes.add(hash);
278
285
  }
279
286
  }
@@ -290,7 +297,7 @@ ${referencingAssets
290
297
  (a) => a.name
291
298
  )})`;
292
299
  };
293
- /** @type {Set<string>} */
300
+ /** @type {Hashes} */
294
301
  const hashesInOrder = new Set();
295
302
  for (const hash of hashToAssets.keys()) {
296
303
  /**
@@ -329,7 +336,7 @@ ${referencingAssets
329
336
  cacheGenerate.mergeEtags(
330
337
  cacheGenerate.getLazyHashedEtag(asset.source),
331
338
  Array.from(
332
- /** @type {ReferencedHashes} */ (asset.referencedHashes),
339
+ /** @type {Hashes} */ (asset.referencedHashes),
333
340
  (hash) => hashToNewHash.get(hash)
334
341
  ).join("|")
335
342
  );
@@ -341,10 +348,10 @@ ${referencingAssets
341
348
  if (asset.contentComputePromise) return asset.contentComputePromise;
342
349
  return (asset.contentComputePromise = (async () => {
343
350
  if (
344
- /** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
345
- [
346
- .../** @type {ReferencedHashes} */ (asset.referencedHashes)
347
- ].some((hash) => hashToNewHash.get(hash) !== hash)
351
+ /** @type {Hashes} */ (asset.ownHashes).size > 0 ||
352
+ [.../** @type {Hashes} */ (asset.referencedHashes)].some(
353
+ (hash) => hashToNewHash.get(hash) !== hash
354
+ )
348
355
  ) {
349
356
  const identifier = asset.name;
350
357
  const etag = getEtag(asset);
@@ -372,10 +379,10 @@ ${referencingAssets
372
379
  }
373
380
  return (asset.contentComputeWithoutOwnPromise = (async () => {
374
381
  if (
375
- /** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
376
- [
377
- .../** @type {ReferencedHashes} */ (asset.referencedHashes)
378
- ].some((hash) => hashToNewHash.get(hash) !== hash)
382
+ /** @type {Hashes} */ (asset.ownHashes).size > 0 ||
383
+ [.../** @type {Hashes} */ (asset.referencedHashes)].some(
384
+ (hash) => hashToNewHash.get(hash) !== hash
385
+ )
379
386
  ) {
380
387
  const identifier = `${asset.name}|without-own`;
381
388
  const etag = getEtag(asset);
@@ -387,7 +394,7 @@ ${referencingAssets
387
394
  hashRegExp,
388
395
  (hash) => {
389
396
  if (
390
- /** @type {OwnHashes} */
397
+ /** @type {Hashes} */
391
398
  (asset.ownHashes).has(hash)
392
399
  ) {
393
400
  return "";
@@ -401,6 +408,7 @@ ${referencingAssets
401
408
  }
402
409
  })());
403
410
  };
411
+ /** @type {Comparator<AssetInfoForRealContentHash>} */
404
412
  const comparator = compareSelect((a) => a.name, compareStrings);
405
413
  for (const oldHash of hashesInOrder) {
406
414
  const assets =
@@ -409,13 +417,13 @@ ${referencingAssets
409
417
  assets.sort(comparator);
410
418
  await Promise.all(
411
419
  assets.map((asset) =>
412
- /** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)
420
+ /** @type {Hashes} */ (asset.ownHashes).has(oldHash)
413
421
  ? computeNewContentWithoutOwn(asset)
414
422
  : computeNewContent(asset)
415
423
  )
416
424
  );
417
425
  const assetsContent = mapAndDeduplicateBuffers(assets, (asset) => {
418
- if (/** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)) {
426
+ if (/** @type {Hashes} */ (asset.ownHashes).has(oldHash)) {
419
427
  return asset.newSourceWithoutOwn
420
428
  ? asset.newSourceWithoutOwn.buffer()
421
429
  : asset.source.buffer();
@@ -447,7 +455,9 @@ ${referencingAssets
447
455
  );
448
456
 
449
457
  const infoUpdate = {};
450
- const hash = /** @type {string} */ (asset.info.contenthash);
458
+ const hash =
459
+ /** @type {Exclude<AssetInfo["contenthash"], undefined>} */
460
+ (asset.info.contenthash);
451
461
  infoUpdate.contenthash = Array.isArray(hash)
452
462
  ? hash.map(
453
463
  (hash) => /** @type {string} */ (hashToNewHash.get(hash))