webpack 5.90.3 → 5.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (257) hide show
  1. package/README.md +5 -5
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +14 -6
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/BannerPlugin.js +3 -1
  6. package/lib/Cache.js +8 -2
  7. package/lib/CacheFacade.js +3 -3
  8. package/lib/Chunk.js +7 -4
  9. package/lib/ChunkGraph.js +52 -25
  10. package/lib/ChunkGroup.js +23 -17
  11. package/lib/CleanPlugin.js +8 -6
  12. package/lib/Compilation.js +295 -120
  13. package/lib/Compiler.js +223 -87
  14. package/lib/ConcatenationScope.js +3 -3
  15. package/lib/ConditionalInitFragment.js +4 -5
  16. package/lib/ContextModule.js +95 -41
  17. package/lib/ContextModuleFactory.js +4 -2
  18. package/lib/ContextReplacementPlugin.js +3 -2
  19. package/lib/DefinePlugin.js +18 -6
  20. package/lib/Dependency.js +12 -10
  21. package/lib/DependencyTemplate.js +17 -7
  22. package/lib/DllModule.js +1 -0
  23. package/lib/DllReferencePlugin.js +7 -3
  24. package/lib/EntryOptionPlugin.js +4 -1
  25. package/lib/EntryPlugin.js +6 -1
  26. package/lib/Entrypoint.js +1 -1
  27. package/lib/EvalDevToolModulePlugin.js +11 -0
  28. package/lib/ExportsInfo.js +23 -8
  29. package/lib/ExternalModule.js +160 -35
  30. package/lib/ExternalModuleFactoryPlugin.js +37 -2
  31. package/lib/FileSystemInfo.js +69 -42
  32. package/lib/FlagDependencyExportsPlugin.js +21 -7
  33. package/lib/Generator.js +4 -4
  34. package/lib/HookWebpackError.js +2 -2
  35. package/lib/HotModuleReplacementPlugin.js +108 -45
  36. package/lib/IgnorePlugin.js +4 -1
  37. package/lib/InitFragment.js +5 -3
  38. package/lib/LibManifestPlugin.js +17 -9
  39. package/lib/Module.js +41 -14
  40. package/lib/ModuleFactory.js +3 -3
  41. package/lib/ModuleFilenameHelpers.js +30 -17
  42. package/lib/ModuleGraph.js +60 -31
  43. package/lib/ModuleGraphConnection.js +2 -1
  44. package/lib/MultiCompiler.js +62 -9
  45. package/lib/NodeStuffPlugin.js +14 -3
  46. package/lib/NormalModule.js +13 -13
  47. package/lib/NormalModuleFactory.js +18 -9
  48. package/lib/NormalModuleReplacementPlugin.js +5 -1
  49. package/lib/Parser.js +1 -1
  50. package/lib/PlatformPlugin.js +39 -0
  51. package/lib/ProgressPlugin.js +1 -1
  52. package/lib/ProvidePlugin.js +3 -1
  53. package/lib/RawModule.js +2 -1
  54. package/lib/RecordIdsPlugin.js +4 -4
  55. package/lib/ResolverFactory.js +6 -4
  56. package/lib/RuntimeModule.js +4 -4
  57. package/lib/RuntimePlugin.js +1 -0
  58. package/lib/RuntimeTemplate.js +124 -52
  59. package/lib/SourceMapDevToolPlugin.js +4 -1
  60. package/lib/Stats.js +11 -4
  61. package/lib/Template.js +5 -5
  62. package/lib/TemplatedPathPlugin.js +48 -7
  63. package/lib/Watching.js +67 -60
  64. package/lib/WebpackError.js +6 -6
  65. package/lib/WebpackOptionsApply.js +18 -5
  66. package/lib/asset/AssetGenerator.js +15 -0
  67. package/lib/asset/RawDataUrlModule.js +3 -1
  68. package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
  69. package/lib/buildChunkGraph.js +120 -67
  70. package/lib/cache/IdleFileCachePlugin.js +8 -3
  71. package/lib/cache/MemoryCachePlugin.js +1 -1
  72. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  73. package/lib/cache/PackFileCacheStrategy.js +51 -18
  74. package/lib/cache/ResolverCachePlugin.js +22 -14
  75. package/lib/cache/getLazyHashedEtag.js +2 -2
  76. package/lib/cli.js +5 -5
  77. package/lib/config/browserslistTargetHandler.js +7 -1
  78. package/lib/config/defaults.js +108 -34
  79. package/lib/config/normalization.js +3 -1
  80. package/lib/config/target.js +18 -11
  81. package/lib/container/ContainerEntryDependency.js +2 -1
  82. package/lib/container/ContainerEntryModule.js +4 -2
  83. package/lib/container/ContainerPlugin.js +14 -10
  84. package/lib/container/FallbackModule.js +1 -1
  85. package/lib/container/RemoteRuntimeModule.js +12 -3
  86. package/lib/css/CssExportsGenerator.js +68 -25
  87. package/lib/css/CssGenerator.js +34 -6
  88. package/lib/css/CssLoadingRuntimeModule.js +217 -98
  89. package/lib/css/CssModulesPlugin.js +238 -107
  90. package/lib/css/CssParser.js +24 -15
  91. package/lib/css/walkCssTokens.js +1 -1
  92. package/lib/debug/ProfilingPlugin.js +28 -3
  93. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
  94. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
  95. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
  96. package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
  97. package/lib/dependencies/CommonJsExportsDependency.js +13 -5
  98. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
  99. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
  100. package/lib/dependencies/ContextDependencyHelpers.js +49 -29
  101. package/lib/dependencies/ContextElementDependency.js +8 -1
  102. package/lib/dependencies/CssExportDependency.js +2 -2
  103. package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
  104. package/lib/dependencies/CssUrlDependency.js +10 -7
  105. package/lib/dependencies/ExportsInfoDependency.js +5 -4
  106. package/lib/dependencies/ExternalModuleDependency.js +4 -2
  107. package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
  108. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
  109. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
  110. package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
  111. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
  112. package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
  113. package/lib/dependencies/HarmonyImportDependency.js +28 -12
  114. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
  115. package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
  116. package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
  117. package/lib/dependencies/ImportDependency.js +9 -2
  118. package/lib/dependencies/ImportEagerDependency.js +4 -2
  119. package/lib/dependencies/ImportMetaContextDependency.js +7 -0
  120. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
  121. package/lib/dependencies/ImportMetaPlugin.js +1 -1
  122. package/lib/dependencies/ImportParserPlugin.js +15 -5
  123. package/lib/dependencies/ImportWeakDependency.js +4 -2
  124. package/lib/dependencies/LoaderDependency.js +2 -1
  125. package/lib/dependencies/LoaderImportDependency.js +2 -1
  126. package/lib/dependencies/LoaderPlugin.js +2 -2
  127. package/lib/dependencies/ModuleDependency.js +4 -5
  128. package/lib/dependencies/PureExpressionDependency.js +64 -47
  129. package/lib/dependencies/RequireContextPlugin.js +1 -1
  130. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
  131. package/lib/dependencies/RequireEnsureDependency.js +1 -1
  132. package/lib/dependencies/URLDependency.js +7 -4
  133. package/lib/dependencies/WorkerDependency.js +1 -1
  134. package/lib/dependencies/WorkerPlugin.js +2 -1
  135. package/lib/dependencies/getFunctionExpression.js +3 -1
  136. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
  137. package/lib/hmr/LazyCompilationPlugin.js +2 -2
  138. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
  139. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
  140. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  141. package/lib/ids/IdHelpers.js +6 -6
  142. package/lib/ids/NamedChunkIdsPlugin.js +1 -1
  143. package/lib/ids/NamedModuleIdsPlugin.js +1 -1
  144. package/lib/ids/SyncModuleIdsPlugin.js +2 -2
  145. package/lib/index.js +11 -0
  146. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  147. package/lib/javascript/ChunkHelpers.js +2 -2
  148. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  149. package/lib/javascript/JavascriptGenerator.js +0 -1
  150. package/lib/javascript/JavascriptModulesPlugin.js +174 -17
  151. package/lib/javascript/JavascriptParser.js +204 -71
  152. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  153. package/lib/javascript/StartupHelpers.js +22 -5
  154. package/lib/library/AbstractLibraryPlugin.js +2 -2
  155. package/lib/library/AmdLibraryPlugin.js +2 -2
  156. package/lib/library/AssignLibraryPlugin.js +3 -3
  157. package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
  158. package/lib/library/JsonpLibraryPlugin.js +2 -2
  159. package/lib/library/ModuleLibraryPlugin.js +2 -2
  160. package/lib/library/SystemLibraryPlugin.js +2 -2
  161. package/lib/library/UmdLibraryPlugin.js +33 -12
  162. package/lib/logging/Logger.js +27 -2
  163. package/lib/logging/createConsoleLogger.js +13 -9
  164. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  165. package/lib/node/NodeEnvironmentPlugin.js +14 -8
  166. package/lib/node/NodeTemplatePlugin.js +1 -1
  167. package/lib/node/NodeWatchFileSystem.js +37 -26
  168. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
  169. package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
  170. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
  171. package/lib/node/nodeConsole.js +24 -1
  172. package/lib/optimize/AggressiveMergingPlugin.js +1 -1
  173. package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
  174. package/lib/optimize/ConcatenatedModule.js +140 -121
  175. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  176. package/lib/optimize/InnerGraph.js +8 -3
  177. package/lib/optimize/InnerGraphPlugin.js +36 -13
  178. package/lib/optimize/LimitChunkCountPlugin.js +1 -2
  179. package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
  180. package/lib/optimize/RealContentHashPlugin.js +3 -3
  181. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  182. package/lib/optimize/RuntimeChunkPlugin.js +6 -1
  183. package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
  184. package/lib/optimize/SplitChunksPlugin.js +10 -10
  185. package/lib/performance/SizeLimitsPlugin.js +13 -2
  186. package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
  187. package/lib/rules/RuleSetCompiler.js +9 -7
  188. package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
  189. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
  190. package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
  191. package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
  192. package/lib/schemes/HttpUriPlugin.js +1 -1
  193. package/lib/serialization/BinaryMiddleware.js +4 -4
  194. package/lib/serialization/FileMiddleware.js +4 -3
  195. package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
  196. package/lib/serialization/ObjectMiddleware.js +8 -5
  197. package/lib/serialization/PlainObjectSerializer.js +2 -2
  198. package/lib/serialization/Serializer.js +19 -0
  199. package/lib/serialization/SerializerMiddleware.js +2 -2
  200. package/lib/serialization/SingleItemMiddleware.js +2 -2
  201. package/lib/serialization/types.js +1 -1
  202. package/lib/sharing/ConsumeSharedModule.js +2 -2
  203. package/lib/sharing/ConsumeSharedPlugin.js +17 -3
  204. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
  205. package/lib/sharing/ProvideSharedPlugin.js +13 -6
  206. package/lib/sharing/resolveMatchedConfigs.js +3 -3
  207. package/lib/sharing/utils.js +13 -6
  208. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
  209. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  210. package/lib/stats/StatsFactory.js +2 -2
  211. package/lib/stats/StatsPrinter.js +6 -6
  212. package/lib/util/ArrayQueue.js +14 -21
  213. package/lib/util/AsyncQueue.js +1 -1
  214. package/lib/util/Queue.js +8 -2
  215. package/lib/util/SortableSet.js +16 -4
  216. package/lib/util/StackedCacheMap.js +26 -0
  217. package/lib/util/TupleQueue.js +8 -2
  218. package/lib/util/WeakTupleMap.js +57 -13
  219. package/lib/util/binarySearchBounds.js +1 -1
  220. package/lib/util/cleverMerge.js +26 -13
  221. package/lib/util/comparators.js +37 -15
  222. package/lib/util/conventions.js +129 -0
  223. package/lib/util/createHash.js +3 -5
  224. package/lib/util/deprecation.js +3 -3
  225. package/lib/util/deterministicGrouping.js +2 -2
  226. package/lib/util/findGraphRoots.js +1 -1
  227. package/lib/util/fs.js +383 -69
  228. package/lib/util/hash/BatchedHash.js +3 -0
  229. package/lib/util/hash/xxhash64.js +2 -2
  230. package/lib/util/identifier.js +5 -5
  231. package/lib/util/mergeScope.js +79 -0
  232. package/lib/util/runtime.js +2 -17
  233. package/lib/util/semver.js +3 -0
  234. package/lib/util/smartGrouping.js +3 -3
  235. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
  236. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
  237. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
  238. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  239. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
  240. package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
  241. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
  242. package/lib/wasm-sync/WebAssemblyParser.js +7 -4
  243. package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
  244. package/lib/web/FetchCompileWasmPlugin.js +1 -1
  245. package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
  246. package/lib/webpack.js +19 -6
  247. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
  248. package/package.json +40 -39
  249. package/schemas/WebpackOptions.check.js +1 -1
  250. package/schemas/WebpackOptions.json +97 -8
  251. package/schemas/plugins/BannerPlugin.check.js +1 -1
  252. package/schemas/plugins/BannerPlugin.json +5 -1
  253. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  254. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  255. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  256. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  257. package/types.d.ts +1826 -639
