webpack 5.104.1 → 5.105.4

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 (333) hide show
  1. package/README.md +2 -2
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +85 -15
  4. package/lib/AbstractMethodError.js +1 -0
  5. package/lib/AsyncDependenciesBlock.js +17 -2
  6. package/lib/AsyncDependencyToInitialChunkError.js +3 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -1
  8. package/lib/BannerPlugin.js +5 -1
  9. package/lib/CacheFacade.js +2 -2
  10. package/lib/CaseSensitiveModulesWarning.js +1 -0
  11. package/lib/Chunk.js +9 -5
  12. package/lib/ChunkGraph.js +30 -9
  13. package/lib/ChunkGroup.js +6 -3
  14. package/lib/ChunkRenderError.js +9 -2
  15. package/lib/CleanPlugin.js +5 -1
  16. package/lib/CodeGenerationError.js +7 -1
  17. package/lib/CodeGenerationResults.js +10 -3
  18. package/lib/CommentCompilationWarning.js +2 -1
  19. package/lib/Compilation.js +294 -244
  20. package/lib/Compiler.js +4 -3
  21. package/lib/ConcatenationScope.js +2 -1
  22. package/lib/ConcurrentCompilationError.js +3 -3
  23. package/lib/ContextModule.js +255 -112
  24. package/lib/ContextModuleFactory.js +14 -2
  25. package/lib/DefinePlugin.js +15 -8
  26. package/lib/DelegatedModule.js +6 -0
  27. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  28. package/lib/Dependency.js +7 -2
  29. package/lib/DependencyTemplates.js +3 -2
  30. package/lib/DllModule.js +2 -0
  31. package/lib/DllReferencePlugin.js +1 -0
  32. package/lib/DotenvPlugin.js +11 -5
  33. package/lib/DynamicEntryPlugin.js +8 -1
  34. package/lib/EnvironmentNotSupportAsyncWarning.js +2 -0
  35. package/lib/EvalDevToolModulePlugin.js +3 -0
  36. package/lib/EvalSourceMapDevToolPlugin.js +25 -14
  37. package/lib/ExportsInfo.js +8 -34
  38. package/lib/ExternalModule.js +18 -2
  39. package/lib/ExternalModuleFactoryPlugin.js +9 -2
  40. package/lib/ExternalsPlugin.js +2 -1
  41. package/lib/FalseIIFEUmdWarning.js +1 -0
  42. package/lib/FileSystemInfo.js +49 -25
  43. package/lib/FlagDependencyExportsPlugin.js +8 -1
  44. package/lib/FlagDependencyUsagePlugin.js +9 -7
  45. package/lib/HarmonyLinkingError.js +1 -0
  46. package/lib/HookWebpackError.js +2 -0
  47. package/lib/HotModuleReplacementPlugin.js +16 -2
  48. package/lib/IgnoreWarningsPlugin.js +5 -2
  49. package/lib/InitFragment.js +1 -0
  50. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  51. package/lib/LibManifestPlugin.js +1 -0
  52. package/lib/ManifestPlugin.js +8 -1
  53. package/lib/Module.js +51 -8
  54. package/lib/ModuleBuildError.js +3 -1
  55. package/lib/ModuleDependencyError.js +1 -0
  56. package/lib/ModuleDependencyWarning.js +1 -0
  57. package/lib/ModuleError.js +4 -1
  58. package/lib/ModuleFilenameHelpers.js +4 -2
  59. package/lib/ModuleGraph.js +3 -0
  60. package/lib/ModuleGraphConnection.js +10 -10
  61. package/lib/ModuleHashingError.js +2 -0
  62. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  63. package/lib/ModuleNotFoundError.js +1 -0
  64. package/lib/ModuleParseError.js +5 -1
  65. package/lib/ModuleProfile.js +1 -1
  66. package/lib/ModuleRestoreError.js +2 -0
  67. package/lib/ModuleSourceTypeConstants.js +1 -11
  68. package/lib/ModuleStoreError.js +2 -0
  69. package/lib/ModuleWarning.js +3 -1
  70. package/lib/MultiCompiler.js +11 -7
  71. package/lib/MultiStats.js +5 -5
  72. package/lib/MultiWatching.js +2 -2
  73. package/lib/NoModeWarning.js +1 -0
  74. package/lib/NodeStuffInWebError.js +1 -0
  75. package/lib/NormalModule.js +28 -5
  76. package/lib/NormalModuleFactory.js +20 -4
  77. package/lib/OptionsApply.js +3 -1
  78. package/lib/ProgressPlugin.js +4 -0
  79. package/lib/RawModule.js +2 -0
  80. package/lib/RuntimeModule.js +28 -1
  81. package/lib/RuntimePlugin.js +7 -9
  82. package/lib/RuntimeTemplate.js +14 -7
  83. package/lib/SourceMapDevToolModuleOptionsPlugin.js +1 -0
  84. package/lib/SourceMapDevToolPlugin.js +40 -25
  85. package/lib/Stats.js +3 -2
  86. package/lib/Template.js +10 -5
  87. package/lib/TemplatedPathPlugin.js +4 -2
  88. package/lib/UnhandledSchemeError.js +1 -0
  89. package/lib/UnsupportedFeatureWarning.js +3 -0
  90. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  91. package/lib/WatchIgnorePlugin.js +1 -1
  92. package/lib/Watching.js +5 -0
  93. package/lib/WebpackError.js +4 -0
  94. package/lib/WebpackOptionsApply.js +74 -44
  95. package/lib/asset/AssetBytesGenerator.js +1 -0
  96. package/lib/asset/AssetGenerator.js +18 -3
  97. package/lib/asset/AssetModulesPlugin.js +48 -2
  98. package/lib/asset/AssetParser.js +4 -0
  99. package/lib/asset/AssetSourceGenerator.js +1 -0
  100. package/lib/asset/RawDataUrlModule.js +9 -1
  101. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  102. package/lib/buildChunkGraph.js +31 -2
  103. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  104. package/lib/cache/PackFileCacheStrategy.js +41 -8
  105. package/lib/cache/getLazyHashedEtag.js +13 -4
  106. package/lib/cache/mergeEtags.js +3 -1
  107. package/lib/cli.js +3 -1
  108. package/lib/config/defaults.js +65 -44
  109. package/lib/config/normalization.js +96 -0
  110. package/lib/container/ContainerEntryDependency.js +3 -0
  111. package/lib/container/ContainerEntryModule.js +7 -0
  112. package/lib/container/ContainerExposedDependency.js +1 -0
  113. package/lib/container/FallbackDependency.js +1 -0
  114. package/lib/container/FallbackItemDependency.js +1 -0
  115. package/lib/container/FallbackModule.js +4 -0
  116. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  117. package/lib/container/ModuleFederationPlugin.js +1 -1
  118. package/lib/container/RemoteModule.js +42 -1
  119. package/lib/css/CssGenerator.js +38 -4
  120. package/lib/css/CssModulesPlugin.js +33 -30
  121. package/lib/css/CssParser.js +12 -9
  122. package/lib/debug/ProfilingPlugin.js +1 -0
  123. package/lib/dependencies/AMDDefineDependency.js +3 -1
  124. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  125. package/lib/dependencies/AMDPlugin.js +1 -1
  126. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  127. package/lib/dependencies/CachedConstDependency.js +1 -0
  128. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  129. package/lib/dependencies/CommonJsExportRequireDependency.js +5 -0
  130. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  131. package/lib/dependencies/CommonJsImportsParserPlugin.js +315 -506
  132. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  133. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  134. package/lib/dependencies/ConstDependency.js +1 -0
  135. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  136. package/lib/dependencies/ContextElementDependency.js +1 -0
  137. package/lib/dependencies/CreateRequireParserPlugin.js +356 -0
  138. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  139. package/lib/dependencies/CssIcssExportDependency.js +7 -4
  140. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  141. package/lib/dependencies/CssUrlDependency.js +2 -3
  142. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  143. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  144. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  145. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
  146. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -8
  147. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  148. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  149. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  150. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  151. package/lib/dependencies/HarmonyImportDependency.js +31 -1
  152. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +217 -49
  153. package/lib/dependencies/HarmonyImportSideEffectDependency.js +11 -5
  154. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  155. package/lib/dependencies/HarmonyModulesPlugin.js +4 -0
  156. package/lib/dependencies/ImportDependency.js +1 -0
  157. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  158. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  159. package/lib/dependencies/ImportParserPlugin.js +8 -23
  160. package/lib/dependencies/ImportPhase.js +4 -0
  161. package/lib/dependencies/LoaderPlugin.js +3 -0
  162. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  163. package/lib/dependencies/ModuleDependency.js +1 -0
  164. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  165. package/lib/dependencies/ProvidedDependency.js +1 -0
  166. package/lib/dependencies/RequireContextPlugin.js +1 -0
  167. package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
  168. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  169. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  170. package/lib/dependencies/WorkerDependency.js +9 -3
  171. package/lib/dependencies/WorkerPlugin.js +1 -0
  172. package/lib/dependencies/getFunctionExpression.js +3 -1
  173. package/lib/electron/ElectronTargetPlugin.js +3 -1
  174. package/lib/errors/BuildCycleError.js +4 -1
  175. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  176. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  177. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  178. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  179. package/lib/hmr/lazyCompilationBackend.js +3 -2
  180. package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
  181. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
  182. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
  183. package/lib/ids/HashedModuleIdsPlugin.js +3 -8
  184. package/lib/ids/IdHelpers.js +10 -8
  185. package/lib/ids/NamedChunkIdsPlugin.js +7 -5
  186. package/lib/ids/NamedModuleIdsPlugin.js +1 -0
  187. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  188. package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
  189. package/lib/ids/SyncModuleIdsPlugin.js +30 -20
  190. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  191. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  192. package/lib/javascript/JavascriptModulesPlugin.js +104 -30
  193. package/lib/javascript/JavascriptParser.js +48 -15
  194. package/lib/json/JsonGenerator.js +1 -0
  195. package/lib/json/JsonParser.js +9 -2
  196. package/lib/library/AbstractLibraryPlugin.js +4 -1
  197. package/lib/library/AmdLibraryPlugin.js +2 -1
  198. package/lib/library/AssignLibraryPlugin.js +6 -2
  199. package/lib/library/EnableLibraryPlugin.js +1 -0
  200. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  201. package/lib/library/JsonpLibraryPlugin.js +1 -1
  202. package/lib/library/ModuleLibraryPlugin.js +130 -13
  203. package/lib/library/SystemLibraryPlugin.js +4 -1
  204. package/lib/library/UmdLibraryPlugin.js +4 -3
  205. package/lib/logging/Logger.js +9 -5
  206. package/lib/logging/createConsoleLogger.js +4 -0
  207. package/lib/logging/truncateArgs.js +1 -1
  208. package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
  209. package/lib/node/NodeEnvironmentPlugin.js +1 -0
  210. package/lib/node/NodeTargetPlugin.js +10 -1
  211. package/lib/node/NodeTemplatePlugin.js +1 -0
  212. package/lib/node/NodeWatchFileSystem.js +6 -0
  213. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
  214. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  215. package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
  216. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
  217. package/lib/node/nodeConsole.js +18 -1
  218. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  219. package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
  220. package/lib/optimize/ConcatenatedModule.js +36 -19
  221. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  222. package/lib/optimize/InnerGraph.js +5 -3
  223. package/lib/optimize/InnerGraphPlugin.js +25 -25
  224. package/lib/optimize/LimitChunkCountPlugin.js +3 -2
  225. package/lib/optimize/MangleExportsPlugin.js +14 -2
  226. package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
  227. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  228. package/lib/optimize/ModuleConcatenationPlugin.js +23 -5
  229. package/lib/optimize/RealContentHashPlugin.js +37 -27
  230. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  231. package/lib/optimize/RuntimeChunkPlugin.js +3 -5
  232. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  233. package/lib/optimize/SplitChunksPlugin.js +23 -5
  234. package/lib/performance/AssetsOverSizeLimitWarning.js +7 -2
  235. package/lib/performance/EntrypointsOverSizeLimitWarning.js +7 -2
  236. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  237. package/lib/performance/SizeLimitsPlugin.js +7 -6
  238. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
  239. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
  240. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
  241. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
  242. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  243. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  244. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  245. package/lib/rules/RuleSetCompiler.js +6 -0
  246. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  247. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  248. package/lib/runtime/CompatRuntimeModule.js +1 -0
  249. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  250. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
  251. package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
  252. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  253. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  254. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  255. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
  256. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  257. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  258. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  259. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  260. package/lib/runtime/ToBinaryRuntimeModule.js +14 -6
  261. package/lib/schemes/HttpUriPlugin.js +39 -20
  262. package/lib/schemes/VirtualUrlPlugin.js +28 -2
  263. package/lib/serialization/BinaryMiddleware.js +4 -0
  264. package/lib/serialization/FileMiddleware.js +9 -4
  265. package/lib/serialization/ObjectMiddleware.js +34 -11
  266. package/lib/serialization/PlainObjectSerializer.js +2 -0
  267. package/lib/sharing/ConsumeSharedModule.js +78 -1
  268. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  269. package/lib/sharing/ProvideSharedModule.js +4 -0
  270. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  271. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  272. package/lib/sharing/utils.js +8 -6
  273. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -12
  274. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  275. package/lib/stats/StatsFactory.js +2 -2
  276. package/lib/url/URLParserPlugin.js +5 -3
  277. package/lib/util/AppendOnlyStackedSet.js +78 -0
  278. package/lib/util/Hash.js +1 -0
  279. package/lib/util/IterableHelpers.js +1 -0
  280. package/lib/util/LazyBucketSortedSet.js +1 -0
  281. package/lib/util/LazySet.js +1 -0
  282. package/lib/util/ParallelismFactorCalculator.js +1 -0
  283. package/lib/util/SortableSet.js +1 -0
  284. package/lib/util/StringXor.js +1 -0
  285. package/lib/util/binarySearchBounds.js +15 -8
  286. package/lib/util/chainedImports.js +1 -1
  287. package/lib/util/cleverMerge.js +6 -1
  288. package/lib/util/comparators.js +21 -1
  289. package/lib/util/compileBooleanMatcher.js +3 -3
  290. package/lib/util/concatenate.js +3 -2
  291. package/lib/util/conventions.js +3 -2
  292. package/lib/util/deterministicGrouping.js +13 -1
  293. package/lib/util/extractSourceMap.js +12 -13
  294. package/lib/util/findGraphRoots.js +79 -109
  295. package/lib/util/fs.js +15 -19
  296. package/lib/util/hash/BatchedHash.js +4 -0
  297. package/lib/util/hash/BulkUpdateHash.js +8 -1
  298. package/lib/util/hash/hash-digest.js +1 -0
  299. package/lib/util/hash/wasm-hash.js +18 -2
  300. package/lib/util/identifier.js +7 -2
  301. package/lib/util/magicComment.js +1 -1
  302. package/lib/util/propertyName.js +1 -1
  303. package/lib/util/registerExternalSerializer.js +1 -0
  304. package/lib/util/runtime.js +15 -1
  305. package/lib/util/semver.js +1 -0
  306. package/lib/util/serialization.js +2 -2
  307. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
  308. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  309. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  310. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  311. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  312. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  313. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  314. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  315. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  316. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  317. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  318. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  319. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  320. package/lib/webpack.js +16 -4
  321. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  322. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
  323. package/package.json +40 -40
  324. package/schemas/WebpackOptions.check.js +1 -1
  325. package/schemas/WebpackOptions.json +121 -55
  326. package/schemas/plugins/BannerPlugin.json +2 -2
  327. package/schemas/plugins/IgnorePlugin.json +1 -1
  328. package/schemas/plugins/ManifestPlugin.json +3 -3
  329. package/schemas/plugins/ProgressPlugin.json +1 -1
  330. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  331. package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
  332. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  333. package/types.d.ts +677 -230
