webpack 5.93.0 → 5.95.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.
Files changed (344) hide show
  1. package/README.md +8 -5
  2. package/bin/webpack.js +6 -7
  3. package/hot/log.js +1 -2
  4. package/hot/only-dev-server.js +1 -1
  5. package/hot/poll.js +1 -1
  6. package/hot/signal.js +1 -1
  7. package/lib/APIPlugin.js +4 -3
  8. package/lib/AbstractMethodError.js +10 -5
  9. package/lib/AutomaticPrefetchPlugin.js +1 -1
  10. package/lib/BannerPlugin.js +12 -6
  11. package/lib/Cache.js +8 -10
  12. package/lib/CacheFacade.js +3 -3
  13. package/lib/CaseSensitiveModulesWarning.js +5 -7
  14. package/lib/Chunk.js +14 -11
  15. package/lib/ChunkGraph.js +58 -36
  16. package/lib/ChunkGroup.js +2 -3
  17. package/lib/ChunkTemplate.js +43 -0
  18. package/lib/CleanPlugin.js +10 -11
  19. package/lib/CodeGenerationResults.js +6 -5
  20. package/lib/CommentCompilationWarning.js +0 -1
  21. package/lib/Compilation.js +223 -191
  22. package/lib/Compiler.js +81 -82
  23. package/lib/ConcatenationScope.js +3 -6
  24. package/lib/ConditionalInitFragment.js +6 -7
  25. package/lib/ConstPlugin.js +7 -15
  26. package/lib/ContextExclusionPlugin.js +3 -3
  27. package/lib/ContextModule.js +33 -20
  28. package/lib/ContextModuleFactory.js +89 -44
  29. package/lib/ContextReplacementPlugin.js +10 -9
  30. package/lib/DefinePlugin.js +75 -68
  31. package/lib/DelegatedModule.js +7 -3
  32. package/lib/DelegatedModuleFactoryPlugin.js +36 -22
  33. package/lib/DelegatedPlugin.js +4 -0
  34. package/lib/DependenciesBlock.js +0 -1
  35. package/lib/Dependency.js +10 -14
  36. package/lib/DllEntryPlugin.js +4 -2
  37. package/lib/DllModuleFactory.js +1 -0
  38. package/lib/DllPlugin.js +9 -7
  39. package/lib/DllReferencePlugin.js +30 -15
  40. package/lib/EntryPlugin.js +1 -3
  41. package/lib/EnvironmentPlugin.js +6 -2
  42. package/lib/ErrorHelpers.js +11 -12
  43. package/lib/EvalDevToolModulePlugin.js +10 -12
  44. package/lib/EvalSourceMapDevToolPlugin.js +15 -13
  45. package/lib/ExportsInfo.js +185 -120
  46. package/lib/ExternalModule.js +41 -15
  47. package/lib/ExternalModuleFactoryPlugin.js +23 -10
  48. package/lib/FileSystemInfo.js +791 -422
  49. package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
  50. package/lib/FlagDependencyExportsPlugin.js +12 -11
  51. package/lib/FlagDependencyUsagePlugin.js +1 -1
  52. package/lib/Generator.js +2 -5
  53. package/lib/GraphHelpers.js +3 -2
  54. package/lib/HookWebpackError.js +8 -10
  55. package/lib/HotModuleReplacementPlugin.js +78 -64
  56. package/lib/IgnoreErrorModuleFactory.js +3 -3
  57. package/lib/IgnorePlugin.js +1 -3
  58. package/lib/IgnoreWarningsPlugin.js +6 -9
  59. package/lib/InitFragment.js +2 -3
  60. package/lib/LibManifestPlugin.js +4 -3
  61. package/lib/MainTemplate.js +72 -19
  62. package/lib/Module.js +25 -9
  63. package/lib/ModuleBuildError.js +4 -11
  64. package/lib/ModuleDependencyError.js +5 -5
  65. package/lib/ModuleDependencyWarning.js +5 -5
  66. package/lib/ModuleError.js +1 -5
  67. package/lib/ModuleFilenameHelpers.js +29 -46
  68. package/lib/ModuleGraph.js +7 -6
  69. package/lib/ModuleGraphConnection.js +6 -6
  70. package/lib/ModuleInfoHeaderPlugin.js +82 -30
  71. package/lib/ModuleParseError.js +8 -9
  72. package/lib/ModuleRestoreError.js +1 -1
  73. package/lib/ModuleStoreError.js +1 -1
  74. package/lib/ModuleTemplate.js +33 -1
  75. package/lib/ModuleTypeConstants.js +21 -22
  76. package/lib/ModuleWarning.js +1 -5
  77. package/lib/MultiCompiler.js +24 -26
  78. package/lib/MultiStats.js +73 -31
  79. package/lib/MultiWatching.js +1 -1
  80. package/lib/NormalModule.js +130 -69
  81. package/lib/NormalModuleFactory.js +53 -49
  82. package/lib/OptimizationStages.js +3 -3
  83. package/lib/ProgressPlugin.js +9 -9
  84. package/lib/ProvidePlugin.js +4 -4
  85. package/lib/RuntimeGlobals.js +71 -70
  86. package/lib/RuntimeModule.js +1 -1
  87. package/lib/RuntimePlugin.js +24 -12
  88. package/lib/RuntimeTemplate.js +40 -44
  89. package/lib/SizeFormatHelpers.js +2 -4
  90. package/lib/SourceMapDevToolPlugin.js +42 -34
  91. package/lib/Stats.js +5 -11
  92. package/lib/Template.js +18 -24
  93. package/lib/TemplatedPathPlugin.js +21 -13
  94. package/lib/WarnDeprecatedOptionPlugin.js +0 -1
  95. package/lib/WatchIgnorePlugin.js +26 -9
  96. package/lib/Watching.js +10 -5
  97. package/lib/WebpackOptionsApply.js +84 -62
  98. package/lib/asset/AssetGenerator.js +107 -42
  99. package/lib/asset/AssetModulesPlugin.js +29 -23
  100. package/lib/asset/AssetSourceGenerator.js +2 -7
  101. package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
  102. package/lib/buildChunkGraph.js +93 -81
  103. package/lib/cache/IdleFileCachePlugin.js +4 -4
  104. package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
  105. package/lib/cache/PackFileCacheStrategy.js +51 -50
  106. package/lib/cache/ResolverCachePlugin.js +6 -6
  107. package/lib/cache/mergeEtags.js +16 -21
  108. package/lib/cli.js +148 -104
  109. package/lib/config/browserslistTargetHandler.js +16 -13
  110. package/lib/config/defaults.js +32 -28
  111. package/lib/config/normalization.js +335 -344
  112. package/lib/config/target.js +42 -52
  113. package/lib/container/ContainerEntryModule.js +2 -2
  114. package/lib/container/ContainerPlugin.js +1 -1
  115. package/lib/container/RemoteRuntimeModule.js +11 -8
  116. package/lib/container/options.js +18 -4
  117. package/lib/css/CssExportsGenerator.js +26 -24
  118. package/lib/css/CssGenerator.js +9 -4
  119. package/lib/css/CssLoadingRuntimeModule.js +10 -10
  120. package/lib/css/CssModulesPlugin.js +127 -47
  121. package/lib/css/CssParser.js +20 -18
  122. package/lib/css/walkCssTokens.js +80 -95
  123. package/lib/debug/ProfilingPlugin.js +19 -20
  124. package/lib/dependencies/AMDDefineDependency.js +1 -1
  125. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
  126. package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
  127. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
  128. package/lib/dependencies/AMDRuntimeModules.js +2 -2
  129. package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
  130. package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
  131. package/lib/dependencies/CommonJsExportsDependency.js +0 -1
  132. package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
  133. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  134. package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
  135. package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
  136. package/lib/dependencies/ConstDependency.js +1 -1
  137. package/lib/dependencies/ContextDependency.js +7 -2
  138. package/lib/dependencies/ContextDependencyHelpers.js +31 -34
  139. package/lib/dependencies/ContextElementDependency.js +35 -8
  140. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  141. package/lib/dependencies/CssExportDependency.js +7 -7
  142. package/lib/dependencies/CssImportDependency.js +0 -2
  143. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
  144. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  145. package/lib/dependencies/CssUrlDependency.js +4 -5
  146. package/lib/dependencies/DynamicExports.js +5 -5
  147. package/lib/dependencies/ExportsInfoDependency.js +1 -2
  148. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
  149. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
  150. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
  151. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  152. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
  153. package/lib/dependencies/HarmonyExports.js +2 -2
  154. package/lib/dependencies/HarmonyImportDependency.js +2 -4
  155. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
  156. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
  157. package/lib/dependencies/ImportDependency.js +1 -1
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
  159. package/lib/dependencies/ImportMetaPlugin.js +11 -13
  160. package/lib/dependencies/ImportParserPlugin.js +39 -44
  161. package/lib/dependencies/JsonExportsDependency.js +22 -18
  162. package/lib/dependencies/LoaderPlugin.js +47 -36
  163. package/lib/dependencies/LocalModule.js +1 -1
  164. package/lib/dependencies/LocalModulesHelpers.js +4 -4
  165. package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
  166. package/lib/dependencies/ProvidedDependency.js +1 -1
  167. package/lib/dependencies/PureExpressionDependency.js +6 -6
  168. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  169. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  170. package/lib/dependencies/SystemPlugin.js +1 -1
  171. package/lib/dependencies/URLDependency.js +3 -3
  172. package/lib/dependencies/URLPlugin.js +66 -12
  173. package/lib/dependencies/WorkerPlugin.js +25 -24
  174. package/lib/dependencies/processExportInfo.js +3 -1
  175. package/lib/electron/ElectronTargetPlugin.js +1 -0
  176. package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
  177. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
  178. package/lib/formatLocation.js +1 -2
  179. package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
  180. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
  181. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
  182. package/lib/hmr/LazyCompilationPlugin.js +27 -12
  183. package/lib/hmr/lazyCompilationBackend.js +64 -40
  184. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
  185. package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
  186. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  187. package/lib/ids/HashedModuleIdsPlugin.js +5 -1
  188. package/lib/ids/IdHelpers.js +29 -39
  189. package/lib/ids/SyncModuleIdsPlugin.js +7 -2
  190. package/lib/index.js +1 -5
  191. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
  192. package/lib/javascript/BasicEvaluatedExpression.js +4 -19
  193. package/lib/javascript/ChunkHelpers.js +1 -1
  194. package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
  195. package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
  196. package/lib/javascript/JavascriptGenerator.js +23 -7
  197. package/lib/javascript/JavascriptModulesPlugin.js +133 -86
  198. package/lib/javascript/JavascriptParser.js +179 -200
  199. package/lib/javascript/JavascriptParserHelpers.js +20 -21
  200. package/lib/javascript/StartupHelpers.js +41 -13
  201. package/lib/json/JsonGenerator.js +7 -13
  202. package/lib/json/JsonModulesPlugin.js +1 -4
  203. package/lib/json/JsonParser.js +5 -3
  204. package/lib/library/AmdLibraryPlugin.js +12 -16
  205. package/lib/library/AssignLibraryPlugin.js +8 -10
  206. package/lib/library/EnableLibraryPlugin.js +15 -14
  207. package/lib/library/JsonpLibraryPlugin.js +2 -1
  208. package/lib/library/ModernModuleLibraryPlugin.js +8 -6
  209. package/lib/library/ModuleLibraryPlugin.js +2 -1
  210. package/lib/library/SystemLibraryPlugin.js +2 -1
  211. package/lib/library/UmdLibraryPlugin.js +66 -92
  212. package/lib/logging/Logger.js +32 -4
  213. package/lib/logging/createConsoleLogger.js +12 -13
  214. package/lib/logging/runtime.js +7 -8
  215. package/lib/logging/truncateArgs.js +5 -8
  216. package/lib/node/NodeWatchFileSystem.js +3 -18
  217. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  218. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  219. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  220. package/lib/node/nodeConsole.js +22 -22
  221. package/lib/optimize/AggressiveMergingPlugin.js +2 -4
  222. package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
  223. package/lib/optimize/ConcatenatedModule.js +81 -51
  224. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  225. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
  226. package/lib/optimize/InnerGraph.js +17 -17
  227. package/lib/optimize/InnerGraphPlugin.js +8 -7
  228. package/lib/optimize/LimitChunkCountPlugin.js +2 -3
  229. package/lib/optimize/MangleExportsPlugin.js +1 -0
  230. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  231. package/lib/optimize/MinMaxSizeWarning.js +1 -1
  232. package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
  233. package/lib/optimize/RealContentHashPlugin.js +7 -10
  234. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  235. package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
  236. package/lib/optimize/SplitChunksPlugin.js +34 -30
  237. package/lib/performance/SizeLimitsPlugin.js +2 -2
  238. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
  239. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
  240. package/lib/rules/BasicEffectRulePlugin.js +3 -1
  241. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  242. package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
  243. package/lib/rules/RuleSetCompiler.js +41 -22
  244. package/lib/rules/UseEffectRulePlugin.js +36 -32
  245. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
  246. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  247. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
  248. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
  249. package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
  250. package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
  251. package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
  252. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
  253. package/lib/schemes/DataUriPlugin.js +1 -1
  254. package/lib/schemes/HttpUriPlugin.js +241 -126
  255. package/lib/serialization/BinaryMiddleware.js +44 -28
  256. package/lib/serialization/DateObjectSerializer.js +1 -0
  257. package/lib/serialization/ErrorObjectSerializer.js +2 -0
  258. package/lib/serialization/FileMiddleware.js +154 -106
  259. package/lib/serialization/MapObjectSerializer.js +2 -1
  260. package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
  261. package/lib/serialization/ObjectMiddleware.js +52 -56
  262. package/lib/serialization/PlainObjectSerializer.js +32 -6
  263. package/lib/serialization/RegExpObjectSerializer.js +1 -0
  264. package/lib/serialization/Serializer.js +4 -5
  265. package/lib/serialization/SerializerMiddleware.js +6 -6
  266. package/lib/serialization/SetObjectSerializer.js +2 -1
  267. package/lib/sharing/ConsumeSharedPlugin.js +116 -97
  268. package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
  269. package/lib/sharing/ProvideForSharedDependency.js +0 -1
  270. package/lib/sharing/ProvideSharedPlugin.js +2 -2
  271. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  272. package/lib/sharing/utils.js +15 -27
  273. package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
  274. package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
  275. package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
  276. package/lib/stats/StatsFactory.js +127 -56
  277. package/lib/stats/StatsPrinter.js +75 -44
  278. package/lib/util/ArrayHelpers.js +8 -4
  279. package/lib/util/ArrayQueue.js +1 -1
  280. package/lib/util/AsyncQueue.js +31 -12
  281. package/lib/util/IterableHelpers.js +3 -4
  282. package/lib/util/LazyBucketSortedSet.js +60 -44
  283. package/lib/util/LazySet.js +13 -0
  284. package/lib/util/MapHelpers.js +1 -3
  285. package/lib/util/ParallelismFactorCalculator.js +1 -1
  286. package/lib/util/Queue.js +1 -1
  287. package/lib/util/Semaphore.js +4 -7
  288. package/lib/util/SetHelpers.js +5 -5
  289. package/lib/util/SortableSet.js +4 -3
  290. package/lib/util/StackedCacheMap.js +4 -6
  291. package/lib/util/StackedMap.js +1 -3
  292. package/lib/util/StringXor.js +0 -5
  293. package/lib/util/TupleQueue.js +1 -1
  294. package/lib/util/TupleSet.js +15 -5
  295. package/lib/util/URLAbsoluteSpecifier.js +7 -7
  296. package/lib/util/WeakTupleMap.js +19 -21
  297. package/lib/util/binarySearchBounds.js +5 -12
  298. package/lib/util/chainedImports.js +1 -1
  299. package/lib/util/cleverMerge.js +21 -19
  300. package/lib/util/comparators.js +57 -52
  301. package/lib/util/compileBooleanMatcher.js +3 -6
  302. package/lib/util/conventions.js +8 -11
  303. package/lib/util/createHash.js +9 -6
  304. package/lib/util/deprecation.js +22 -12
  305. package/lib/util/deterministicGrouping.js +19 -26
  306. package/lib/util/findGraphRoots.js +2 -2
  307. package/lib/util/fs.js +32 -32
  308. package/lib/util/hash/md4.js +2 -2
  309. package/lib/util/hash/wasm-hash.js +7 -7
  310. package/lib/util/hash/xxhash64.js +2 -2
  311. package/lib/util/identifier.js +81 -59
  312. package/lib/util/memoize.js +8 -10
  313. package/lib/util/mergeScope.js +6 -9
  314. package/lib/util/nonNumericOnlyHash.js +2 -2
  315. package/lib/util/numberHash.js +1 -6
  316. package/lib/util/objectToMap.js +0 -1
  317. package/lib/util/propertyAccess.js +2 -5
  318. package/lib/util/propertyName.js +1 -3
  319. package/lib/util/registerExternalSerializer.js +1 -1
  320. package/lib/util/runtime.js +109 -113
  321. package/lib/util/semver.js +29 -27
  322. package/lib/util/serialization.js +16 -1
  323. package/lib/util/smartGrouping.js +5 -5
  324. package/lib/util/source.js +1 -1
  325. package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
  326. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  327. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
  328. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  329. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
  330. package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
  331. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  332. package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
  333. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
  334. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
  335. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  336. package/package.json +18 -17
  337. package/schemas/WebpackOptions.check.js +1 -1
  338. package/schemas/WebpackOptions.json +5 -0
  339. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  340. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  341. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  342. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  343. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  344. package/types.d.ts +681 -355