@@ -88,6 +88,7 @@ const { isSourceEqual } = require("./util/source");
88
88
  /** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */
89
89
  /** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */
90
90
  /** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
91
+ /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
91
92
  /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
92
93
  /** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
93
94
  /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
@@ -101,8 +102,11 @@ const { isSourceEqual } = require("./util/source");
101
102
  /** @typedef {import("./Dependency").ReferencedExport} ReferencedExport */
102
103
  /** @typedef {import("./DependencyTemplate")} DependencyTemplate */
103
104
  /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
105
+ /** @typedef {import("./Module").BuildInfo} BuildInfo */
106
+ /** @typedef {import("./NormalModule").NormalModuleCompilationHooks} NormalModuleCompilationHooks */
104
107
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
105
108
  /** @typedef {import("./ModuleFactory")} ModuleFactory */
109
+ /** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
106
110
  /** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
107
111
  /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
108
112
  /** @typedef {import("./RequestShortener")} RequestShortener */
@@ -113,9 +117,13 @@ const { isSourceEqual } = require("./util/source");
113
117
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsError} StatsError */
114
118
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
115
119
  /** @typedef {import("./util/Hash")} Hash */
116
- /** @template T @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T> */
120
+ /**
121
+ * @template T
122
+ * @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
123
+ */
117
124
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
118
-
125
+ /** @typedef {WeakMap<Dependency, Module>} References */
126
+ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
119
127
  /**
120
128
  * @callback Callback
121
129
  * @param {(WebpackError | null)=} err
@@ -160,20 +168,20 @@ const { isSourceEqual } = require("./util/source");
160
168
  /** @typedef {Record<string, Source>} CompilationAssets */
161
169
 
162
170
  /**
163
- * @typedef {Object} AvailableModulesChunkGroupMapping
171
+ * @typedef {object} AvailableModulesChunkGroupMapping
164
172
  * @property {ChunkGroup} chunkGroup
165
173
  * @property {Set<Module>} availableModules
166
174
  * @property {boolean} needCopy
167
175
  */
168
176
 
169
177
  /**
170
- * @typedef {Object} DependenciesBlockLike
178
+ * @typedef {object} DependenciesBlockLike
171
179
  * @property {Dependency[]} dependencies
172
180
  * @property {AsyncDependenciesBlock[]} blocks
173
181
  */
174
182
 
175
183
  /**
176
- * @typedef {Object} ChunkPathData
184
+ * @typedef {object} ChunkPathData
177
185
  * @property {string|number} id
178
186
  * @property {string=} name
179
187
  * @property {string} hash
@@ -183,7 +191,7 @@ const { isSourceEqual } = require("./util/source");
183
191
  */
184
192
 
185
193
  /**
186
- * @typedef {Object} ChunkHashContext
194
+ * @typedef {object} ChunkHashContext
187
195
  * @property {CodeGenerationResults} codeGenerationResults results of code generation
188
196
  * @property {RuntimeTemplate} runtimeTemplate the runtime template
189
197
  * @property {ModuleGraph} moduleGraph the module graph
@@ -191,18 +199,18 @@ const { isSourceEqual } = require("./util/source");
191
199
  */
192
200
 
193
201
  /**
194
- * @typedef {Object} RuntimeRequirementsContext
202
+ * @typedef {object} RuntimeRequirementsContext
195
203
  * @property {ChunkGraph} chunkGraph the chunk graph
196
204
  * @property {CodeGenerationResults} codeGenerationResults the code generation results
197
205
  */
198
206
 