package/lib/Module.js CHANGED
@@ -80,6 +80,8 @@ const makeSerializable = require("./util/makeSerializable");
80
80
  /** @typedef {KnownSourceType | string} SourceType */
81
81
  /** @typedef {ReadonlySet<SourceType>} SourceTypes */
82
82
 
83
+ /** @typedef {ReadonlySet<typeof JAVASCRIPT_TYPE | string>} BasicSourceTypes */
84
+
83
85
  // TODO webpack 6: compilation will be required in CodeGenerationContext
84
86
  /**
85
87
  * @typedef {object} CodeGenerationContext
@@ -104,15 +106,42 @@ const makeSerializable = require("./util/makeSerializable");
104
106
  /** @typedef {Set<string>} RuntimeRequirements */
105
107
  /** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
106
108
 
107
- /** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<EXPECTED_ANY>[]>} KnownCodeGenerationResultDataForJavascriptModules */
108
- /** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */
109
- /** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */
110
- /** @typedef {Map<"share-init", [{ shareScope: string, initStage: number, init: string }]>} KnownCodeGenerationResultForSharing */
111
- /** @typedef {KnownCodeGenerationResultDataForJavascriptModules & KnownCodeGenerationResultDataForCssModules & KnownCodeGenerationResultDataForAssetModules & KnownCodeGenerationResultForSharing & Map<string, EXPECTED_ANY>} CodeGenerationResultData */
109
+ /**
110
+ * @typedef {object} AllCodeGenerationSchemas
111
+ * @property {Set<string>} topLevelDeclarations top level declarations for javascript modules
112
+ * @property {InitFragment<EXPECTED_ANY>[]} chunkInitFragments chunk init fragments for javascript modules
113
+ * @property {{ javascript?: string, ["css-url"]?: string }} url url for css and javascript modules
114
+ * @property {string} filename a filename for asset modules
115
+ * @property {AssetInfo} assetInfo an asset info for asset modules
116
+ * @property {string} fullContentHash a full content hash for asset modules
117
+ * @property {[{ shareScope: string, initStage: number, init: string }]} share-init share-init for modules federation
118
+ */
119
+
120
+ /* eslint-disable jsdoc/type-formatting */
121
+ /**
122
+ * @template {string} K
123
+ * @typedef {K extends keyof AllCodeGenerationSchemas ? AllCodeGenerationSchemas[K] : EXPECTED_ANY} CodeGenValue
124
+ */
125
+ /* eslint-enable jsdoc/type-formatting */
126
+
127
+ /* eslint-disable jsdoc/require-template */
128
+ /**
129
+ * @typedef {object} CodeGenMapOverloads
130
+ * @property {<K extends string>(key: K) => CodeGenValue<K> | undefined} get
131
+ * @property {<K extends string>(key: K, value: CodeGenValue<K>) => CodeGenerationResultData} set
132
+ * @property {<K extends string>(key: K) => boolean} has
133
+ * @property {<K extends string>(key: K) => boolean} delete
134
+ */
135
+
136
+ /**
137
+ * @typedef {Omit<Map<string, EXPECTED_ANY>, "get" | "set" | "has" | "delete"> & CodeGenMapOverloads} CodeGenerationResultData
138
+ */
139
+
140
+ /** @typedef {Map<SourceType, Source>} Sources */
112
141
 