package/lib/MultiStats.js CHANGED
@@ -8,15 +8,25 @@
8
8
  const identifierUtils = require("./util/identifier");
9
9
 
10
10
  /** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
11
+ /** @typedef {import("./Compilation").CreateStatsOptionsContext} CreateStatsOptionsContext */
12
+ /** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
11
13
  /** @typedef {import("./Stats")} Stats */
12
14
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").KnownStatsCompilation} KnownStatsCompilation */
13
15
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
16
+ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsError} StatsError */
14
17
 
18
+ /**
19
+ * @param {string} str string
20
+ * @param {string} prefix pref
21
+ * @returns {string} indent
22
+ */
15
23
  const indent = (str, prefix) => {
16
- const rem = str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
24
+ const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
17
25
  return prefix + rem;
18
26
  };
19
27
 
28
+ /** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */
29
+
20
30
  class MultiStats {
21
31
  /**
22
32
  * @param {Stats[]} stats the child stats
@@ -43,13 +53,30 @@ class MultiStats {
43
53
  return this.stats.some(stat => stat.hasWarnings());
44
54
  }
45
55
 
56
+ /**
57
+ * @param {string | boolean | StatsOptions | undefined} options stats options
58
+ * @param {CreateStatsOptionsContext} context context
59
+ * @returns {ChildOptions} context context
60
+ */
46
61
  _createChildOptions(options, context) {
47
- if (!options) {
48
- options = {};
49
- }
50
- const { children: childrenOptions = undefined, ...baseOptions } =
51
- typeof options === "string" ? { preset: options } : options;
62
+ const getCreateStatsOptions = () => {
63
+ if (!options) {
64
+ options = {};
65
+ }
66
+
67
+ const { children: childrenOptions = undefined, ...baseOptions } =
68
+ typeof options === "string"
69
+ ? { preset: options }
70
+ : /** @type {StatsOptions} */ (options);
71
+
72
+ return { childrenOptions, baseOptions };
73
+ };
74
+
52
75
  const children = this.stats.map((stat, idx) => {
76
+ if (typeof options === "boolean") {
77
+ return stat.compilation.createStatsOptions(options, context);
78
+ }
79
+ const { childrenOptions, baseOptions } = getCreateStatsOptions();
53
80
  const childOptions = Array.isArray(childrenOptions)
54
81
  ? childrenOptions[idx]
55
82
  : childrenOptions;
@@ -77,81 +104,96 @@ class MultiStats {
77
104
  }
78
105
 
79
106
  /**
80
- * @param {any} options stats options
107
+ * @param {(string | boolean | StatsOptions)=} options stats options
81
108
  * @returns {StatsCompilation} json output
82
109
  */
83
110
  toJson(options) {
84
- options = this._createChildOptions(options, { forToString: false });
111
+ const childOptions = this._createChildOptions(options, {
112
+ forToString: false
113
+ });
85
114
  /** @type {KnownStatsCompilation} */
86
115
  const obj = {};
87
116
  obj.children = this.stats.map((stat, idx) => {
88
- const obj = stat.toJson(options.children[idx]);
117
+ const obj = stat.toJson(childOptions.children[idx]);
89
118
  const compilationName = stat.compilation.name;
90
119
  const name =
91
120
  compilationName &&
92
121
  identifierUtils.makePathsRelative(
93
- options.context,
122
+ stat.compilation.compiler.context,
94
123
  compilationName,
95
124
  stat.compilation.compiler.root
96
125
  );
97
126
  obj.name = name;
98
127
  return obj;
99
128
  });
100
- if (options.version) {
129
+ if (childOptions.version) {
101
130
  obj.version = obj.children[0].version;
102
131
  }
103
- if (options.hash) {
132
+ if (childOptions.hash) {
104
133
  obj.hash = obj.children.map(j => j.hash).join("");
105
134
  }
106
- const mapError = (j, obj) => {
107
- return {
108
- ...obj,
109
- compilerPath: obj.compilerPath
110
- ? `${j.name}.${obj.compilerPath}`
111
- : j.name
112
- };
113
- };
114
- if (options.errors) {
135
+ /**
136
+ * @param {StatsCompilation} j stats error
137
+ * @param {StatsError} obj Stats error
138
+ * @returns {TODO} result
139
+ */
140
+ const mapError = (j, obj) => ({
141
+ ...obj,
142
+ compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
143
+ });
144
+ if (childOptions.errors) {
115
145
  obj.errors = [];
116
146
  for (const j of obj.children) {
117
- for (const i of j.errors) {
147
+ const errors =
148
+ /** @type {NonNullable<KnownStatsCompilation["errors"]>} */
149
+ (j.errors);
150
+ for (const i of errors) {
118
151
  obj.errors.push(mapError(j, i));
119
152
  }
120
153
  }
121
154
  }
122
- if (options.warnings) {
155
+ if (childOptions.warnings) {
123
156
  obj.warnings = [];
124
157
  for (const j of obj.children) {
125
- for (const i of j.warnings) {
158
+ const warnings =
159
+ /** @type {NonNullable<KnownStatsCompilation["warnings"]>} */
160
+ (j.warnings);
161
+ for (const i of warnings) {
126
162
  obj.warnings.push(mapError(j, i));
127
163
  }
128
164
  }
129
165
  }
130
- if (options.errorsCount) {
166
+ if (childOptions.errorsCount) {
131
167
  obj.errorsCount = 0;
132
168
  for (const j of obj.children) {
133
- obj.errorsCount += j.errorsCount;
169
+ obj.errorsCount += /** @type {number} */ (j.errorsCount);
134
170
  }
135
171
  }
136
- if (options.warningsCount) {
172
+ if (childOptions.warningsCount) {
137
173
  obj.warningsCount = 0;
138
174
  for (const j of obj.children) {
139
- obj.warningsCount += j.warningsCount;
175
+ obj.warningsCount += /** @type {number} */ (j.warningsCount);
140
176
  }
141
177
  }
142
178
  return obj;
143
179
  }
144
180
 
181
+ /**
182
+ * @param {(string | boolean | StatsOptions)=} options stats options
183
+ * @returns {string} string output
184
+ */
145
185
  toString(options) {
146
- options = this._createChildOptions(options, { forToString: true });
186
+ const childOptions = this._createChildOptions(options, {
187
+ forToString: true
188
+ });
147
189
  const results = this.stats.map((stat, idx) => {
148
- const str = stat.toString(options.children[idx]);
190
+ const str = stat.toString(childOptions.children[idx]);
149
191
  const compilationName = stat.compilation.name;
150
192
  const name =
151
193
  compilationName &&
152
194
  identifierUtils
153
195
  .makePathsRelative(
154
- options.context,
196
+ stat.compilation.compiler.context,
155
197
  compilationName,
156
198
  stat.compilation.compiler.root
157
199
  )
@@ -62,7 +62,7 @@ class MultiWatching {
62
62
  * @returns {void}
63
63
  */
64
64
  close(callback) {
65
- asyncLib.forEach(
65
+ asyncLib.each(
66
66
  this.watchings,
67
67
  (watching, finishedCallback) => {
68
68
  watching.close(finishedCallback);
@@ -82,12 +82,27 @@ const memoize = require("./util/memoize");
82
82
  /** @typedef {import("./util/Hash")} Hash */
83
83
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
84
84
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
85
+ /** @typedef {import("./util/createHash").Algorithm} Algorithm */
86
+ /**
87
+ * @template T
88
+ * @typedef {import("./util/deprecation").FakeHook<T>} FakeHook
89
+ */
85
90
 
86
91
  /** @typedef {{[k: string]: any}} ParserOptions */
87
92
  /** @typedef {{[k: string]: any}} GeneratorOptions */
88
93
 
89
94
  /** @typedef {UnsafeCacheData & { parser: undefined | Parser, parserOptions: undefined | ParserOptions, generator: undefined | Generator, generatorOptions: undefined | GeneratorOptions }} NormalModuleUnsafeCacheData */
90
95
 
96
+ /**
97
+ * @template T
98
+ * @typedef {import("../declarations/LoaderContext").LoaderContext<T>} LoaderContext
99
+ */
100
+
101
+ /**
102
+ * @template T
103
+ * @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} NormalModuleLoaderContext
104
+ */
105
+
91
106
  /**
92
107
  * @typedef {object} SourceMap
93
108
  * @property {number} version
@@ -184,11 +199,14 @@ const asBuffer = input => {
184
199
  };
185
200
 
186
201
  class NonErrorEmittedError extends WebpackError {
202
+ /**
203
+ * @param {any} error value which is not an instance of Error
204
+ */
187
205
  constructor(error) {
188
206
  super();
189
207
 
190
208
  this.name = "NonErrorEmittedError";
191
- this.message = "(Emitted value instead of an instance of Error) " + error;
209
+ this.message = `(Emitted value instead of an instance of Error) ${error}`;
192
210
  }
193
211
  }
194
212
 
@@ -200,12 +218,12 @@ makeSerializable(
200
218
 
201
219
  /**
202
220
  * @typedef {object} NormalModuleCompilationHooks
203
- * @property {SyncHook<[object, NormalModule]>} loader
204
- * @property {SyncHook<[LoaderItem[], NormalModule, object]>} beforeLoaders
221
+ * @property {SyncHook<[LoaderContext<any>, NormalModule]>} loader
222
+ * @property {SyncHook<[LoaderItem[], NormalModule, LoaderContext<any>]>} beforeLoaders
205
223
  * @property {SyncHook<[NormalModule]>} beforeParse
206
224
  * @property {SyncHook<[NormalModule]>} beforeSnapshot
207
- * @property {HookMap<AsyncSeriesBailHook<[string, NormalModule], string | Buffer>>} readResourceForScheme
208
- * @property {HookMap<AsyncSeriesBailHook<[object], string | Buffer>>} readResource
225
+ * @property {HookMap<FakeHook<AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>>>} readResourceForScheme
226
+ * @property {HookMap<AsyncSeriesBailHook<[LoaderContext<any>], string | Buffer | null>>} readResource
209
227
  * @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild
210
228
  */
211
229
 
@@ -251,20 +269,32 @@ class NormalModule extends Module {
251
269
  beforeSnapshot: new SyncHook(["module"]),
252
270
  // TODO webpack 6 deprecate
253
271
  readResourceForScheme: new HookMap(scheme => {
254
- const hook = hooks.readResource.for(scheme);
272
+ const hook =
273
+ /** @type {NormalModuleCompilationHooks} */
274
+ (hooks).readResource.for(scheme);
255
275
  return createFakeHook(
256
- /** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer>} */ ({
276
+ /** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>} */ ({
257
277
  tap: (options, fn) =>
258
278
  hook.tap(options, loaderContext =>
259
- fn(loaderContext.resource, loaderContext._module)
279
+ fn(
280
+ loaderContext.resource,
281
+ /** @type {NormalModule} */ (loaderContext._module)
282
+ )
260
283
  ),
261
284
  tapAsync: (options, fn) =>
262
285
  hook.tapAsync(options, (loaderContext, callback) =>
263
- fn(loaderContext.resource, loaderContext._module, callback)
286
+ fn(
287
+ loaderContext.resource,
288
+ /** @type {NormalModule} */ (loaderContext._module),
289
+ callback
290
+ )
264
291
  ),
265
292
  tapPromise: (options, fn) =>
266
293
  hook.tapPromise(options, loaderContext =>
267
- fn(loaderContext.resource, loaderContext._module)
294
+ fn(
295
+ loaderContext.resource,
296
+ /** @type {NormalModule} */ (loaderContext._module)
297
+ )
268
298
  )
269
299
  })
270
300
  );
@@ -343,7 +373,7 @@ class NormalModule extends Module {
343
373
  this._source = null;
344
374
  /**
345
375
  * @private
346
- * @type {Map<string, number> | undefined}
376
+ * @type {Map<string | undefined, number> | undefined}
347
377
  */
348
378
  this._sourceSizes = undefined;
349
379
  /**
@@ -369,12 +399,10 @@ class NormalModule extends Module {
369
399
  if (this.layer === null) {
370
400
  if (this.type === JAVASCRIPT_MODULE_TYPE_AUTO) {
371
401
  return this.request;
372
- } else {
373
- return `${this.type}|${this.request}`;
374
402
  }
375
- } else {
376
- return `${this.type}|${this.request}|${this.layer}`;
403
+ return `${this.type}|${this.request}`;
377
404
  }
405
+ return `${this.type}|${this.request}|${this.layer}`;
378
406
  }
379
407
 
380
408
  /**
@@ -382,7 +410,7 @@ class NormalModule extends Module {
382
410
  * @returns {string} a user readable identifier of the module
383
411
  */
384
412
  readableIdentifier(requestShortener) {
385
- return requestShortener.shorten(this.userRequest);
413
+ return /** @type {string} */ (requestShortener.shorten(this.userRequest));
386
414
  }
387
415
 
388
416
  /**
@@ -556,30 +584,36 @@ class NormalModule extends Module {
556
584
  /**
557
585
  * @returns {ResolveContext} resolve context
558
586
  */
559
- const getResolveContext = () => {
560
- return {
561
- fileDependencies: {
562
- add: d => /** @type {TODO} */ (loaderContext).addDependency(d)
563
- },
564
- contextDependencies: {
565
- add: d => /** @type {TODO} */ (loaderContext).addContextDependency(d)
566
- },
567
- missingDependencies: {
568
- add: d => /** @type {TODO} */ (loaderContext).addMissingDependency(d)
569
- }
570
- };
571
- };
587
+ const getResolveContext = () => ({
588
+ fileDependencies: {
589
+ add: d => /** @type {TODO} */ (loaderContext).addDependency(d)
590
+ },
591
+ contextDependencies: {
592
+ add: d => /** @type {TODO} */ (loaderContext).addContextDependency(d)
593
+ },
594
+ missingDependencies: {
595
+ add: d => /** @type {TODO} */ (loaderContext).addMissingDependency(d)
596
+ }
597
+ });
572
598
  const getAbsolutify = memoize(() =>
573
599
  absolutify.bindCache(compilation.compiler.root)
574
600
  );
575
601
  const getAbsolutifyInContext = memoize(() =>
576
- absolutify.bindContextCache(this.context, compilation.compiler.root)
602
+ absolutify.bindContextCache(
603
+ /** @type {string} */
604
+ (this.context),
605
+ compilation.compiler.root
606
+ )
577
607
  );
578
608
  const getContextify = memoize(() =>
579
609
  contextify.bindCache(compilation.compiler.root)
580
610
  );
581
611
  const getContextifyInContext = memoize(() =>
582
- contextify.bindContextCache(this.context, compilation.compiler.root)
612
+ contextify.bindContextCache(
613
+ /** @type {string} */
614
+ (this.context),
615
+ compilation.compiler.root
616
+ )
583
617
  );
584
618
  const utils = {
585
619
  /**
@@ -587,28 +621,29 @@ class NormalModule extends Module {
587
621
  * @param {string} request request
588
622
  * @returns {string} result
589
623
  */
590
- absolutify: (context, request) => {
591
- return context === this.context
624
+ absolutify: (context, request) =>
625
+ context === this.context
592
626
  ? getAbsolutifyInContext()(request)
593
- : getAbsolutify()(context, request);
594
- },
627
+ : getAbsolutify()(context, request),
595
628
  /**
596
629
  * @param {string} context context
597
630
  * @param {string} request request
598
631
  * @returns {string} result
599
632
  */
600
- contextify: (context, request) => {
601
- return context === this.context
633
+ contextify: (context, request) =>
634
+ context === this.context
602
635
  ? getContextifyInContext()(request)
603
- : getContextify()(context, request);
604
- },
636
+ : getContextify()(context, request),
605
637
  /**
606
638
  * @param {(string | typeof import("./util/Hash"))=} type type
607
639
  * @returns {Hash} hash
608
640
  */
609
- createHash: type => {
610
- return createHash(type || compilation.outputOptions.hashFunction);
611
- }
641
+ createHash: type =>
642
+ createHash(
643
+ type ||
644
+ /** @type {Algorithm} */
645
+ (compilation.outputOptions.hashFunction)
646
+ )
612
647
  };
613
648
  /** @type {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} */
614
649
  const loaderContext = {
@@ -622,8 +657,10 @@ class NormalModule extends Module {
622
657
  if (options.startsWith("{") && options.endsWith("}")) {
623
658
  try {
624
659
  options = parseJson(options);
625
- } catch (e) {
626
- throw new Error(`Cannot parse string options: ${e.message}`);
660
+ } catch (err) {
661
+ throw new Error(
662
+ `Cannot parse string options: ${/** @type {Error} */ (err).message}`
663
+ );
627
664
  }
628
665
  } else {
629
666
  options = querystring.parse(options, "&", "=", {
@@ -738,17 +775,21 @@ class NormalModule extends Module {
738
775
  utils,
739
776
  rootContext: /** @type {string} */ (options.context),
740
777
  webpack: true,
741
- sourceMap: !!this.useSourceMap,
778
+ sourceMap: Boolean(this.useSourceMap),
742
779
  mode: options.mode || "production",
780
+ hashFunction: options.output.hashFunction,
781
+ hashDigest: options.output.hashDigest,
782
+ hashDigestLength: options.output.hashDigestLength,
783
+ hashSalt: options.output.hashSalt,
743
784
  _module: this,
744
785
  _compilation: compilation,
745
786
  _compiler: compilation.compiler,
746
- fs: fs
787
+ fs
747
788
  };
748
789
 
749
790
  Object.assign(loaderContext, options.loader);
750
791
 
751
- hooks.loader.call(loaderContext, this);
792
+ hooks.loader.call(/** @type {LoaderContext<any>} */ (loaderContext), this);
752
793
 
753
794
  return loaderContext;
754
795
  }
@@ -775,7 +816,7 @@ class NormalModule extends Module {
775
816
  /**
776
817
  * @param {string} context the compilation context
777
818
  * @param {string | Buffer} content the content
778
- * @param {(string | SourceMapSource)=} sourceMap an optional source map
819
+ * @param {(string | SourceMapSource | null)=} sourceMap an optional source map
779
820
  * @param {object=} associatedObjectForCache object for caching
780
821
  * @returns {Source} the created source
781
822
  */
@@ -832,7 +873,14 @@ class NormalModule extends Module {
832
873
  hooks
833
874
  );
834
875
 
835
- const processResult = (err, result) => {
876
+ /** @typedef {[string | Buffer, string | SourceMapSource, Record<string, any>]} Result */
877
+
878
+ /**
879
+ * @param {Error | null} err err
880
+ * @param {(Result | null)=} _result result
881
+ * @returns {void}
882
+ */
883
+ const processResult = (err, _result) => {
836
884
  if (err) {
837
885
  if (!(err instanceof Error)) {
838
886
  err = new NonErrorEmittedError(err);
@@ -848,6 +896,7 @@ class NormalModule extends Module {
848
896
  return callback(error);
849
897
  }
850
898
 
899
+ const result = /** @type {Result} */ (_result);
851
900
  const source = result[0];
852
901
  const sourceMap = result.length >= 1 ? result[1] : null;
853
902
  const extraInfo = result.length >= 2 ? result[2] : null;
@@ -896,7 +945,11 @@ class NormalModule extends Module {
896
945
  buildInfo.cacheable = true;
897
946
 
898
947
  try {
899
- hooks.beforeLoaders.call(this.loaders, this, loaderContext);
948
+ hooks.beforeLoaders.call(
949
+ this.loaders,
950
+ this,
951
+ /** @type {LoaderContext<any>} */ (loaderContext)
952
+ );
900
953
  } catch (err) {
901
954
  processResult(err);
902
955
  return;
@@ -920,7 +973,13 @@ class NormalModule extends Module {
920
973
  .callAsync(loaderContext, (err, result) => {
921
974
  if (err) return callback(err);
922
975
  if (typeof result !== "string" && !result) {
923
- return callback(new UnhandledSchemeError(scheme, resource));
976
+ return callback(
977
+ new UnhandledSchemeError(
978
+ /** @type {string} */
979
+ (scheme),
980
+ resource
981
+ )
982
+ );
924
983
  }
925
984
  return callback(null, result);
926
985
  });
@@ -1037,7 +1096,10 @@ class NormalModule extends Module {
1037
1096
  * @private
1038
1097
  */
1039
1098
  _initBuildHash(compilation) {
1040
- const hash = createHash(compilation.outputOptions.hashFunction);
1099
+ const hash = createHash(
1100
+ /** @type {Algorithm} */
1101
+ (compilation.outputOptions.hashFunction)
1102
+ );
1041
1103
  if (this._source) {
1042
1104
  hash.update("source");
1043
1105
  this._source.updateHash(hash);
@@ -1128,7 +1190,7 @@ class NormalModule extends Module {
1128
1190
  try {
1129
1191
  hooks.beforeSnapshot.call(this);
1130
1192
  } catch (err) {
1131
- this.markModuleAsErrored(err);
1193
+ this.markModuleAsErrored(/** @type {WebpackError} */ (err));
1132
1194
  return callback();
1133
1195
  }
1134
1196
 
@@ -1140,7 +1202,7 @@ class NormalModule extends Module {
1140
1202
  // add warning for all non-absolute paths in fileDependencies, etc
1141
1203
  // This makes it easier to find problems with watching and/or caching
1142
1204
  /** @type {undefined | Set<string>} */
1143
- let nonAbsoluteDependencies = undefined;
1205
+ let nonAbsoluteDependencies;
1144
1206
  /**
1145
1207
  * @param {LazySet<string>} deps deps
1146
1208
  */
@@ -1155,7 +1217,8 @@ class NormalModule extends Module {
1155
1217
  const depWithoutGlob = dep.replace(/[\\/]?\*.*$/, "");
1156
1218
  const absolute = join(
1157
1219
  compilation.fileSystemInfo.fs,
1158
- this.context,
1220
+ /** @type {string} */
1221
+ (this.context),
1159
1222
  depWithoutGlob
1160
1223
  );
1161
1224
  if (absolute !== dep && ABSOLUTE_PATH_REGEX.test(absolute)) {
@@ -1168,7 +1231,7 @@ class NormalModule extends Module {
1168
1231
  : deps
1169
1232
  ).add(absolute);
1170
1233
  }
1171
- } catch (e) {
1234
+ } catch (_err) {
1172
1235
  // ignore
1173
1236
  }
1174
1237
  }
@@ -1218,7 +1281,7 @@ class NormalModule extends Module {
1218
1281
  try {
1219
1282
  hooks.beforeParse.call(this);
1220
1283
  } catch (err) {
1221
- this.markModuleAsErrored(err);
1284
+ this.markModuleAsErrored(/** @type {WebpackError} */ (err));
1222
1285
  this._initBuildHash(compilation);
1223
1286
  return callback();
1224
1287
  }
@@ -1241,11 +1304,11 @@ class NormalModule extends Module {
1241
1304
  source,
1242
1305
  current: this,
1243
1306
  module: this,
1244
- compilation: compilation,
1245
- options: options
1307
+ compilation,
1308
+ options
1246
1309
  });
1247
- } catch (e) {
1248
- handleParseError(/** @type {Error} */ (e));
1310
+ } catch (parseErr) {
1311
+ handleParseError(/** @type {Error} */ (parseErr));
1249
1312
  return;
1250
1313
  }
1251
1314
  handleParseResult();
@@ -1305,9 +1368,8 @@ class NormalModule extends Module {
1305
1368
  // When caching is implemented here, make sure to not cache when
1306
1369
  // at least one circular connection was in the loop above
1307
1370
  return current;
1308
- } else {
1309
- return true;
1310
1371
  }
1372
+ return true;
1311
1373
  }
1312
1374
 
1313
1375
  /**
@@ -1348,15 +1410,13 @@ class NormalModule extends Module {
1348
1410
  }
1349
1411
 
1350
1412
  /** @type {function(): Map<string, any>} */
1351
- const getData = () => {
1352
- return this._codeGeneratorData;
1353
- };
1413
+ const getData = () => this._codeGeneratorData;
1354
1414
 
1355
1415
  const sources = new Map();
1356
1416
  for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
1357
1417
  const source = this.error
1358
1418
  ? new RawSource(
1359
- "throw new Error(" + JSON.stringify(this.error.message) + ");"
1419
+ `throw new Error(${JSON.stringify(this.error.message)});`
1360
1420
  )
1361
1421
  : /** @type {Generator} */ (this.generator).generate(this, {
1362
1422
  dependencyTemplates,
@@ -1453,7 +1513,7 @@ class NormalModule extends Module {
1453
1513
  )
1454
1514
  );
1455
1515
  }
1456
- callback(null, !!needBuild);
1516
+ callback(null, Boolean(needBuild));
1457
1517
  });
1458
1518
  });
1459
1519
  }
@@ -1519,7 +1579,8 @@ class NormalModule extends Module {
1519
1579
  */
1520
1580
  updateHash(hash, context) {
1521
1581
  hash.update(/** @type {BuildInfo} */ (this.buildInfo).hash);
1522
- this.generator.updateHash(hash, {
1582
+ /** @type {Generator} */
1583
+ (this.generator).updateHash(hash, {
1523
1584
  module: this,
1524
1585
  ...context
1525
1586
  });