199
207
  /**
200
- * @typedef {Object} ExecuteModuleOptions
208
+ * @typedef {object} ExecuteModuleOptions
201
209
  * @property {EntryOptions=} entryOptions
202
210
  */
203
211
 
204
212
  /**
205
- * @typedef {Object} ExecuteModuleResult
213
+ * @typedef {object} ExecuteModuleResult
206
214
  * @property {any} exports
207
215
  * @property {boolean} cacheable
208
216
  * @property {Map<string, { source: Source, info: AssetInfo }>} assets
@@ -213,7 +221,7 @@ const { isSourceEqual } = require("./util/source");
213
221
  */
214
222
 
215
223
  /**
216
- * @typedef {Object} ExecuteModuleArgument
224
+ * @typedef {object} ExecuteModuleArgument
217
225
  * @property {Module} module
218
226
  * @property {{ id: string, exports: any, loaded: boolean }=} moduleObject
219
227
  * @property {any} preparedInfo
@@ -221,7 +229,7 @@ const { isSourceEqual } = require("./util/source");
221
229
  */
222
230
 
223
231
  /**
224
- * @typedef {Object} ExecuteModuleContext
232
+ * @typedef {object} ExecuteModuleContext
225
233
  * @property {Map<string, { source: Source, info: AssetInfo }>} assets
226
234
  * @property {Chunk} chunk
227
235
  * @property {ChunkGraph} chunkGraph
@@ -229,14 +237,14 @@ const { isSourceEqual } = require("./util/source");
229
237
  */
230
238
 
231
239
  /**
232
- * @typedef {Object} EntryData
240
+ * @typedef {object} EntryData
233
241
  * @property {Dependency[]} dependencies dependencies of the entrypoint that should be evaluated at startup
234
242
  * @property {Dependency[]} includeDependencies dependencies of the entrypoint that should be included but not evaluated
235
243
  * @property {EntryOptions} options options of the entrypoint
236
244
  */
237
245
 
238
246
  /**
239
- * @typedef {Object} LogEntry
247
+ * @typedef {object} LogEntry
240
248
  * @property {string} type
241
249
  * @property {any[]} args
242
250
  * @property {number} time
@@ -244,7 +252,7 @@ const { isSourceEqual } = require("./util/source");
244
252
  */
245
253
 
246
254
  /**
247
- * @typedef {Object} KnownAssetInfo
255
+ * @typedef {object} KnownAssetInfo
248
256
  * @property {boolean=} immutable true, if the asset can be long term cached forever (contains a hash)
249
257
  * @property {boolean=} minimized whether the asset is minimized
250
258
  * @property {string | string[]=} fullhash the value(s) of the full hash used for this asset
@@ -262,21 +270,21 @@ const { isSourceEqual } = require("./util/source");
262
270
  /** @typedef {KnownAssetInfo & Record<string, any>} AssetInfo */
263
271
 
264
272
  /**
265
- * @typedef {Object} Asset
273
+ * @typedef {object} Asset
266
274
  * @property {string} name the filename of the asset
267
275
  * @property {Source} source source of the asset
268
276
  * @property {AssetInfo} info info about the asset
269
277
  */
270
278
 
271
279
  /**
272
- * @typedef {Object} ModulePathData
280
+ * @typedef {object} ModulePathData
273
281
  * @property {string|number} id
274
282
  * @property {string} hash
275
283
  * @property {function(number): string=} hashWithLength
276
284
  */
277
285
 
278
286
  /**
279
- * @typedef {Object} PathData
287
+ * @typedef {object} PathData
280
288
  * @property {ChunkGraph=} chunkGraph
281
289
  * @property {string=} hash
282
290
  * @property {function(number): string=} hashWithLength
@@ -294,7 +302,7 @@ const { isSourceEqual } = require("./util/source");
294
302
  */
295
303
 
296
304
  /**
297
- * @typedef {Object} KnownNormalizedStatsOptions
305
+ * @typedef {object} KnownNormalizedStatsOptions
298
306
  * @property {string} context
299
307
  * @property {RequestShortener} requestShortener
300
308
  * @property {string} chunksSort
@@ -338,18 +346,29 @@ const { isSourceEqual } = require("./util/source");
338
346
  /** @typedef {KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, any>} NormalizedStatsOptions */
339
347
 
340
348
  /**
341
- * @typedef {Object} KnownCreateStatsOptionsContext
349
+ * @typedef {object} KnownCreateStatsOptionsContext
342
350
  * @property {boolean=} forToString
343
351
  */
344
352
 
345
353
  /** @typedef {KnownCreateStatsOptionsContext & Record<string, any>} CreateStatsOptionsContext */
346
354
 
355
+ /** @typedef {{module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}[]} CodeGenerationJobs */
356
+
357
+ /** @typedef {{javascript: ModuleTemplate}} ModuleTemplates */
358
+
359
+ /** @typedef {Set<Module>} NotCodeGeneratedModules */
360
+
347
361
  /** @type {AssetInfo} */
348
362
  const EMPTY_ASSET_INFO = Object.freeze({});
349
363
 
350
364
  const esmDependencyCategory = "esm";
365
+
351
366
  // TODO webpack 6: remove