113
142
  /**
114
143
  * @typedef {object} CodeGenerationResult
115
- * @property {Map<SourceType, Source>} sources the resulting sources for all source types
144
+ * @property {Sources} sources the resulting sources for all source types
116
145
  * @property {CodeGenerationResultData=} data the resulting data for all source types
117
146
  * @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements
118
147
  * @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)
@@ -135,8 +164,8 @@ const makeSerializable = require("./util/makeSerializable");
135
164
  * @property {boolean=} sideEffectFree
136
165
  * @property {boolean=} isCSSModule
137
166
  * @property {Record<string, string>=} jsIncompatibleExports
138
- * @property {Map<RuntimeSpec, Record<string, string>>=} exportsFinalNameByRuntime
139
- * @property {Map<RuntimeSpec, string>=} exportsSourceByRuntime
167
+ * @property {Map<string, Record<string, string>>=} exportsFinalNameByRuntime
168
+ * @property {Map<string, string>=} exportsSourceByRuntime
140
169
  */
141
170
 
142
171
  /**
@@ -939,6 +968,19 @@ class Module extends DependenciesBlock {
939
968
  return JAVASCRIPT_TYPES;
940
969
  }
941
970
 
971
+ /**
972
+ * Basic source types are high-level categories like javascript, css, webassembly, etc.
973
+ * We only have built-in knowledge about the javascript basic type here; other basic types may be
974
+ * added or changed over time by generators and do not need to be handled or detected here.
975
+ *
976
+ * Some modules, e.g. RemoteModule, may return non-basic source types like "remote" and "share-init"
977
+ * from getSourceTypes(), but their generated output is still JavaScript, i.e. their basic type is JS.
978
+ * @returns {BasicSourceTypes} types available (do not mutate)
979
+ */
980
+ getSourceBasicTypes() {
981
+ return this.getSourceTypes();
982
+ }
983
+
942
984
  /**
943
985
  * @abstract
944
986
  * @deprecated Use codeGeneration() instead
@@ -1026,6 +1068,7 @@ class Module extends DependenciesBlock {
1026
1068
  */