352
367
  const deprecatedNormalModuleLoaderHook = util.deprecate(
368
+ /**
369
+ * @param {Compilation} compilation compilation
370
+ * @returns {NormalModuleCompilationHooks["loader"]} hooks
371
+ */
353
372
  compilation => {
354
373
  return require("./NormalModule").getCompilationHooks(compilation).loader;
355
374
  },
@@ -358,6 +377,9 @@ const deprecatedNormalModuleLoaderHook = util.deprecate(
358
377
  );
359
378
 
360
379
  // TODO webpack 6: remove
380
+ /**
381
+ * @param {ModuleTemplates | undefined} moduleTemplates module templates
382
+ */
361
383
  const defineRemovedModuleTemplates = moduleTemplates => {
362
384
  Object.defineProperties(moduleTemplates, {
363
385
  asset: {
@@ -382,30 +404,11 @@ const defineRemovedModuleTemplates = moduleTemplates => {
382
404
  moduleTemplates = undefined;
383
405
  };
384
406
 
385
- const byId = compareSelect(
386
- /**
387
- * @param {Chunk} c chunk
388
- * @returns {number | string} id
389
- */ c => c.id,
390
- compareIds
391
- );
407
+ const byId = compareSelect(c => c.id, compareIds);
392
408
 
393
409
  const byNameOrHash = concatComparators(
394
- compareSelect(
395
- /**
396
- * @param {Compilation} c compilation
397
- * @returns {string} name
398
- */
399
- c => c.name,
400
- compareIds
401
- ),
402
- compareSelect(
403
- /**
404
- * @param {Compilation} c compilation
405
- * @returns {string} hash
406
- */ c => c.fullHash,
407
- compareIds
408
- )
410
+ compareSelect(c => c.name, compareIds),
411
+ compareSelect(c => c.fullHash, compareIds)
409
412
  );
410
413
 
411
414
  const byMessage = compareSelect(err => `${err.message}`, compareStringsNumeric);
@@ -440,6 +443,10 @@ class Compilation {
440
443
  const processAssetsHook = new AsyncSeriesHook(["assets"]);
441
444
 
442
445
  let savedAssets = new Set();
446
+ /**
447
+ * @param {CompilationAssets} assets assets
448
+ * @returns {CompilationAssets} new assets
449
+ */
443
450
  const popNewAssets = assets => {
444
451
  let newAssets = undefined;
445
452
  for (const file of Object.keys(assets)) {
@@ -667,7 +674,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
667
674
  /** @type {SyncHook<[Iterable<Module>]>} */
668
675
  afterOptimizeModules: new SyncHook(["modules"]),
669
676
 
670
- /** @type {SyncBailHook<[Iterable<Chunk>, ChunkGroup[]]>} */
677
+ /** @type {SyncBailHook<[Iterable<Chunk>, ChunkGroup[]], boolean | void>} */
671
678
  optimizeChunks: new SyncBailHook(["chunks", "chunkGroups"]),
672
679
  /** @type {SyncHook<[Iterable<Chunk>, ChunkGroup[]]>} */
673
680
  afterOptimizeChunks: new SyncHook(["chunks", "chunkGroups"]),
@@ -677,7 +684,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
677
684
  /** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */
678
685
  afterOptimizeTree: new SyncHook(["chunks", "modules"]),
679
686
 
680
- /** @type {AsyncSeriesBailHook<[Iterable<Chunk>, Iterable<Module>]>} */
687
+ /** @type {AsyncSeriesBailHook<[Iterable<Chunk>, Iterable<Module>], void>} */
681
688
  optimizeChunkModules: new AsyncSeriesBailHook(["chunks", "modules"]),
682
689
  /** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */
683
690
  afterOptimizeChunkModules: new SyncHook(["chunks", "modules"]),
@@ -690,7 +697,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
690
697
  "runtimeRequirements",
691
698
  "context"
692
699
  ]),
693
- /** @type {HookMap<SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext]>>} */
700
+ /** @type {HookMap<SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext], void>>} */
694
701
  runtimeRequirementInChunk: new HookMap(
695
702
  () => new SyncBailHook(["chunk", "runtimeRequirements", "context"])
696
703
  ),
@@ -824,7 +831,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
824
831
  /** @type {AsyncSeriesHook<[CompilationAssets]>} */
825
832
  processAdditionalAssets: new AsyncSeriesHook(["assets"]),
826
833
 
827
- /** @type {SyncBailHook<[], boolean>} */
834
+ /** @type {SyncBailHook<[], boolean | undefined>} */
828
835
  needAdditionalSeal: new SyncBailHook([]),
829
836
  /** @type {AsyncSeriesHook<[]>} */
830
837
  afterSeal: new AsyncSeriesHook([]),
@@ -842,7 +849,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
842
849
  /** @type {SyncHook<[Chunk, string]>} */
843
850
  chunkAsset: new SyncHook(["chunk", "filename"]),
844
851
 
845
- /** @type {SyncWaterfallHook<[string, object, AssetInfo]>} */
852
+ /** @type {SyncWaterfallHook<[string, object, AssetInfo | undefined]>} */
846
853
  assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]),
847
854
 
848
855
  /** @type {SyncBailHook<[], boolean>} */
@@ -878,12 +885,17 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
878
885
  });
879
886
  /** @type {string=} */
880
887
  this.name = undefined;
888
+ /** @type {number | undefined} */
881
889
  this.startTime = undefined;
890
+ /** @type {number | undefined} */
882
891
  this.endTime = undefined;
883
892
  /** @type {Compiler} */
884
893
  this.compiler = compiler;
885
894
  this.resolverFactory = compiler.resolverFactory;
886
- this.inputFileSystem = compiler.inputFileSystem;
895
+ /** @type {InputFileSystem} */
896
+ this.inputFileSystem =
897
+ /** @type {InputFileSystem} */
898
+ (compiler.inputFileSystem);
887
899
  this.fileSystemInfo = new FileSystemInfo(this.inputFileSystem, {
888
900
  unmanagedPaths: compiler.unmanagedPaths,
889
901
  managedPaths: compiler.managedPaths,
@@ -907,7 +919,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
907
919
 
908
920
  this.logger = this.getLogger("webpack.Compilation");
909
921
 
910
- const options = compiler.options;
922
+ const options = /** @type {WebpackOptions} */ (compiler.options);
911
923
  this.options = options;
912
924
  this.outputOptions = options && options.output;
913
925
  /** @type {boolean} */
@@ -923,7 +935,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
923
935
  this.outputOptions,
924
936
  this.requestShortener
925
937
  );
926
- /** @type {{javascript: ModuleTemplate}} */
938
+ /** @type {ModuleTemplates} */
927
939
  this.moduleTemplates = {
928
940
  javascript: new ModuleTemplate(this.runtimeTemplate, this)
929
941
  };
@@ -1007,7 +1019,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1007
1019
  arrayToSetDeprecation(this.chunks, "Compilation.chunks");
1008
1020
  arrayToSetDeprecation(this.modules, "Compilation.modules");
1009
1021
  }
1010
- /** @private @type {Map<string, Module>} */
1022
+ /**
1023
+ * @private
1024
+ * @type {Map<string, Module>}
1025
+ */
1011
1026
  this._modules = new Map();
1012
1027
  this.records = null;
1013
1028
  /** @type {string[]} */
@@ -1049,7 +1064,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1049
1064
  this.codeGeneratedModules = new WeakSet();
1050
1065
  /** @type {WeakSet<Module>} */
1051
1066
  this.buildTimeExecutedModules = new WeakSet();
1052
- /** @private @type {Map<Module, Callback[]>} */
1067
+ /**
1068
+ * @private
1069
+ * @type {Map<Module, Callback[]>}
1070
+ */
1053
1071
  this._rebuildingModules = new Map();
1054
1072
  /** @type {Set<string>} */
1055
1073
  this.emittedAssets = new Set();
@@ -1066,6 +1084,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1066
1084
  // TODO webpack 6 remove
1067
1085
  this.compilationDependencies = {
1068
1086
  add: util.deprecate(
1087
+ /**
1088
+ * @param {string} item item
1089
+ * @returns {LazySet<string>} file dependencies
1090
+ */
1069
1091
  item => this.fileDependencies.add(item),
1070
1092
  "Compilation.compilationDependencies is deprecated (used Compilation.fileDependencies instead)",
1071
1093
  "DEP_WEBPACK_COMPILATION_COMPILATION_DEPENDENCIES"
@@ -1119,12 +1141,20 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1119
1141
  }
1120
1142
  }
1121
1143
 
1144
+ /**
1145
+ * @param {NormalizedStatsOptions} options options
1146
+ * @returns {StatsFactory} the stats factory
1147
+ */
1122
1148
  createStatsFactory(options) {
1123
1149
  const statsFactory = new StatsFactory();
1124
1150
  this.hooks.statsFactory.call(statsFactory, options);
1125
1151
  return statsFactory;
1126
1152
  }
1127
1153
 
1154
+ /**
1155
+ * @param {NormalizedStatsOptions} options options
1156
+ * @returns {StatsPrinter} the stats printer
1157
+ */
1128
1158
  createStatsPrinter(options) {
1129
1159
  const statsPrinter = new StatsPrinter();
1130
1160
  this.hooks.statsPrinter.call(statsPrinter, options);
@@ -1164,7 +1194,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1164
1194
  case LogType.warn:
1165
1195
  case LogType.error:
1166
1196
  case LogType.trace:
1167
- trace = ErrorHelpers.cutOffLoaderExecution(new Error("Trace").stack)
1197
+ trace = ErrorHelpers.cutOffLoaderExecution(
1198
+ /** @type {string} */ (new Error("Trace").stack)
1199
+ )
1168
1200
  .split("\n")
1169
1201
  .slice(3);
1170
1202
  break;
@@ -1314,7 +1346,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1314
1346
  */
1315
1347
  getModule(module) {
1316
1348
  const identifier = module.identifier();
1317
- return this._modules.get(identifier);
1349
+ return /** @type {Module} */ (this._modules.get(identifier));
1318
1350
  }
1319
1351
 
1320
1352
  /**
@@ -1375,7 +1407,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1375
1407
  this.options,
1376
1408
  this,
1377
1409
  this.resolverFactory.get("normal", module.resolveOptions),
1378
- this.inputFileSystem,
1410
+ /** @type {InputFileSystem} */ (this.inputFileSystem),
1379
1411
  err => {
1380
1412
  if (currentProfile !== undefined) {
1381
1413
  currentProfile.markBuildingEnd();
@@ -1392,7 +1424,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1392
1424
  currentProfile.markStoringEnd();
1393
1425
  }
1394
1426
  if (err) {
1395
- this.hooks.failedModule.call(module, err);
1427
+ this.hooks.failedModule.call(
1428
+ module,
1429
+ /** @type {WebpackError} */ (err)
1430
+ );
1396
1431
  return callback(new ModuleStoreError(module, err));
1397
1432
  }
1398
1433
  this.hooks.succeedModule.call(module);
@@ -1418,6 +1453,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1418
1453
  * @returns {void}
1419
1454
  */
1420
1455
  processModuleDependenciesNonRecursive(module) {
1456
+ /**
1457
+ * @param {DependenciesBlock} block block
1458
+ */
1421
1459
  const processDependenciesBlock = block => {
1422
1460
  if (block.dependencies) {
1423
1461
  let i = 0;
@@ -1463,6 +1501,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1463
1501
  let inProgressSorting = 1;
1464
1502
  let inProgressTransitive = 1;
1465
1503
 
1504
+ /**
1505
+ * @param {WebpackError=} err error
1506
+ * @returns {void}
1507
+ */
1466
1508
  const onDependenciesSorted = err => {
1467
1509
  if (err) return callback(err);
1468
1510
 
@@ -1494,6 +1536,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1494
1536
  if (--inProgressTransitive === 0) onTransitiveTasksFinished();
1495
1537
  };
1496
1538
 
1539
+ /**
1540
+ * @param {WebpackError=} err error
1541
+ * @returns {void}
1542
+ */
1497
1543
  const onTransitiveTasksFinished = err => {
1498
1544
  if (err) return callback(err);
1499
1545
  this.processDependenciesQueue.decreaseParallelism();
@@ -1541,7 +1587,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1541
1587
  if (err) {
1542
1588
  if (inProgressSorting <= 0) return;
1543
1589
  inProgressSorting = -1;
1544
- onDependenciesSorted(err);
1590
+ onDependenciesSorted(/** @type {WebpackError} */ (err));
1545
1591
  return;
1546
1592
  }
1547
1593
  try {
@@ -1596,7 +1642,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1596
1642
  } catch (err) {
1597
1643
  if (inProgressSorting <= 0) return;
1598
1644
  inProgressSorting = -1;
1599
- onDependenciesSorted(err);
1645
+ onDependenciesSorted(/** @type {WebpackError} */ (err));
1600
1646
  return;
1601
1647
  }
1602
1648
  if (--inProgressSorting === 0) onDependenciesSorted();
@@ -1686,7 +1732,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1686
1732
  /** @type {DependenciesBlock[]} */
1687
1733
  const queue = [module];
1688
1734
  do {
1689
- const block = queue.pop();
1735
+ const block = /** @type {DependenciesBlock} */ (queue.pop());
1690
1736
  if (block.dependencies) {
1691
1737
  currentBlock = block;
1692
1738
  let i = 0;
@@ -1703,6 +1749,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1703
1749
  if (--inProgressSorting === 0) onDependenciesSorted();
1704
1750
  }
1705
1751
 
1752
+ /**
1753
+ * @private
1754
+ * @param {Module} originModule original module
1755
+ * @param {Dependency} dependency dependency
1756
+ * @param {Module} module cached module
1757
+ * @param {Callback} callback callback
1758
+ */
1706
1759
  _handleNewModuleFromUnsafeCache(originModule, dependency, module, callback) {
1707
1760
  const moduleGraph = this.moduleGraph;
1708
1761
 
@@ -1727,6 +1780,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1727
1780
  );
1728
1781
  }
1729
1782
 
1783
+ /**
1784
+ * @private
1785
+ * @param {Module} originModule original modules
1786
+ * @param {Dependency} dependency dependency
1787
+ * @param {Module} module cached module
1788
+ */
1730
1789
  _handleExistingModuleFromUnsafeCache(originModule, dependency, module) {
1731
1790
  const moduleGraph = this.moduleGraph;
1732
1791
 
@@ -1734,7 +1793,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1734
1793
  }
1735
1794
 
1736
1795
  /**
1737
- * @typedef {Object} HandleModuleCreationOptions
1796
+ * @typedef {object} HandleModuleCreationOptions
1738
1797
  * @property {ModuleFactory} factory
1739
1798
  * @property {Dependency[]} dependencies
1740
1799
  * @property {Module | null} originModule
@@ -1813,27 +1872,30 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1813
1872
  moduleGraph.setProfile(newModule, currentProfile);
1814
1873
  }
1815
1874
 
1816
- this.addModule(newModule, (err, module) => {
1875
+ this.addModule(newModule, (err, _module) => {
1817
1876
  if (err) {
1818
1877
  applyFactoryResultDependencies();
1819
1878
  if (!err.module) {
1820
- err.module = module;
1879
+ err.module = _module;
1821
1880
  }
1822
1881
  this.errors.push(err);
1823
1882
 
1824
1883
  return callback(err);
1825
1884
  }
1826
1885
 
1886
+ const module =
1887
+ /** @type {Module & { restoreFromUnsafeCache?: Function }} */
1888
+ (_module);
1889
+
1827
1890
  if (
1828
1891
  this._unsafeCache &&
1829
1892
  factoryResult.cacheable !== false &&
1830
- /** @type {any} */ (module).restoreFromUnsafeCache &&
1893
+ module.restoreFromUnsafeCache &&
1831
1894
  this._unsafeCachePredicate(module)
1832
1895
  ) {
1833
1896
  const unsafeCacheableModule =
1834
- /** @type {Module & { restoreFromUnsafeCache: Function }} */ (
1835
- module
1836
- );
1897
+ /** @type {Module & { restoreFromUnsafeCache: Function }} */
1898
+ (module);
1837
1899
  for (let i = 0; i < dependencies.length; i++) {
1838
1900
  const dependency = dependencies[i];
1839
1901
  moduleGraph.setResolvedModule(
@@ -1888,6 +1950,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1888
1950
  );
1889
1951
  }
1890
1952
 
1953
+ /**
1954
+ * @private
1955
+ * @param {Module} originModule original module
1956
+ * @param {Module} module module
1957
+ * @param {boolean} recursive true if make it recursive, otherwise false
1958
+ * @param {boolean} checkCycle true if need to check cycle, otherwise false
1959
+ * @param {ModuleCallback} callback callback
1960
+ * @returns {void}
1961
+ */
1891
1962
  _handleModuleBuildAndDependencies(
1892
1963
  originModule,
1893
1964
  module,
@@ -2057,7 +2128,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2057
2128
  }
2058
2129
 
2059
2130
  /**
2060
- * @param {Object} options options
2131
+ * @param {object} options options
2061
2132
  * @param {string} options.context context string path
2062
2133
  * @param {Dependency} options.dependency dependency used to create Module chain
2063
2134
  * @param {Partial<ModuleFactoryCreateDataContextInfo>=} options.contextInfo additional context info for the root module
@@ -2164,7 +2235,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2164
2235
  }
2165
2236
  };
2166
2237
  entryData[target].push(entry);
2167
- this.entries.set(name, entryData);
2238
+ this.entries.set(
2239
+ /** @type {NonNullable<EntryOptions["name"]>} */ (name),
2240
+ entryData
2241
+ );
2168
2242
  } else {
2169
2243
  entryData[target].push(entry);
2170
2244
  for (const key of Object.keys(options)) {
@@ -2204,7 +2278,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2204
2278
  this.hooks.failedEntry.call(entry, options, err);
2205
2279
  return callback(err);
2206
2280
  }
2207
- this.hooks.succeedEntry.call(entry, options, module);
2281
+ this.hooks.succeedEntry.call(
2282
+ entry,
2283
+ options,
2284
+ /** @type {Module} */ (module)
2285
+ );
2208
2286
  return callback(null, module);
2209
2287
  }
2210
2288
  );
@@ -2264,6 +2342,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2264
2342
  });
2265
2343
  }
2266
2344
 
2345
+ /**
2346
+ * @private
2347
+ * @param {Set<Module>} modules modules
2348
+ */
2267
2349
  _computeAffectedModules(modules) {
2268
2350
  const moduleMemCacheCache = this.compiler.moduleMemCaches;
2269
2351
  if (!moduleMemCacheCache) return;
@@ -2280,8 +2362,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2280
2362
  let statReferencesChanged = 0;
2281
2363
  let statWithoutBuild = 0;
2282
2364
 
2365
+ /**
2366
+ * @param {Module} module module
2367
+ * @returns {References | undefined} references
2368
+ */
2283
2369
  const computeReferences = module => {
2284
- /** @type {WeakMap<Dependency, Module>} */
2370
+ /** @type {References | undefined} */
2285
2371
  let references = undefined;
2286
2372
  for (const connection of moduleGraph.getOutgoingConnections(module)) {
2287
2373
  const d = connection.dependency;
@@ -2295,7 +2381,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2295
2381
 
2296
2382
  /**
2297
2383
  * @param {Module} module the module
2298
- * @param {WeakMap<Dependency, Module>} references references
2384
+ * @param {References | undefined} references references
2299
2385
  * @returns {boolean} true, when the references differ
2300
2386
  */
2301
2387
  const compareReferences = (module, references) => {
@@ -2367,6 +2453,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2367
2453
  }
2368
2454
  }
2369
2455
 
2456
+ /**
2457
+ * @param {readonly ModuleGraphConnection[]} connections connections
2458
+ * @returns {symbol|boolean} result
2459
+ */
2370
2460
  const reduceAffectType = connections => {
2371
2461
  let affected = false;
2372
2462
  for (const { dependency } of connections) {
@@ -2442,13 +2532,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2442
2532
  let statNew = 0;
2443
2533
  /**
2444
2534
  * @param {Module} module module
2445
- * @returns {{ id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[] }} references
2535
+ * @returns {{ id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number | null)[] }} references
2446
2536
  */
2447
2537
  const computeReferences = module => {
2448
2538
  const id = chunkGraph.getModuleId(module);
2449
- /** @type {Map<Module, string | number | undefined>} */
2539
+ /** @type {Map<Module, string | number | undefined> | undefined} */
2450
2540
  let modules = undefined;
2451
- /** @type {(string | number)[] | undefined} */
2541
+ /** @type {(string | number | null)[] | undefined} */
2452
2542
  let blocks = undefined;
2453
2543
  const outgoing = moduleGraph.getOutgoingConnectionsByModule(module);
2454
2544
  if (outgoing !== undefined) {
@@ -2477,10 +2567,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2477
2567
  };
2478
2568
  /**
2479
2569
  * @param {Module} module module
2480
- * @param {Object} references references
2570
+ * @param {object} references references
2481
2571
  * @param {string | number} references.id id
2482
- * @param {Map<Module, string | number>=} references.modules modules
2483
- * @param {(string | number)[]=} references.blocks blocks
2572
+ * @param {Map<Module, string | number | undefined>=} references.modules modules
2573
+ * @param {(string | number | null)[]=} references.blocks blocks
2484
2574
  * @returns {boolean} ok?
2485
2575
  */
2486
2576
  const compareReferences = (module, { id, modules, blocks }) => {
@@ -2510,7 +2600,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2510
2600
  };
2511
2601
 
2512
2602
  for (const [module, memCache] of moduleMemCaches) {
2513
- /** @type {{ references: { id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[]}, memCache: WeakTupleMap<any[], any> }} */
2603
+ /** @type {{ references: { id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number | null)[]}, memCache: WeakTupleMap<any[], any> }} */
2514
2604
  const cache = memCache.get(key);
2515
2605
  if (cache === undefined) {
2516
2606
  const memCache2 = new WeakTupleMap();
@@ -2539,6 +2629,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2539
2629
  );
2540
2630
  }
2541
2631
 
2632
+ /**
2633
+ * @param {Callback} callback callback
2634
+ */
2542
2635
  finish(callback) {
2543
2636
  this.factorizeQueue.clear();
2544
2637
  if (this.profile) {
@@ -2546,6 +2639,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2546
2639
  const ParallelismFactorCalculator = require("./util/ParallelismFactorCalculator");
2547
2640
  const p = new ParallelismFactorCalculator();
2548
2641
  const moduleGraph = this.moduleGraph;
2642
+ /** @type {Map<Module, ModuleProfile>} */
2549
2643
  const modulesWithProfiles = new Map();
2550
2644
  for (const module of this.modules) {
2551
2645
  const profile = moduleGraph.getProfile(module);
@@ -2606,6 +2700,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2606
2700
  logger.debug(msg);
2607
2701
  }
2608
2702
  };
2703
+ /**
2704
+ * @param {string} category a category
2705
+ * @param {(profile: ModuleProfile) => number} getDuration get duration callback
2706
+ * @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback
2707
+ */
2609
2708
  const logNormalSummary = (category, getDuration, getParallelism) => {
2610
2709
  let sum = 0;
2611
2710
  let max = 0;
@@ -2630,6 +2729,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2630
2729
  `${Math.round(sum)} ms ${category}`
2631
2730
  );
2632
2731
  };
2732
+ /**
2733
+ * @param {string} category a category
2734
+ * @param {(profile: ModuleProfile) => number} getDuration get duration callback
2735
+ * @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback
2736
+ */
2633
2737
  const logByLoadersSummary = (category, getDuration, getParallelism) => {
2634
2738
  const map = new Map();
2635
2739
  for (const [module, profile] of modulesWithProfiles) {
@@ -2728,7 +2832,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2728
2832
  const { modules, moduleMemCaches } = this;
2729
2833
  this.hooks.finishModules.callAsync(modules, err => {
2730
2834
  this.logger.timeEnd("finish modules");
2731
- if (err) return callback(err);
2835
+ if (err) return callback(/** @type {WebpackError} */ (err));
2732
2836
 
2733
2837
  // extract warnings and errors from modules
2734
2838
  this.moduleGraph.freeze("dependency errors");
@@ -2894,12 +2998,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2894
2998
  Entrypoints that depend on other entrypoints do not have their own runtime.
2895
2999
  They will use the runtime(s) from referenced entrypoints instead.
2896
3000
  Remove the 'runtime' option from the entrypoint.`);
2897
- const entry = this.entrypoints.get(name);
3001
+ const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
2898
3002
  err.chunk = entry.getEntrypointChunk();
2899
3003
  this.errors.push(err);
2900
3004
  }
2901
3005
  if (dependOn) {
2902
- const entry = this.entrypoints.get(name);
3006
+ const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
2903
3007
  const referencedChunks = entry
2904
3008
  .getEntrypointChunk()
2905
3009
  .getAllReferencedChunks();
@@ -2927,7 +3031,7 @@ Remove the 'runtime' option from the entrypoint.`);
2927
3031
  connectChunkGroupParentAndChild(dependency, entry);
2928
3032
  }
2929
3033
  } else if (runtime) {
2930
- const entry = this.entrypoints.get(name);
3034
+ const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
2931
3035
  let chunk = this.namedChunks.get(runtime);
2932
3036
  if (chunk) {
2933
3037
  if (!runtimeChunks.has(chunk)) {
@@ -2938,7 +3042,9 @@ Did you mean to use 'dependOn: ${JSON.stringify(
2938
3042
  runtime
2939
3043
  )}' instead to allow using entrypoint '${name}' within the runtime of entrypoint '${runtime}'? For this '${runtime}' must always be loaded when '${name}' is used.
2940
3044
  Or do you want to use the entrypoints '${name}' and '${runtime}' independently on the same page with a shared runtime? In this case give them both the same value for the 'runtime' option. It must be a name not already used by an entrypoint.`);
2941
- const entryChunk = entry.getEntrypointChunk();
3045
+ const entryChunk =
3046
+ /** @type {Chunk} */
3047
+ (entry.getEntrypointChunk());
2942
3048
  err.chunk = entryChunk;
2943
3049
  this.errors.push(err);
2944
3050
  entry.setRuntimeChunk(entryChunk);
@@ -3077,16 +3183,18 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3077
3183
  }
3078
3184
  this.hooks.afterProcessAssets.call(this.assets);
3079
3185
  this.logger.timeEnd("process assets");
3080
- this.assets = this._backCompat
3081
- ? soonFrozenObjectDeprecation(
3082
- this.assets,
3083
- "Compilation.assets",
3084
- "DEP_WEBPACK_COMPILATION_ASSETS",
3085
- `BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
3186
+ this.assets = /** @type {CompilationAssets} */ (
3187
+ this._backCompat
3188
+ ? soonFrozenObjectDeprecation(
3189
+ this.assets,
3190
+ "Compilation.assets",
3191
+ "DEP_WEBPACK_COMPILATION_ASSETS",
3192
+ `BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
3086
3193
  Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
3087
3194
  Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.`
3088
- )
3089
- : Object.freeze(this.assets);
3195
+ )
3196
+ : Object.freeze(this.assets)
3197
+ );
3090
3198
 
3091
3199
  this.summarizeDependencies();
3092
3200
  if (shouldRecord) {
@@ -3172,12 +3280,15 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3172
3280
  return hasProblems;
3173
3281
  }
3174
3282
 
3283
+ /**
3284
+ * @param {Callback} callback callback
3285
+ */
3175
3286
  codeGeneration(callback) {
3176
3287
  const { chunkGraph } = this;
3177
3288
  this.codeGenerationResults = new CodeGenerationResults(
3178
3289
  this.outputOptions.hashFunction
3179
3290
  );
3180
- /** @type {{module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}[]} */
3291
+ /** @type {CodeGenerationJobs} */
3181
3292
  const jobs = [];
3182
3293
  for (const module of this.modules) {
3183
3294
  const runtimes = chunkGraph.getModuleRuntimes(module);
@@ -3206,6 +3317,12 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3206
3317
  this._runCodeGenerationJobs(jobs, callback);
3207
3318
  }
3208
3319
 
3320
+ /**
3321
+ * @private
3322
+ * @param {CodeGenerationJobs} jobs code generation jobs
3323
+ * @param {Callback} callback callback
3324
+ * @returns {void}
3325
+ */
3209
3326
  _runCodeGenerationJobs(jobs, callback) {
3210
3327
  if (jobs.length === 0) {
3211
3328
  return callback();
@@ -3217,9 +3334,10 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3217
3334
  const results = this.codeGenerationResults;
3218
3335
  /** @type {WebpackError[]} */
3219
3336
  const errors = [];
3220
- /** @type {Set<Module> | undefined} */
3337
+ /** @type {NotCodeGeneratedModules | undefined} */
3221
3338
  let notCodeGeneratedModules = undefined;
3222
3339
  const runIteration = () => {
3340
+ /** @type {CodeGenerationJobs} */
3223
3341
  let delayedJobs = [];
3224
3342
  let delayedModules = new Set();
3225
3343
  asyncLib.eachLimit(
@@ -3232,8 +3350,12 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3232
3350
  if (
3233
3351
  notCodeGeneratedModules === undefined ||
3234
3352
  codeGenerationDependencies.some(dep => {
3235
- const referencedModule = moduleGraph.getModule(dep);
3236
- return notCodeGeneratedModules.has(referencedModule);
3353
+ const referencedModule = /** @type {Module} */ (
3354
+ moduleGraph.getModule(dep)
3355
+ );
3356
+ return /** @type {NotCodeGeneratedModules} */ (
3357
+ notCodeGeneratedModules
3358
+ ).has(referencedModule);
3237
3359
  })
3238
3360
  ) {
3239
3361
  delayedJobs.push(job);
@@ -3265,11 +3387,13 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3265
3387
  if (delayedJobs.length > 0) {
3266
3388
  if (delayedJobs.length === jobs.length) {
3267
3389
  return callback(
3268
- new Error(
3269
- `Unable to make progress during code generation because of circular code generation dependency: ${Array.from(
3270
- delayedModules,
3271
- m => m.identifier()
3272
- ).join(", ")}`
3390
+ /** @type {WebpackError} */ (
3391
+ new Error(
3392
+ `Unable to make progress during code generation because of circular code generation dependency: ${Array.from(
3393
+ delayedModules,
3394
+ m => m.identifier()
3395
+ ).join(", ")}`
3396
+ )
3273
3397
  )
3274
3398
  );
3275
3399
  }
@@ -3336,7 +3460,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3336
3460
  )
3337
3461
  );
3338
3462
  cache.get((err, cachedResult) => {
3339
- if (err) return callback(err);
3463
+ if (err) return callback(/** @type {WebpackError} */ (err));
3340
3464
  let result;
3341
3465
  if (!cachedResult) {
3342
3466
  try {
@@ -3348,12 +3472,13 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3348
3472
  dependencyTemplates,
3349
3473
  runtimeTemplate,
3350
3474
  runtime,
3351
- runtimes,
3352
3475
  codeGenerationResults: results,
3353
3476
  compilation: this
3354
3477
  });
3355
3478
  } catch (err) {
3356
- errors.push(new CodeGenerationError(module, err));
3479
+ errors.push(
3480
+ new CodeGenerationError(module, /** @type {Error} */ (err))
3481
+ );
3357
3482
  result = cachedResult = {
3358
3483
  sources: new Map(),
3359
3484
  runtimeRequirements: null
@@ -3366,7 +3491,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3366
3491
  results.add(module, runtime, result);
3367
3492
  }
3368
3493
  if (!cachedResult) {
3369
- cache.store(result, err => callback(err, codeGenerated));
3494
+ cache.store(result, err =>
3495
+ callback(/** @type {WebpackError} */ (err), codeGenerated)
3496
+ );
3370
3497
  } else {
3371
3498
  callback(null, codeGenerated);
3372
3499
  }
@@ -3388,7 +3515,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3388
3515
  }
3389
3516
 
3390
3517
  /**
3391
- * @param {Object} options options
3518
+ * @param {object} options options
3392
3519
  * @param {ChunkGraph=} options.chunkGraph the chunk graph
3393
3520
  * @param {Iterable<Module>=} options.modules modules
3394
3521
  * @param {Iterable<Chunk>=} options.chunks chunks
@@ -3835,7 +3962,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3835
3962
  const blocks = block.blocks;
3836
3963
  for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
3837
3964
  const asyncBlock = blocks[indexBlock];
3838
- const chunkGroup = this.chunkGraph.getBlockChunkGroup(asyncBlock);
3965
+ const chunkGroup =
3966
+ /** @type {ChunkGroup} */
3967
+ (this.chunkGraph.getBlockChunkGroup(asyncBlock));
3839
3968
  // Grab all chunks from the first Block's AsyncDepBlock
3840
3969
  const chunks = chunkGroup.chunks;
3841
3970
  // For each chunk in chunkGroup
@@ -3906,6 +4035,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3906
4035
  let statModulesFromCache = 0;
3907
4036
  const { chunkGraph, runtimeTemplate, moduleMemCaches2 } = this;
3908
4037
  const { hashFunction, hashDigest, hashDigestLength } = this.outputOptions;
4038
+ /** @type {WebpackError[]} */
3909
4039
  const errors = [];
3910
4040
  for (const module of this.modules) {
3911
4041
  const memCache = moduleMemCaches2 && moduleMemCaches2.get(module);
@@ -3954,6 +4084,18 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3954
4084
  );
3955
4085
  }
3956
4086
 
4087
+ /**
4088
+ * @private
4089
+ * @param {Module} module module
4090
+ * @param {ChunkGraph} chunkGraph the chunk graph
4091
+ * @param {RuntimeSpec} runtime runtime
4092
+ * @param {OutputOptions["hashFunction"]} hashFunction hash function
4093
+ * @param {RuntimeTemplate} runtimeTemplate runtime template
4094
+ * @param {OutputOptions["hashDigest"]} hashDigest hash digest
4095
+ * @param {OutputOptions["hashDigestLength"]} hashDigestLength hash digest length
4096
+ * @param {WebpackError[]} errors errors
4097
+ * @returns {string} module hash digest
4098
+ */
3957
4099
  _createModuleHash(
3958
4100
  module,
3959
4101
  chunkGraph,
@@ -3974,7 +4116,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3974
4116
  });
3975
4117
  moduleHashDigest = /** @type {string} */ (moduleHash.digest(hashDigest));
3976
4118
  } catch (err) {
3977
- errors.push(new ModuleHashingError(module, err));
4119
+ errors.push(new ModuleHashingError(module, /** @type {Error} */ (err)));
3978
4120
  moduleHashDigest = "XXXXXX";
3979
4121
  }
3980
4122
  chunkGraph.setModuleHashes(
@@ -3988,7 +4130,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3988
4130
 
3989
4131
  createHash() {
3990
4132
  this.logger.time("hashing: initialize hash");
3991
- const chunkGraph = this.chunkGraph;
4133
+ const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
3992
4134
  const runtimeTemplate = this.runtimeTemplate;
3993
4135
  const outputOptions = this.outputOptions;
3994
4136
  const hashFunction = outputOptions.hashFunction;
@@ -4083,7 +4225,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4083
4225
  for (const chunk of runtimeChunks) {
4084
4226
  const hasFullHashModules =
4085
4227
  chunkGraph.getNumberOfChunkFullHashModules(chunk) !== 0;
4086
- const info = runtimeChunksMap.get(chunk);
4228
+ const info =
4229
+ /** @type {RuntimeChunkInfo} */
4230
+ (runtimeChunksMap.get(chunk));
4087
4231
  for (const otherInfo of info.referencedBy) {
4088
4232
  if (hasFullHashModules) {
4089
4233
  chunkGraph.upgradeDependentToFullHashModules(otherInfo.chunk);
@@ -4127,8 +4271,12 @@ This prevents using hashes of each other and should be avoided.`);
4127
4271
  const codeGenerationJobs = [];
4128
4272
  /** @type {Map<string, Map<Module, {module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}>>} */
4129
4273
  const codeGenerationJobsMap = new Map();
4274
+ /** @type {WebpackError[]} */
4130
4275
  const errors = [];
4131
4276
 
4277
+ /**
4278
+ * @param {Chunk} chunk chunk
4279
+ */
4132
4280
  const processChunk = chunk => {
4133
4281
  // Last minute module hash generation for modules that depend on chunk hashes
4134
4282
  this.logger.time("hashing: hash runtime modules");
@@ -4217,7 +4365,9 @@ This prevents using hashes of each other and should be avoided.`);
4217
4365
 
4218
4366
  this.logger.time("hashing: process full hash modules");
4219
4367
  for (const chunk of fullHashChunks) {
4220
- for (const module of chunkGraph.getChunkFullHashModulesIterable(chunk)) {
4368
+ for (const module of /** @type {Iterable<RuntimeModule>} */ (
4369
+ chunkGraph.getChunkFullHashModulesIterable(chunk)
4370
+ )) {
4221
4371
  const moduleHash = createHash(hashFunction);
4222
4372
  module.updateHash(moduleHash, {
4223
4373
  chunkGraph,
@@ -4291,6 +4441,9 @@ This prevents using hashes of each other and should be avoided.`);
4291
4441
  const newRelated = newInfo && newInfo.related;
4292
4442
  if (oldRelated) {
4293
4443
  for (const key of Object.keys(oldRelated)) {
4444
+ /**
4445
+ * @param {string} name name
4446
+ */
4294
4447
  const remove = name => {
4295
4448
  const relatedIn = this._assetsRelatedIn.get(name);
4296
4449
  if (relatedIn === undefined) return;
@@ -4311,6 +4464,9 @@ This prevents using hashes of each other and should be avoided.`);
4311
4464
  }
4312
4465
  if (newRelated) {
4313
4466
  for (const key of Object.keys(newRelated)) {
4467
+ /**
4468
+ * @param {string} name name
4469
+ */
4314
4470
  const add = name => {
4315
4471
  let relatedIn = this._assetsRelatedIn.get(name);
4316
4472
  if (relatedIn === undefined) {
@@ -4335,7 +4491,7 @@ This prevents using hashes of each other and should be avoided.`);
4335
4491
  /**
4336
4492
  * @param {string} file file name
4337
4493
  * @param {Source | function(Source): Source} newSourceOrFunction new asset source or function converting old to new
4338
- * @param {AssetInfo | function(AssetInfo | undefined): AssetInfo} assetInfoUpdateOrFunction new asset info or function converting old to new
4494
+ * @param {(AssetInfo | function(AssetInfo | undefined): AssetInfo) | undefined} assetInfoUpdateOrFunction new asset info or function converting old to new
4339
4495
  */
4340
4496
  updateAsset(
4341
4497
  file,
@@ -4366,6 +4522,10 @@ This prevents using hashes of each other and should be avoided.`);
4366
4522
  }
4367
4523
  }
4368
4524
 
4525
+ /**
4526
+ * @param {string} file file name
4527
+ * @param {string} newFile the new name of file
4528
+ */
4369
4529
  renameAsset(file, newFile) {
4370
4530
  const source = this.assets[file];
4371
4531
  if (!source) {
@@ -4504,9 +4664,10 @@ This prevents using hashes of each other and should be avoided.`);
4504
4664
  createModuleAssets() {
4505
4665
  const { chunkGraph } = this;
4506
4666
  for (const module of this.modules) {
4507
- if (module.buildInfo.assets) {
4508
- const assetsInfo = module.buildInfo.assetsInfo;
4509
- for (const assetName of Object.keys(module.buildInfo.assets)) {
4667
+ const buildInfo = /** @type {BuildInfo} */ (module.buildInfo);
4668
+ if (buildInfo.assets) {
4669
+ const assetsInfo = buildInfo.assetsInfo;
4670
+ for (const assetName of Object.keys(buildInfo.assets)) {
4510
4671
  const fileName = this.getPath(assetName, {
4511
4672
  chunkGraph: this.chunkGraph,
4512
4673
  module
@@ -4516,7 +4677,7 @@ This prevents using hashes of each other and should be avoided.`);
4516
4677
  }
4517
4678
  this.emitAsset(
4518
4679
  fileName,
4519
- module.buildInfo.assets[assetName],
4680
+ buildInfo.assets[assetName],
4520
4681
  assetsInfo ? assetsInfo.get(assetName) : undefined
4521
4682
  );
4522
4683
  this.hooks.moduleAsset.call(module, fileName);
@@ -4563,7 +4724,9 @@ This prevents using hashes of each other and should be avoided.`);
4563
4724
  runtimeTemplate: this.runtimeTemplate
4564
4725
  });
4565
4726
  } catch (err) {
4566
- this.errors.push(new ChunkRenderError(chunk, "", err));
4727
+ this.errors.push(
4728
+ new ChunkRenderError(chunk, "", /** @type {Error} */ (err))
4729
+ );
4567
4730
  return callback();
4568
4731
  }
4569
4732
  asyncLib.forEach(
@@ -4586,6 +4749,10 @@ This prevents using hashes of each other and should be avoided.`);
4586
4749
  let assetInfo;
4587
4750
 
4588
4751
  let inTry = true;
4752
+ /**
4753
+ * @param {Error} err error
4754
+ * @returns {void}
4755
+ */
4589
4756
  const errorAndCallback = err => {
4590
4757
  const filename =
4591
4758
  file ||
@@ -4813,7 +4980,7 @@ This prevents using hashes of each other and should be avoided.`);
4813
4980
  });
4814
4981
  },
4815
4982
  err => {
4816
- if (err) return callback(err);
4983
+ if (err) return callback(/** @type {WebpackError} */ (err));
4817
4984
 
4818
4985
  // Create new chunk graph, chunk and entrypoint for the build time execution
4819
4986
  const chunkGraph = new ChunkGraph(
@@ -4996,7 +5163,10 @@ This prevents using hashes of each other and should be avoided.`);
4996
5163
  missingDependencies,
4997
5164
  buildDependencies
4998
5165
  );
4999
- if (module.buildInfo.cacheable === false) {
5166
+ if (
5167
+ /** @type {BuildInfo} */ (module.buildInfo).cacheable ===
5168
+ false
5169
+ ) {
5000
5170
  cacheable = false;
5001
5171
  }
5002
5172
  if (module.buildInfo && module.buildInfo.assets) {
@@ -5098,7 +5268,8 @@ This prevents using hashes of each other and should be avoided.`);
5098
5268
  chunk
5099
5269
  )) {
5100
5270
  __webpack_require_module__(
5101
- moduleArgumentsMap.get(runtimeModule)
5271
+ /** @type {ExecuteModuleArgument} */
5272
+ (moduleArgumentsMap.get(runtimeModule))
5102
5273
  );
5103
5274
  }
5104
5275
  exports = __webpack_require__(module.identifier());
@@ -5172,7 +5343,7 @@ This prevents using hashes of each other and should be avoided.`);
5172
5343
  }
5173
5344
 
5174
5345
  /**
5175
- * @typedef {Object} FactorizeModuleOptions
5346
+ * @typedef {object} FactorizeModuleOptions
5176
5347
  * @property {ModuleProfile} currentProfile
5177
5348
  * @property {ModuleFactory} factory
5178
5349
  * @property {Dependency[]} dependencies
@@ -5189,7 +5360,8 @@ This prevents using hashes of each other and should be avoided.`);
5189
5360
  */
5190
5361
 
5191
5362
  // Workaround for typescript as it doesn't support function overloading in jsdoc within a class
5192
- Compilation.prototype.factorizeModule = /** @type {{
5363
+ Compilation.prototype.factorizeModule = /**
5364
+ @type {{
5193
5365
  (options: FactorizeModuleOptions & { factoryResult?: false }, callback: ModuleCallback): void;
5194
5366
  (options: FactorizeModuleOptions & { factoryResult: true }, callback: ModuleFactoryResultCallback): void;
5195
5367
  }} */ (
@@ -5229,6 +5401,9 @@ Object.defineProperty(compilationPrototype, "cache", {
5229
5401
  "DEP_WEBPACK_COMPILATION_CACHE"
5230
5402
  ),
5231
5403
  set: util.deprecate(
5404
+ /**
5405
+ * @param {any} v value
5406
+ */
5232
5407
  v => {},
5233
5408
  "Compilation.cache was removed in favor of Compilation.getCache()",
5234
5409
  "DEP_WEBPACK_COMPILATION_CACHE"