1027
1069
  codeGeneration(context) {
1028
1070
  // Best override this method
1071
+ /** @type {Sources} */
1029
1072
  const sources = new Map();
1030
1073
  for (const type of this.getSourceTypes()) {
1031
1074
  if (type !== UNKNOWN_TYPE) {
@@ -17,10 +17,11 @@ const makeSerializable = require("./util/makeSerializable");
17
17
  class ModuleBuildError extends WebpackError {
18
18
  /**
19
19
  * @param {string | ErrorWithHideStack} err error thrown
20
- * @param {{from?: string | null}} info additional info
20
+ * @param {{ from?: string | null }} info additional info
21
21
  */
22
22
  constructor(err, { from = null } = {}) {
23
23
  let message = "Module build failed";
24
+ /** @type {undefined | string} */
24
25
  let details;
25
26
 
26
27
  message += from ? ` (from ${from}):\n` : ": ";
@@ -48,6 +49,7 @@ class ModuleBuildError extends WebpackError {
48
49
 
49
50
  super(message);
50
51
 
52
+ /** @type {string} */
51
53
  this.name = "ModuleBuildError";
52
54
  this.details = details;
53
55
  this.error = err;
@@ -21,6 +21,7 @@ class ModuleDependencyError extends WebpackError {
21
21
  constructor(module, err, loc) {
22
22
  super(err.message);
23
23
 
24
+ /** @type {string} */
24
25
  this.name = "ModuleDependencyError";
25
26
  this.details =
26
27
  err && !err.hideStack
@@ -21,6 +21,7 @@ class ModuleDependencyWarning extends WebpackError {
21
21
  constructor(module, err, loc) {
22
22
  super(err ? err.message : "");
23
23
 
24
+ /** @type {string} */
24
25
  this.name = "ModuleDependencyWarning";
25
26
  this.details =
26
27
  err && !err.hideStack
@@ -15,7 +15,7 @@ const makeSerializable = require("./util/makeSerializable");
15
15
  class ModuleError extends WebpackError {
16
16
  /**
17
17
  * @param {Error} err error thrown
18
- * @param {{from?: string | null}} info additional info
18
+ * @param {{ from?: string | null }} info additional info
19
19
  */
20
20
  constructor(err, { from = null } = {}) {
21
21
  let message = "Module Error";
@@ -30,8 +30,11 @@ class ModuleError extends WebpackError {
30
30
 
31
31
  super(message);
32
32
 
33
+ /** @type {string} */
33
34
  this.name = "ModuleError";
35
+ /** @type {Error} */
34
36
  this.error = err;
37
+ /** @type {string | undefined} */
35
38
  this.details =
36
39
  err && typeof err === "object" && err.stack
37
40
  ? cleanUp(err.stack, this.message)
@@ -15,7 +15,8 @@ const memoize = require("./util/memoize");
15
15
  /** @typedef {import("./Module")} Module */
16
16
  /** @typedef {import("./RequestShortener")} RequestShortener */
17
17
 
18
- /** @typedef {string | RegExp | ((str: string) => boolean) | (string | RegExp | ((str: string) => boolean))[]} Matcher */
18
+ /** @typedef {(str: string) => boolean} MatcherFn */
19
+ /** @typedef {string | RegExp | MatcherFn | (string | RegExp | MatcherFn)[]} Matcher */
19
20
  /** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
20
21
 
21
22
  const ModuleFilenameHelpers = module.exports;
@@ -115,7 +116,7 @@ const lazyObject = (obj) => {
115
116
  return newObj;
116
117
  };
117
118
 
118
- const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
119
+ const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/g;
119
120
  /**
120
121
  * @typedef {object} ModuleFilenameTemplateContext
121
122
  * @property {string} identifier the identifier of the module
@@ -157,6 +158,7 @@ ModuleFilenameHelpers.createFilename = (
157
158
 
158
159
  /** @type {ReturnStringCallback} */
159
160
  let absoluteResourcePath;
161
+ /** @type {ReturnStringCallback} */
160
162
  let hash;
161
163
  /** @type {ReturnStringCallback} */
162
164
  let identifier;
@@ -33,6 +33,7 @@ const { sortWithSourceOrder } = require("./util/comparators");
33
33
  * @returns {string}
34
34
  */
35
35
 
36
+ /** @type {Iterable<ModuleGraphConnection>} */
36
37
  const EMPTY_SET = new Set();
37
38
 
38
39
  /**
@@ -42,6 +43,7 @@ const EMPTY_SET = new Set();
42
43
  * @returns {ReadonlyMap<T, ReadonlyArray<ModuleGraphConnection>>} mapped by key
43
44
  */
44
45
  const getConnectionsByKey = (set, getKey) => {
46
+ /** @type {Map<T, ModuleGraphConnection[]>} */
45
47
  const map = new Map();
46
48
  /** @type {T | 0} */
47
49
  let lastKey = 0;
@@ -528,6 +530,7 @@ class ModuleGraph {
528
530
  mgm._unassignedConnections &&
529
531
  mgm._unassignedConnections.length !== 0
530
532
  ) {
533
+ /** @type {undefined | ModuleGraphConnection} */
531
534
  let foundConnection;
532
535
  for (const connection of mgm._unassignedConnections) {
533
536
  this._dependencyMap.set(
@@ -57,7 +57,7 @@ class ModuleGraphConnection {
57
57
  * @param {Module} module the referenced module
58
58
  * @param {string=} explanation some extra detail
59
59
  * @param {boolean=} weak the reference is weak
60
- * @param {false | null | GetConditionFn | undefined} condition condition for the connection
60
+ * @param {false | null | GetConditionFn=} condition condition for the connection
61
61
  */
62
62
  constructor(
63
63
  originModule,
@@ -67,14 +67,23 @@ class ModuleGraphConnection {
67
67
  weak = false,
68
68
  condition = undefined
69
69
  ) {
70
+ /** @type {Module | null} */
70
71
  this.originModule = originModule;
72
+ /** @type {Module | null} */
71
73
  this.resolvedOriginModule = originModule;
74
+ /** @type {Dependency | null} */
72
75
  this.dependency = dependency;
76
+ /** @type {Module} */
73
77
  this.resolvedModule = module;
78
+ /** @type {Module} */
74
79
  this.module = module;
80
+ /** @type {boolean | undefined} */
75
81
  this.weak = weak;
82
+ /** @type {boolean} */
76
83
  this.conditional = Boolean(condition);
84
+ /** @type {boolean} */
77
85
  this._active = condition !== false;
86
+ /** @type {false | null | GetConditionFn | undefined} */
78
87
  this.condition = condition || undefined;
79
88
  /** @type {Set<string> | undefined} */
80
89
  this.explanations = undefined;
@@ -175,15 +184,6 @@ class ModuleGraphConnection {
175
184
  this.conditional = false;
176
185
  this._active = value;
177
186
  }
178
-
179
- // TODO webpack 5 remove
180
- get active() {
181
- throw new Error("Use getActiveState instead");
182
- }
183
-
184
- set active(value) {
185
- throw new Error("Use setActive instead");
186
- }
187
187
  }
188
188
 
189
189
  /** @typedef {typeof TRANSITIVE_ONLY} TRANSITIVE_ONLY */
@@ -18,6 +18,7 @@ class ModuleHashingError extends WebpackError {
18
18
  constructor(module, error) {
19
19
  super();
20
20
 
21
+ /** @type {string} */
21
22
  this.name = "ModuleHashingError";
22
23
  this.error = error;
23
24
  this.message = error.message;
@@ -26,4 +27,5 @@ class ModuleHashingError extends WebpackError {
26
27
  }
27
28
  }
28
29
 
30
+ /** @type {typeof ModuleHashingError} */
29
31
  module.exports = ModuleHashingError;
@@ -63,6 +63,7 @@ const printExportsInfoToSource = (
63
63
  let alreadyPrintedExports = 0;
64
64
 
65
65
  // determine exports to print
66
+ /** @type {ExportInfo[]} */
66
67
  const printedExports = [];
67
68
  for (const exportInfo of exportsInfo.orderedExports) {
68
69
  if (!alreadyPrinted.has(exportInfo)) {
@@ -145,7 +146,8 @@ const printExportsInfoToSource = (
145
146
  }
146
147
  };
147
148
 
148
- /** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */
149
+ /** @typedef {{ header: RawSource | undefined, full: WeakMap<Source, CachedSource> }} CacheEntry */
150
+ /** @type {WeakMap<RequestShortener, WeakMap<Module, CacheEntry>>} */
149
151
  const caches = new WeakMap();
150
152
 
151
153
  const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
@@ -155,6 +157,7 @@ class ModuleInfoHeaderPlugin {
155
157
  * @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
156
158
  */
157
159
  constructor(verbose = true) {
160
+ /** @type {boolean} */
158
161
  this._verbose = verbose;
159
162
  }
160
163
 
@@ -175,6 +178,7 @@ class ModuleInfoHeaderPlugin {
175
178
  { chunk, chunkGraph, moduleGraph, runtimeTemplate }
176
179
  ) => {
177
180
  const { requestShortener } = runtimeTemplate;
181
+ /** @type {undefined | CacheEntry} */
178
182
  let cacheEntry;
179
183
  let cache = caches.get(requestShortener);
180
184
  if (cache === undefined) {
@@ -256,6 +260,7 @@ class ModuleInfoHeaderPlugin {
256
260
  PLUGIN_NAME,
257
261
  (moduleSource, module, { runtimeTemplate }) => {
258
262
  const { requestShortener } = runtimeTemplate;
263
+ /** @type {undefined | CacheEntry} */
259
264
  let cacheEntry;
260
265
  let cache = caches.get(requestShortener);
261
266
  if (cache === undefined) {
@@ -78,6 +78,7 @@ class ModuleNotFoundError extends WebpackError {
78
78
 
79
79
  super(message);
80
80
 
81
+ /** @type {string} */
81
82
  this.name = "ModuleNotFoundError";
82
83
  this.details = err.details;
83
84
  this.module = module;
@@ -8,6 +8,7 @@
8
8
  const WebpackError = require("./WebpackError");
9
9
  const makeSerializable = require("./util/makeSerializable");
10
10
 
11
+ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
11
12
  /** @typedef {import("./Dependency").SourcePosition} SourcePosition */
12
13
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
13
14
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -23,6 +24,7 @@ class ModuleParseError extends WebpackError {
23
24
  */
24
25
  constructor(source, err, loaders, type) {
25
26
  let message = `Module parse failed: ${err && err.message}`;
27
+ /** @type {undefined | DependencyLocation} */
26
28
  let loc;
27
29
 
28
30
  if (
@@ -40,7 +42,8 @@ class ModuleParseError extends WebpackError {
40
42
  "\nFor files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: \"webassembly/async\"').";
41
43
  } else if (!loaders) {
42
44
  message +=
43
- "\nYou may need an appropriate loader to handle this file type.";
45
+ "\nYou may need an appropriate loader to handle this file type. " +
46
+ "See https://webpack.js.org/concepts/loaders";
44
47
  } else if (loaders.length >= 1) {
45
48
  message += `\nFile was processed with these loaders:${loaders
46
49
  .map((loader) => `\n * ${loader}`)
@@ -88,6 +91,7 @@ class ModuleParseError extends WebpackError {
88
91
 
89
92
  super(message);
90
93
 
94
+ /** @type {string} */
91
95
  this.name = "ModuleParseError";
92
96
  this.loc = loc;
93
97
  this.error = err;
@@ -34,7 +34,7 @@ class ModuleProfile {
34
34
  this.storing = 0;
35
35
  this.storingParallelismFactor = 0;
36
36
 
37
- /** @type {{ start: number, end: number }[] | undefined } */
37
+ /** @type {{ start: number, end: number }[] | undefined} */
38
38
  this.additionalFactoryTimes = undefined;
39
39
  this.additionalFactories = 0;
40
40
  this.additionalFactoriesParallelismFactor = 0;
@@ -33,6 +33,7 @@ class ModuleRestoreError extends WebpackError {
33
33
 
34
34
  super(message);
35
35
 
36
+ /** @type {string} */
36
37
  this.name = "ModuleRestoreError";
37
38
  /** @type {string | undefined} */
38
39
  this.details = details;
@@ -41,4 +42,5 @@ class ModuleRestoreError extends WebpackError {
41
42
  }
42
43
  }
43
44
 
45
+ /** @type {typeof ModuleRestoreError} */
44
46
  module.exports = ModuleRestoreError;
@@ -61,17 +61,7 @@ const CONSUME_SHARED_GENERATOR_TYPE = "consume-shared";
61
61
  const UNKNOWN_TYPE = "unknown";
62
62
 
63
63
  /**
64
- * @typedef {JAVASCRIPT_TYPE |
65
- * RUNTIME_TYPE |
66
- * WEBASSEMBLY_TYPE |
67
- * ASSET_TYPE |
68
- * CSS_TYPE |
69
- * CSS_IMPORT_TYPE |
70
- * CSS_URL_TYPE |
71
- * SHARED_INIT_TYPE |
72
- * REMOTE_GENERATOR_TYPE |
73
- * CONSUME_SHARED_GENERATOR_TYPE |
74
- * UNKNOWN_TYPE} AllTypes
64
+ * @typedef {JAVASCRIPT_TYPE | RUNTIME_TYPE | WEBASSEMBLY_TYPE | ASSET_TYPE | CSS_TYPE | CSS_IMPORT_TYPE | CSS_URL_TYPE | SHARED_INIT_TYPE | REMOTE_GENERATOR_TYPE | CONSUME_SHARED_GENERATOR_TYPE | UNKNOWN_TYPE} AllTypes
75
65
  */
76
66
 
77
67
  /**
@@ -33,6 +33,7 @@ class ModuleStoreError extends WebpackError {
33
33
 
34
34
  super(message);
35
35
 
36
+ /** @type {string} */
36
37
  this.name = "ModuleStoreError";
37
38
  this.details = /** @type {string | undefined} */ (details);
38
39
  this.module = module;
@@ -40,4 +41,5 @@ class ModuleStoreError extends WebpackError {
40
41
  }
41
42
  }
42
43
 
44
+ /** @type {typeof ModuleStoreError} */
43
45
  module.exports = ModuleStoreError;
@@ -15,7 +15,7 @@ const makeSerializable = require("./util/makeSerializable");
15
15
  class ModuleWarning extends WebpackError {
16
16
  /**
17
17
  * @param {Error} warning error thrown
18
- * @param {{from?: string | null}} info additional info
18
+ * @param {{ from?: string | null }} info additional info
19
19
  */
20
20
  constructor(warning, { from = null } = {}) {
21
21
  let message = "Module Warning";
@@ -30,6 +30,7 @@ class ModuleWarning extends WebpackError {
30
30
 
31
31
  super(message);
32
32
 
33
+ /** @type {string} */
33
34
  this.name = "ModuleWarning";
34
35
  this.warning = warning;
35
36
  this.details =
@@ -63,4 +64,5 @@ class ModuleWarning extends WebpackError {
63
64
 
64
65
  makeSerializable(ModuleWarning, "webpack/lib/ModuleWarning");
65
66
 
67
+ /** @type {typeof ModuleWarning} */
66
68
  module.exports = ModuleWarning;
@@ -137,10 +137,11 @@ module.exports = class MultiCompiler {
137
137
  compilation.warnings.push(warning);
138
138
  });
139
139
  };
140
+ /** @type {Set<string>} */
140
141
  const cacheNames = new Set();
141
142
  for (const compiler of this.compilers) {
142
143
  if (compiler.options.cache && "name" in compiler.options.cache) {
143
- const name = compiler.options.cache.name;
144
+ const name = /** @type {string} */ (compiler.options.cache.name);
144
145
  if (cacheNames.has(name)) {
145
146
  addWarning(
146
147
  compiler,
@@ -255,7 +256,7 @@ module.exports = class MultiCompiler {
255
256
  * @returns {boolean} true if the dependencies are valid
256
257
  */
257
258
  validateDependencies(callback) {
258
- /** @type {Set<{source: Compiler, target: Compiler}>} */
259
+ /** @type {Set<{ source: Compiler, target: Compiler }>} */
259
260
  const edges = new Set();
260
261
  /** @type {string[]} */
261
262
  const missing = [];
@@ -272,8 +273,8 @@ module.exports = class MultiCompiler {
272
273
  return false;
273
274
  };
274
275
  /**
275
- * @param {{source: Compiler, target: Compiler}} e1 edge 1
276
- * @param {{source: Compiler, target: Compiler}} e2 edge 2
276
+ * @param {{ source: Compiler, target: Compiler }} e1 edge 1
277
+ * @param {{ source: Compiler, target: Compiler }} e2 edge 2
277
278
  * @returns {number} result
278
279
  */
279
280
  const sortEdges = (e1, e2) =>
@@ -339,6 +340,7 @@ module.exports = class MultiCompiler {
339
340
  * @returns {void}
340
341
  */
341
342
  runWithDependencies(compilers, fn, callback) {
343
+ /** @type {Set<string>} */
342
344
  const fulfilledNames = new Set();
343
345
  let remainingCompilers = compilers;
344
346
  /**
@@ -350,6 +352,7 @@ module.exports = class MultiCompiler {
350
352
  * @returns {Compiler[]} compilers
351
353
  */
352
354
  const getReadyCompilers = () => {
355
+ /** @type {Compiler[]} */
353
356
  const readyCompilers = [];
354
357
  const list = remainingCompilers;
355
358
  remainingCompilers = [];
@@ -376,12 +379,12 @@ module.exports = class MultiCompiler {
376
379
  (compiler, callback) => {
377
380
  fn(compiler, (err) => {
378
381
  if (err) return callback(err);
379
- fulfilledNames.add(compiler.name);
382
+ fulfilledNames.add(/** @type {string} */ (compiler.name));
380
383
  runCompilers(callback);
381
384
  });
382
385
  },
383
386
  (err, results) => {
384
- callback(err, results);
387
+ callback(/** @type {Error | null} */ (err), results);
385
388
  }
386
389
  );
387
390
  };
@@ -567,6 +570,7 @@ module.exports = class MultiCompiler {
567
570
  running === 0 &&
568
571
  nodes.every((node) => node.state === "done")
569
572
  ) {
573
+ /** @type {Stats[]} */
570
574
  const stats = [];
571
575
  for (const node of nodes) {
572
576
  const result = node.result;
@@ -667,7 +671,7 @@ module.exports = class MultiCompiler {
667
671
  compiler.close(callback);
668
672
  },
669
673
  (error) => {
670
- callback(error);
674
+ callback(/** @type {Error | null} */ (error));
671
675
  }
672
676
  );
673
677
  }
package/lib/MultiStats.js CHANGED
@@ -8,6 +8,7 @@
8
8
  const identifierUtils = require("./util/identifier");
9
9
 
10
10
  /** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
11
+ /** @typedef {import("../declarations/WebpackOptions").StatsValue} StatsValue */
11
12
  /** @typedef {import("./Compilation").CreateStatsOptionsContext} CreateStatsOptionsContext */
12
13
  /** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
13
14
  /** @typedef {import("./Stats")} Stats */
@@ -25,8 +26,7 @@ const indent = (str, prefix) => {
25
26
  return prefix + rem;
26
27
  };
27
28
 
28
- /** @typedef {undefined | string | boolean | StatsOptions} ChildrenStatsOptions */
29
- /** @typedef {Omit<StatsOptions, "children"> & { children?: ChildrenStatsOptions | ChildrenStatsOptions[] }} MultiStatsOptions */
29
+ /** @typedef {StatsOptions} MultiStatsOptions */
30
30
  /** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */
31
31
 
32
32
  class MultiStats {
@@ -56,7 +56,7 @@ class MultiStats {
56
56
  }
57
57
 
58
58
  /**
59
- * @param {undefined | string | boolean | MultiStatsOptions} options stats options
59
+ * @param {undefined | StatsValue} options stats options
60
60
  * @param {CreateStatsOptionsContext} context context
61
61
  * @returns {ChildOptions} context context
62
62
  */
@@ -109,7 +109,7 @@ class MultiStats {
109
109
  }
110
110
 
111
111
  /**
112
- * @param {(string | boolean | MultiStatsOptions)=} options stats options
112
+ * @param {StatsValue=} options stats options
113
113
  * @returns {StatsCompilation} json output
114
114
  */
115
115
  toJson(options) {
@@ -184,7 +184,7 @@ class MultiStats {
184
184
  }
185
185
 
186
186
  /**
187
- * @param {(string | boolean | MultiStatsOptions)=} options stats options
187
+ * @param {StatsValue=} options stats options
188
188
  * @returns {string} string output
189
189
  */
190
190
  toString(options) {
@@ -31,7 +31,7 @@ class MultiWatching {
31
31
  this.watchings,
32
32
  (watching, callback) => watching.invalidate(callback),
33
33
  (err) => {
34
- callback(err);
34
+ callback(/** @type {Error | null} */ (err));
35
35
  }
36
36
  );
37
37
  } else {
@@ -67,7 +67,7 @@ class MultiWatching {
67
67
  this.compiler.hooks.watchClose.call();
68
68
  if (typeof callback === "function") {
69
69
  this.compiler.running = false;
70
- callback(err);
70
+ callback(/** @type {Error | null} */ (err));
71
71
  }
72
72
  }
73
73
  );
@@ -11,6 +11,7 @@ module.exports = class NoModeWarning extends WebpackError {
11
11
  constructor() {
12
12
  super();
13
13
 
14
+ /** @type {string} */
14
15
  this.name = "NoModeWarning";
15
16
  this.message =
16
17
  "configuration\n" +
@@ -24,6 +24,7 @@ class NodeStuffInWebError extends WebpackError {
24
24
  ${description}`
25
25
  );
26
26
 
27
+ /** @type {string} */
27
28
  this.name = "NodeStuffInWebError";
28
29
  this.loc = loc;
29
30
  }