webpack 5.104.1 → 5.105.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 (279) hide show
  1. package/bin/webpack.js +6 -3
  2. package/lib/APIPlugin.js +85 -15
  3. package/lib/AbstractMethodError.js +1 -0
  4. package/lib/AsyncDependenciesBlock.js +13 -1
  5. package/lib/AsyncDependencyToInitialChunkError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -1
  7. package/lib/BannerPlugin.js +2 -0
  8. package/lib/CacheFacade.js +2 -2
  9. package/lib/CaseSensitiveModulesWarning.js +1 -0
  10. package/lib/Chunk.js +8 -4
  11. package/lib/ChunkGraph.js +30 -9
  12. package/lib/ChunkGroup.js +6 -3
  13. package/lib/ChunkRenderError.js +2 -0
  14. package/lib/CleanPlugin.js +4 -1
  15. package/lib/CodeGenerationError.js +7 -1
  16. package/lib/CodeGenerationResults.js +10 -3
  17. package/lib/CommentCompilationWarning.js +2 -1
  18. package/lib/Compilation.js +280 -236
  19. package/lib/Compiler.js +3 -2
  20. package/lib/ConcatenationScope.js +2 -1
  21. package/lib/ConcurrentCompilationError.js +3 -3
  22. package/lib/ContextModule.js +248 -111
  23. package/lib/ContextModuleFactory.js +14 -2
  24. package/lib/DefinePlugin.js +3 -1
  25. package/lib/DelegatedModule.js +6 -0
  26. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  27. package/lib/Dependency.js +6 -1
  28. package/lib/DependencyTemplates.js +3 -2
  29. package/lib/DllModule.js +2 -0
  30. package/lib/DllReferencePlugin.js +1 -0
  31. package/lib/DotenvPlugin.js +11 -5
  32. package/lib/DynamicEntryPlugin.js +1 -0
  33. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  34. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  35. package/lib/ExportsInfo.js +8 -4
  36. package/lib/ExternalModule.js +16 -0
  37. package/lib/FalseIIFEUmdWarning.js +1 -0
  38. package/lib/FileSystemInfo.js +49 -25
  39. package/lib/FlagDependencyExportsPlugin.js +8 -1
  40. package/lib/FlagDependencyUsagePlugin.js +9 -7
  41. package/lib/HarmonyLinkingError.js +1 -0
  42. package/lib/HookWebpackError.js +2 -0
  43. package/lib/HotModuleReplacementPlugin.js +16 -2
  44. package/lib/InitFragment.js +1 -0
  45. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  46. package/lib/LibManifestPlugin.js +1 -0
  47. package/lib/ManifestPlugin.js +4 -1
  48. package/lib/Module.js +7 -4
  49. package/lib/ModuleBuildError.js +3 -1
  50. package/lib/ModuleDependencyError.js +1 -0
  51. package/lib/ModuleDependencyWarning.js +1 -0
  52. package/lib/ModuleError.js +2 -1
  53. package/lib/ModuleFilenameHelpers.js +2 -1
  54. package/lib/ModuleGraph.js +3 -0
  55. package/lib/ModuleGraphConnection.js +10 -1
  56. package/lib/ModuleHashingError.js +2 -0
  57. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  58. package/lib/ModuleNotFoundError.js +1 -0
  59. package/lib/ModuleParseError.js +5 -1
  60. package/lib/ModuleProfile.js +1 -1
  61. package/lib/ModuleRestoreError.js +2 -0
  62. package/lib/ModuleSourceTypeConstants.js +1 -11
  63. package/lib/ModuleStoreError.js +2 -0
  64. package/lib/ModuleWarning.js +3 -1
  65. package/lib/MultiCompiler.js +11 -7
  66. package/lib/MultiWatching.js +2 -2
  67. package/lib/NoModeWarning.js +1 -0
  68. package/lib/NodeStuffInWebError.js +1 -0
  69. package/lib/NormalModule.js +26 -5
  70. package/lib/NormalModuleFactory.js +20 -4
  71. package/lib/OptionsApply.js +3 -1
  72. package/lib/ProgressPlugin.js +4 -0
  73. package/lib/RawModule.js +2 -0
  74. package/lib/RuntimeModule.js +10 -0
  75. package/lib/RuntimePlugin.js +7 -9
  76. package/lib/RuntimeTemplate.js +14 -7
  77. package/lib/SourceMapDevToolPlugin.js +30 -23
  78. package/lib/Template.js +10 -5
  79. package/lib/TemplatedPathPlugin.js +4 -2
  80. package/lib/UnhandledSchemeError.js +1 -0
  81. package/lib/UnsupportedFeatureWarning.js +1 -0
  82. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  83. package/lib/WatchIgnorePlugin.js +1 -1
  84. package/lib/Watching.js +5 -0
  85. package/lib/WebpackError.js +4 -0
  86. package/lib/WebpackOptionsApply.js +60 -40
  87. package/lib/asset/AssetBytesGenerator.js +1 -0
  88. package/lib/asset/AssetGenerator.js +9 -3
  89. package/lib/asset/AssetModulesPlugin.js +33 -2
  90. package/lib/asset/AssetSourceGenerator.js +1 -0
  91. package/lib/asset/RawDataUrlModule.js +4 -0
  92. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  93. package/lib/buildChunkGraph.js +31 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  95. package/lib/cache/PackFileCacheStrategy.js +41 -8
  96. package/lib/cache/getLazyHashedEtag.js +13 -4
  97. package/lib/cache/mergeEtags.js +3 -1
  98. package/lib/cli.js +3 -1
  99. package/lib/config/defaults.js +65 -44
  100. package/lib/config/normalization.js +96 -0
  101. package/lib/container/ContainerEntryModule.js +4 -0
  102. package/lib/container/FallbackModule.js +2 -0
  103. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  104. package/lib/container/RemoteModule.js +19 -0
  105. package/lib/css/CssGenerator.js +31 -4
  106. package/lib/css/CssModulesPlugin.js +26 -30
  107. package/lib/css/CssParser.js +12 -9
  108. package/lib/debug/ProfilingPlugin.js +1 -0
  109. package/lib/dependencies/AMDDefineDependency.js +3 -1
  110. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  111. package/lib/dependencies/AMDPlugin.js +1 -1
  112. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  113. package/lib/dependencies/CachedConstDependency.js +1 -0
  114. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  115. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  116. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  117. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  118. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  119. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  120. package/lib/dependencies/ConstDependency.js +1 -0
  121. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  122. package/lib/dependencies/ContextElementDependency.js +1 -0
  123. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  124. package/lib/dependencies/CssIcssExportDependency.js +5 -4
  125. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  126. package/lib/dependencies/CssUrlDependency.js +2 -3
  127. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  128. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  129. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  130. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
  131. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  133. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  134. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  135. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
  136. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  137. package/lib/dependencies/ImportDependency.js +1 -0
  138. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  139. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  140. package/lib/dependencies/ImportParserPlugin.js +7 -12
  141. package/lib/dependencies/LoaderPlugin.js +3 -0
  142. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  143. package/lib/dependencies/ModuleDependency.js +1 -0
  144. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  145. package/lib/dependencies/ProvidedDependency.js +1 -0
  146. package/lib/dependencies/RequireContextPlugin.js +1 -0
  147. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  148. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  149. package/lib/dependencies/WorkerDependency.js +9 -3
  150. package/lib/dependencies/WorkerPlugin.js +1 -0
  151. package/lib/dependencies/getFunctionExpression.js +3 -1
  152. package/lib/errors/BuildCycleError.js +4 -1
  153. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  154. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  155. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  156. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  157. package/lib/hmr/lazyCompilationBackend.js +3 -2
  158. package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
  159. package/lib/ids/IdHelpers.js +10 -8
  160. package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
  161. package/lib/ids/SyncModuleIdsPlugin.js +5 -1
  162. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  163. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  164. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  165. package/lib/javascript/JavascriptParser.js +47 -14
  166. package/lib/json/JsonParser.js +6 -0
  167. package/lib/library/AbstractLibraryPlugin.js +4 -1
  168. package/lib/library/AmdLibraryPlugin.js +2 -1
  169. package/lib/library/AssignLibraryPlugin.js +6 -2
  170. package/lib/library/EnableLibraryPlugin.js +1 -0
  171. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  172. package/lib/library/JsonpLibraryPlugin.js +1 -1
  173. package/lib/library/ModuleLibraryPlugin.js +130 -13
  174. package/lib/library/SystemLibraryPlugin.js +4 -1
  175. package/lib/library/UmdLibraryPlugin.js +4 -3
  176. package/lib/logging/createConsoleLogger.js +3 -0
  177. package/lib/logging/truncateArgs.js +1 -1
  178. package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
  179. package/lib/node/NodeTargetPlugin.js +1 -0
  180. package/lib/node/NodeWatchFileSystem.js +3 -0
  181. package/lib/node/nodeConsole.js +18 -1
  182. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  183. package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
  184. package/lib/optimize/ConcatenatedModule.js +33 -19
  185. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  186. package/lib/optimize/InnerGraph.js +5 -3
  187. package/lib/optimize/InnerGraphPlugin.js +25 -25
  188. package/lib/optimize/MangleExportsPlugin.js +14 -2
  189. package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
  190. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  191. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  192. package/lib/optimize/RealContentHashPlugin.js +35 -27
  193. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  194. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  195. package/lib/optimize/SplitChunksPlugin.js +14 -3
  196. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  197. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  198. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  199. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  200. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  201. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  202. package/lib/rules/RuleSetCompiler.js +2 -0
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  204. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  205. package/lib/runtime/CompatRuntimeModule.js +1 -0
  206. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  207. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  208. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  209. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  210. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  211. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
  212. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  213. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  214. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  215. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  216. package/lib/schemes/HttpUriPlugin.js +27 -7
  217. package/lib/schemes/VirtualUrlPlugin.js +7 -2
  218. package/lib/serialization/BinaryMiddleware.js +4 -0
  219. package/lib/serialization/FileMiddleware.js +9 -4
  220. package/lib/serialization/ObjectMiddleware.js +34 -11
  221. package/lib/serialization/PlainObjectSerializer.js +2 -0
  222. package/lib/sharing/ConsumeSharedModule.js +60 -0
  223. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  224. package/lib/sharing/ProvideSharedModule.js +4 -0
  225. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  226. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  227. package/lib/sharing/utils.js +8 -6
  228. package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
  229. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  230. package/lib/stats/StatsFactory.js +2 -2
  231. package/lib/url/URLParserPlugin.js +4 -3
  232. package/lib/util/AppendOnlyStackedSet.js +57 -0
  233. package/lib/util/Hash.js +1 -0
  234. package/lib/util/IterableHelpers.js +1 -0
  235. package/lib/util/LazyBucketSortedSet.js +1 -0
  236. package/lib/util/LazySet.js +1 -0
  237. package/lib/util/ParallelismFactorCalculator.js +1 -0
  238. package/lib/util/SortableSet.js +1 -0
  239. package/lib/util/StringXor.js +1 -0
  240. package/lib/util/binarySearchBounds.js +15 -8
  241. package/lib/util/chainedImports.js +1 -1
  242. package/lib/util/cleverMerge.js +6 -1
  243. package/lib/util/comparators.js +21 -1
  244. package/lib/util/compileBooleanMatcher.js +3 -3
  245. package/lib/util/concatenate.js +3 -2
  246. package/lib/util/conventions.js +3 -2
  247. package/lib/util/deterministicGrouping.js +13 -1
  248. package/lib/util/extractSourceMap.js +12 -13
  249. package/lib/util/fs.js +15 -19
  250. package/lib/util/hash/BatchedHash.js +3 -0
  251. package/lib/util/hash/BulkUpdateHash.js +7 -1
  252. package/lib/util/hash/hash-digest.js +1 -0
  253. package/lib/util/hash/wasm-hash.js +16 -1
  254. package/lib/util/identifier.js +7 -2
  255. package/lib/util/magicComment.js +1 -1
  256. package/lib/util/propertyName.js +1 -1
  257. package/lib/util/registerExternalSerializer.js +1 -0
  258. package/lib/util/runtime.js +15 -1
  259. package/lib/util/semver.js +1 -0
  260. package/lib/util/serialization.js +2 -2
  261. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
  262. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  263. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  264. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  265. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  266. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  267. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  268. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  269. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  270. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  271. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  272. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  273. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  274. package/lib/webpack.js +13 -3
  275. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  276. package/package.json +20 -28
  277. package/schemas/WebpackOptions.check.js +1 -1
  278. package/schemas/WebpackOptions.json +71 -5
  279. package/types.d.ts +339 -93
package/bin/webpack.js CHANGED
@@ -57,9 +57,11 @@ const isInstalled = (packageName) => {
57
57
  } while (dir !== (dir = path.dirname(dir)));
58
58
 
59
59
  // https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274
60
- // eslint-disable-next-line no-warning-comments
61
- // @ts-ignore
62
- for (const internalPath of require("module").globalPaths) {
60
+ const { globalPaths } =
61
+ /** @type {typeof import("module") & { globalPaths: string[] }} */
62
+ (require("module"));
63
+
64
+ for (const internalPath of globalPaths) {
63
65
  try {
64
66
  if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) {
65
67
  return true;
@@ -81,6 +83,7 @@ const runCli = (cli) => {
81
83
 
82
84
  const pkgPath = require.resolve(`${cli.package}/package.json`);
83
85
 
86
+ /** @type {Record<string, EXPECTED_ANY> & { type: string, bin: Record<string, string> }} */
84
87
  const pkg = require(pkgPath);
85
88
 
86
89
  if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
package/lib/APIPlugin.js CHANGED
@@ -16,6 +16,8 @@ const {
16
16
  const RuntimeGlobals = require("./RuntimeGlobals");
17
17
  const WebpackError = require("./WebpackError");
18
18
  const ConstDependency = require("./dependencies/ConstDependency");
19
+ const ModuleInitFragmentDependency = require("./dependencies/ModuleInitFragmentDependency");
20
+ const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency");
19
21
  const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression");
20
22
  const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
21
23
  const {
@@ -32,7 +34,7 @@ const GetFullHashRuntimeModule = require("./runtime/GetFullHashRuntimeModule");
32
34
  /** @typedef {import("./javascript/JavascriptParser").Range} Range */
33
35
 
34
36
  /**
35
- * @returns {Record<string, {expr: string, req: string[] | null, type?: string, assign: boolean}>} replacements
37
+ * @returns {Record<string, { expr: string, req: string[] | null, type?: string, assign: boolean }>} replacements
36
38
  */
37
39
  function getReplacements() {
38
40
  return {
@@ -160,6 +162,10 @@ class APIPlugin {
160
162
  ConstDependency,
161
163
  new ConstDependency.Template()
162
164
  );
165
+ compilation.dependencyTemplates.set(
166
+ ModuleInitFragmentDependency,
167
+ new ModuleInitFragmentDependency.Template()
168
+ );
163
169
 
164
170
  compilation.hooks.runtimeRequirementInTree
165
171
  .for(RuntimeGlobals.chunkName)
@@ -201,6 +207,40 @@ class APIPlugin {
201
207
  * @param {JavascriptParser} parser the parser
202
208
  */
203
209
  const handler = (parser) => {
210
+ parser.hooks.preDeclarator.tap(PLUGIN_NAME, (declarator) => {
211
+ if (
212
+ parser.scope.topLevelScope === true &&
213
+ declarator.id.type === "Identifier" &&
214
+ declarator.id.name === "module"
215
+ ) {
216
+ /** @type {BuildInfo} */
217
+ (parser.state.module.buildInfo).moduleArgument =
218
+ "__webpack_module__";
219
+ }
220
+ });
221
+
222
+ parser.hooks.preStatement.tap(PLUGIN_NAME, (statement) => {
223
+ if (parser.scope.topLevelScope === true) {
224
+ if (
225
+ statement.type === "FunctionDeclaration" &&
226
+ statement.id &&
227
+ statement.id.name === "module"
228
+ ) {
229
+ /** @type {BuildInfo} */
230
+ (parser.state.module.buildInfo).moduleArgument =
231
+ "__webpack_module__";
232
+ } else if (
233
+ statement.type === "ClassDeclaration" &&
234
+ statement.id &&
235
+ statement.id.name === "module"
236
+ ) {
237
+ /** @type {BuildInfo} */
238
+ (parser.state.module.buildInfo).moduleArgument =
239
+ "__webpack_module__";
240
+ }
241
+ }
242
+ });
243
+
204
244
  for (const key of Object.keys(REPLACEMENTS)) {
205
245
  const info = REPLACEMENTS[key];
206
246
  parser.hooks.expression.for(key).tap(PLUGIN_NAME, (expression) => {
@@ -275,13 +315,28 @@ class APIPlugin {
275
315
  /** @type {BuildInfo} */
276
316
  (parser.state.module.buildInfo).moduleConcatenationBailout =
277
317
  "__webpack_module__.id";
278
- const dep = new ConstDependency(
279
- `${parser.state.module.moduleArgument}.id`,
280
- /** @type {Range} */ (expr.range),
281
- [RuntimeGlobals.moduleId]
282
- );
283
- dep.loc = /** @type {DependencyLocation} */ (expr.loc);
284
- parser.state.module.addPresentationalDependency(dep);
318
+ const moduleArgument = parser.state.module.moduleArgument;
319
+ if (moduleArgument === "__webpack_module__") {
320
+ const dep = new RuntimeRequirementsDependency([
321
+ RuntimeGlobals.moduleId
322
+ ]);
323
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
324
+ parser.state.module.addPresentationalDependency(dep);
325
+ } else {
326
+ const initDep = new ModuleInitFragmentDependency(
327
+ `var __webpack_internal_module_id__ = ${moduleArgument}.id;\n`,
328
+ [RuntimeGlobals.moduleId],
329
+ "__webpack_internal_module_id__"
330
+ );
331
+ parser.state.module.addPresentationalDependency(initDep);
332
+ const dep = new ConstDependency(
333
+ "__webpack_internal_module_id__",
334
+ /** @type {Range} */ (expr.range),
335
+ []
336
+ );
337
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
338
+ parser.state.module.addPresentationalDependency(dep);
339
+ }
285
340
  return true;
286
341
  });
287
342
 
@@ -291,13 +346,28 @@ class APIPlugin {
291
346
  /** @type {BuildInfo} */
292
347
  (parser.state.module.buildInfo).moduleConcatenationBailout =
293
348
  "__webpack_module__";
294
- const dep = new ConstDependency(
295
- parser.state.module.moduleArgument,
296
- /** @type {Range} */ (expr.range),
297
- [RuntimeGlobals.module]
298
- );
299
- dep.loc = /** @type {DependencyLocation} */ (expr.loc);
300
- parser.state.module.addPresentationalDependency(dep);
349
+ const moduleArgument = parser.state.module.moduleArgument;
350
+ if (moduleArgument === "__webpack_module__") {
351
+ const dep = new RuntimeRequirementsDependency([
352
+ RuntimeGlobals.module
353
+ ]);
354
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
355
+ parser.state.module.addPresentationalDependency(dep);
356
+ } else {
357
+ const initDep = new ModuleInitFragmentDependency(
358
+ `var __webpack_internal_module__ = ${moduleArgument};\n`,
359
+ [RuntimeGlobals.module],
360
+ "__webpack_internal_module__"
361
+ );
362
+ parser.state.module.addPresentationalDependency(initDep);
363
+ const dep = new ConstDependency(
364
+ "__webpack_internal_module__",
365
+ /** @type {Range} */ (expr.range),
366
+ []
367
+ );
368
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
369
+ parser.state.module.addPresentationalDependency(dep);
370
+ }
301
371
  return true;
302
372
  });
303
373
  parser.hooks.evaluateTypeof
@@ -48,6 +48,7 @@ function Message() {
48
48
  class AbstractMethodError extends WebpackError {
49
49
  constructor() {
50
50
  super(new Message().message);
51
+ /** @type {string} */
51
52
  this.name = "AbstractMethodError";
52
53
  }
53
54
  }
@@ -16,7 +16,7 @@ const makeSerializable = require("./util/makeSerializable");
16
16
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
17
17
  /** @typedef {import("./util/Hash")} Hash */
18
18
 
19
- /** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions }) | string} GroupOptions */
19
+ /** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions } & { circular?: boolean }) | string} GroupOptions */
20
20
 
21
21
  class AsyncDependenciesBlock extends DependenciesBlock {
22
22
  /**
@@ -31,9 +31,14 @@ class AsyncDependenciesBlock extends DependenciesBlock {
31
31
  } else if (!groupOptions) {
32
32
  groupOptions = { name: undefined };
33
33
  }
34
+ if (typeof groupOptions.circular !== "boolean") {
35
+ // default allow circular references
36
+ groupOptions.circular = true;
37
+ }
34
38
  this.groupOptions = groupOptions;
35
39
  this.loc = loc;
36
40
  this.request = request;
41
+ /** @type {undefined | string} */
37
42
  this._stringifiedGroupOptions = undefined;
38
43
  }
39
44
 
@@ -55,6 +60,13 @@ class AsyncDependenciesBlock extends DependenciesBlock {
55
60
  }
56
61
  }
57
62
 
63
+ /**
64
+ * @returns {boolean} Whether circular references are allowed
65
+ */
66
+ get circular() {
67
+ return Boolean(this.groupOptions.circular);
68
+ }
69
+
58
70
  /**
59
71
  * @param {Hash} hash the hash used to track dependencies
60
72
  * @param {UpdateHashContext} context context
@@ -22,6 +22,7 @@ class AsyncDependencyToInitialChunkError extends WebpackError {
22
22
  `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`
23
23
  );
24
24
 
25
+ /** @type {string} */
25
26
  this.name = "AsyncDependencyToInitialChunkError";
26
27
  this.module = module;
27
28
  this.loc = loc;
@@ -29,7 +29,7 @@ class AutomaticPrefetchPlugin {
29
29
  );
30
30
  }
31
31
  );
32
- /** @type {{context: string | null, request: string}[] | null} */
32
+ /** @type {{ context: string | null, request: string }[] | null} */
33
33
  let lastModules = null;
34
34
  compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => {
35
35
  lastModules = [];
@@ -11,6 +11,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
11
11
  const Template = require("./Template");
12
12
  const createSchemaValidation = require("./util/create-schema-validation");
13
13
 
14
+ /** @typedef {import("webpack-sources").Source} Source */
14
15
  /** @typedef {import("../declarations/plugins/BannerPlugin").BannerFunction} BannerFunction */
15
16
  /** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
16
17
  /** @typedef {import("./Compilation").PathData} PathData */
@@ -88,6 +89,7 @@ class BannerPlugin {
88
89
  undefined,
89
90
  options
90
91
  );
92
+ /** @type {WeakMap<Source, { source: ConcatSource, comment: string }>} */
91
93
  const cache = new WeakMap();
92
94
  const stage =
93
95
  this.options.stage || Compilation.PROCESS_ASSETS_STAGE_ADDITIONS;
@@ -13,7 +13,7 @@ const mergeEtags = require("./cache/mergeEtags");
13
13
  /** @typedef {import("./Cache")} Cache */
14
14
  /** @typedef {import("./Cache").Etag} Etag */
15
15
  /** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
16
- /** @typedef {typeof import("./util/Hash")} HashConstructor */
16
+ /** @typedef {import("./util/Hash").HashFunction} HashFunction */
17
17
 
18
18
  /**
19
19
  * @template T
@@ -196,7 +196,7 @@ class CacheFacade {
196
196
  /**
197
197
  * @param {Cache} cache the root cache
198
198
  * @param {string} name the child cache name
199
- * @param {(string | HashConstructor)=} hashFunction the hash function to use
199
+ * @param {HashFunction=} hashFunction the hash function to use
200
200
  */
201
201
  constructor(cache, name, hashFunction) {
202
202
  this._cache = cache;
@@ -63,6 +63,7 @@ This can lead to unexpected behavior when compiling on a filesystem with other c
63
63
  Use equal casing. Compare these module identifiers:
64
64
  ${modulesList}`);
65
65
 
66
+ /** @type {string} */
66
67
  this.name = "CaseSensitiveModulesWarning";
67
68
  this.module = sortedModules[0];
68
69
  }
package/lib/Chunk.js CHANGED
@@ -719,7 +719,7 @@ class Chunk {
719
719
  * @returns {Record<string, ChunkId[]>} a record object of names to lists of child ids(?)
720
720
  */
721
721
  getChildIdsByOrders(chunkGraph, filterFn) {
722
- /** @type {Map<string, {order: number, group: ChunkGroup}[]>} */
722
+ /** @type {Map<string, { order: number, group: ChunkGroup }[]>} */
723
723
  const lists = new Map();
724
724
  for (const group of this.groupsIterable) {
725
725
  if (group.chunks[group.chunks.length - 1] === this) {
@@ -777,11 +777,13 @@ class Chunk {
777
777
  * @returns {{ onChunks: Chunk[], chunks: Chunks }[] | undefined} referenced chunks for a specific type
778
778
  */
779
779
  getChildrenOfTypeInOrder(chunkGraph, type) {
780
+ /** @type {{ order: number, group: ChunkGroup, childGroup: ChunkGroup }[]} */
780
781
  const list = [];
781
782
  for (const group of this.groupsIterable) {
782
783
  for (const childGroup of group.childrenIterable) {
783
784
  const order =
784
- childGroup.options[/** @type {keyof ChunkGroupOptions} */ (type)];
785
+ /** @type {number} */
786
+ (childGroup.options[/** @type {keyof ChunkGroupOptions} */ (type)]);
785
787
  if (order === undefined) continue;
786
788
  list.push({
787
789
  order,
@@ -792,12 +794,14 @@ class Chunk {
792
794
  }
793
795
  if (list.length === 0) return;
794
796
  list.sort((a, b) => {
795
- const cmp =
796
- /** @type {number} */ (b.order) - /** @type {number} */ (a.order);
797
+ const cmp = b.order - a.order;
797
798
  if (cmp !== 0) return cmp;
798
799
  return a.group.compareTo(chunkGraph, b.group);
799
800
  });
801
+ /** @typedef {{ onChunks: Chunk[], chunks: Chunks }} Entry */
802
+ /** @type {Entry[]} */
800
803
  const result = [];
804
+ /** @type {undefined | Entry} */
801
805
  let lastEntry;
802
806
  for (const { group, childGroup } of list) {
803
807
  if (lastEntry && lastEntry.onChunks === group.chunks) {
package/lib/ChunkGraph.js CHANGED
@@ -43,7 +43,7 @@ const {
43
43
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
44
44
  /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
45
45
  /** @typedef {import("./RuntimeModule")} RuntimeModule */
46
- /** @typedef {typeof import("./util/Hash")} Hash */
46
+ /** @typedef {import("./util/Hash").HashFunction} HashFunction */
47
47
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
48
48
 
49
49
  /** @type {ReadonlySet<string>} */
@@ -69,7 +69,9 @@ class ModuleHashInfo {
69
69
  * @param {string} renderedHash rendered hash
70
70
  */
71
71
  constructor(hash, renderedHash) {
72
+ /** @type {string} */
72
73
  this.hash = hash;
74
+ /** @type {string} */
73
75
  this.renderedHash = renderedHash;
74
76
  }
75
77
  }
@@ -95,10 +97,11 @@ const getModuleRuntimes = (chunks) => {
95
97
 
96
98
  /**
97
99
  * @param {SourceTypesByModule | undefined} sourceTypesByModule sourceTypesByModule
98
- * @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type
100
+ * @returns {ModulesBySourceType} modules by source type
99
101
  */
100
102
  const modulesBySourceType = (sourceTypesByModule) => (set) => {
101
- /** @type {Map<SourceType, SortableSet<Module>>} */
103
+ /** @typedef {SortableSet<Module>} ModuleSortableSet */
104
+ /** @type {Map<SourceType, ModuleSortableSet>} */
102
105
  const map = new Map();
103
106
  for (const module of set) {
104
107
  const sourceTypes =
@@ -107,6 +110,7 @@ const modulesBySourceType = (sourceTypesByModule) => (set) => {
107
110
  for (const sourceType of sourceTypes) {
108
111
  let innerSet = map.get(sourceType);
109
112
  if (innerSet === undefined) {
113
+ /** @type {ModuleSortableSet} */
110
114
  innerSet = new SortableSet();
111
115
  map.set(sourceType, innerSet);
112
116
  }
@@ -122,6 +126,10 @@ const modulesBySourceType = (sourceTypesByModule) => (set) => {
122
126
  }
123
127
  return map;
124
128
  };
129
+
130
+ /** @typedef {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} ModulesBySourceType */
131
+
132
+ /** @type {ModulesBySourceType} */
125
133
  const defaultModulesBySourceType = modulesBySourceType(undefined);
126
134
 
127
135
  /**
@@ -164,11 +172,14 @@ const getModulesSize = (modules) => {
164
172
  return size;
165
173
  };
166
174
 
175
+ /** @typedef {Record<string, number>} SizesOfModules */
176
+
167
177
  /**
168
178
  * @param {Iterable<Module>} modules the sortable Set to get the size of
169
- * @returns {Record<string, number>} the sizes of the modules
179
+ * @returns {SizesOfModules} the sizes of the modules
170
180
  */
171
181
  const getModulesSizes = (modules) => {
182
+ /** @type {SizesOfModules} */
172
183
  const sizes = Object.create(null);
173
184
  for (const module of modules) {
174
185
  for (const type of module.getSourceTypes()) {
@@ -199,6 +210,7 @@ const isAvailableChunk = (a, b) => {
199
210
  /** @typedef {Set<Chunk>} EntryInChunks */
200
211
  /** @typedef {Set<Chunk>} RuntimeInChunks */
201
212
  /** @typedef {string | number} ModuleId */
213
+ /** @typedef {RuntimeSpecMap<Set<string>, RuntimeRequirements>} ChunkGraphRuntimeRequirements */
202
214
 
203
215
  class ChunkGraphModule {
204
216
  constructor() {
@@ -212,7 +224,7 @@ class ChunkGraphModule {
212
224
  this.hashes = undefined;
213
225
  /** @type {ModuleId | null} */
214
226
  this.id = null;
215
- /** @type {RuntimeSpecMap<Set<string>, RuntimeRequirements> | undefined} */
227
+ /** @type {ChunkGraphRuntimeRequirements | undefined} */
216
228
  this.runtimeRequirements = undefined;
217
229
  /** @type {RuntimeSpecMap<string, bigint> | undefined} */
218
230
  this.graphHashes = undefined;
@@ -242,7 +254,7 @@ class ChunkGraphChunk {
242
254
  this.runtimeRequirements = undefined;
243
255
  /** @type {Set<string>} */
244
256
  this.runtimeRequirementsInTree = new Set();
245
-
257
+ /** @type {ModulesBySourceType} */
246
258
  this._modulesBySourceType = defaultModulesBySourceType;
247
259
  }
248
260
  }
@@ -251,13 +263,14 @@ class ChunkGraphChunk {
251
263
  /** @typedef {Record<ModuleId, string>} IdToHashMap */
252
264
  /** @typedef {Record<ChunkId, IdToHashMap>} ChunkModuleHashMap */
253
265
  /** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIdMap */
266
+ /** @typedef {Record<ChunkId, boolean>} ChunkConditionMap */
254
267
 
255
268
  /** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */
256
269
 
257
270
  class ChunkGraph {
258
271
  /**
259
272
  * @param {ModuleGraph} moduleGraph the module graph
260
- * @param {string | Hash} hashFunction the hash function to use
273
+ * @param {HashFunction} hashFunction the hash function to use
261
274
  */
262
275
  constructor(moduleGraph, hashFunction = DEFAULTS.HASH_FUNCTION) {
263
276
  /**
@@ -809,6 +822,7 @@ class ChunkGraph {
809
822
  )) {
810
823
  if (filterFn(module)) {
811
824
  if (idToHashMap === undefined) {
825
+ /** @type {IdToHashMap} */
812
826
  idToHashMap = Object.create(null);
813
827
  chunkModuleHashMap[/** @type {ChunkId} */ (asyncChunk.id)] =
814
828
  /** @type {IdToHashMap} */
@@ -830,9 +844,10 @@ class ChunkGraph {
830
844
  /**
831
845
  * @param {Chunk} chunk the chunk
832
846
  * @param {ChunkFilterPredicate} filterFn function used to filter chunks
833
- * @returns {Record<ChunkId, boolean>} chunk map
847
+ * @returns {ChunkConditionMap} chunk condition map
834
848
  */
835
849
  getChunkConditionMap(chunk, filterFn) {
850
+ /** @type {ChunkConditionMap} */
836
851
  const map = Object.create(null);
837
852
  for (const c of chunk.getAllReferencedChunks()) {
838
853
  map[/** @type {ChunkId} */ (c.id)] = filterFn(c, this);
@@ -848,6 +863,7 @@ class ChunkGraph {
848
863
  */
849
864
  hasModuleInGraph(chunk, filterFn, filterChunkFn) {
850
865
  const queue = new Set(chunk.groupsIterable);
866
+ /** @type {Set<Chunk>} */
851
867
  const chunksProcessed = new Set();
852
868
 
853
869
  for (const chunkGroup of queue) {
@@ -1556,6 +1572,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
1556
1572
  const cgm = this._getChunkGraphModule(module);
1557
1573
  const runtimeRequirementsMap = cgm.runtimeRequirements;
1558
1574
  if (runtimeRequirementsMap === undefined) {
1575
+ /** @type {ChunkGraphRuntimeRequirements} */
1559
1576
  const map = new RuntimeSpecMap();
1560
1577
  // TODO avoid cloning item and track ownership instead
1561
1578
  map.set(runtime, transferOwnership ? items : new Set(items));
@@ -1740,6 +1757,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
1740
1757
  } else {
1741
1758
  // cspell:word Tnamespace
1742
1759
  for (const connection of connections) {
1760
+ /** @type {Set<ConnectionState>} */
1743
1761
  const states = new Set();
1744
1762
  let stateInfo = "";
1745
1763
  forEachRuntime(
@@ -1754,7 +1772,10 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
1754
1772
  if (states.size === 1) {
1755
1773
  const state = first(states);
1756
1774
  if (state === false) continue;
1757
- stateInfo = activeStateToString(state);
1775
+ stateInfo = activeStateToString(
1776
+ /** @type {ConnectionState} */
1777
+ (state)
1778
+ );
1758
1779
  }
1759
1780
  processConnection(connection, stateInfo);
1760
1781
  }
package/lib/ChunkGroup.js CHANGED
@@ -56,7 +56,7 @@ const sortById = (a, b) => {
56
56
  /**
57
57
  * @param {OriginRecord} a the first comparator in sort
58
58
  * @param {OriginRecord} b the second comparator in sort
59
- * @returns {1 | -1| 0} returns sorting order as index
59
+ * @returns {1 | -1 | 0} returns sorting order as index
60
60
  */
61
61
  const sortOrigin = (a, b) => {
62
62
  const aIdent = a.module ? a.module.identifier() : "";
@@ -79,13 +79,15 @@ class ChunkGroup {
79
79
  }
80
80
  /** @type {number} */
81
81
  this.groupDebugId = debugId++;
82
- this.options = /** @type {ChunkGroupOptions} */ (options);
82
+ /** @type {ChunkGroupOptions} */
83
+ this.options = options;
83
84
  /** @type {SortableSet<ChunkGroup>} */
84
85
  this._children = new SortableSet(undefined, sortById);
85
86
  /** @type {SortableSet<ChunkGroup>} */
86
87
  this._parents = new SortableSet(undefined, sortById);
87
88
  /** @type {SortableSet<ChunkGroup>} */
88
89
  this._asyncEntrypoints = new SortableSet(undefined, sortById);
90
+ /** @type {SortableSet<AsyncDependenciesBlock>} */
89
91
  this._blocks = new SortableSet();
90
92
  /** @type {Chunk[]} */
91
93
  this.chunks = [];
@@ -429,6 +431,7 @@ class ChunkGroup {
429
431
  * @returns {string[]} the files contained this chunk group
430
432
  */
431
433
  getFiles() {
434
+ /** @type {Set<string>} */
432
435
  const files = new Set();
433
436
 
434
437
  for (const chunk of this.chunks) {
@@ -505,7 +508,7 @@ class ChunkGroup {
505
508
  * @returns {Record<string, ChunkGroup[]>} mapping from children type to ordered list of ChunkGroups
506
509
  */
507
510
  getChildrenByOrders(moduleGraph, chunkGraph) {
508
- /** @type {Map<string, {order: number, group: ChunkGroup}[]>} */
511
+ /** @type {Map<string, { order: number, group: ChunkGroup }[]>} */
509
512
  const lists = new Map();
510
513
  for (const childGroup of this._children) {
511
514
  for (const key of Object.keys(childGroup.options)) {
@@ -19,6 +19,7 @@ class ChunkRenderError extends WebpackError {
19
19
  constructor(chunk, file, error) {
20
20
  super();
21
21
 
22
+ /** @type {string} */
22
23
  this.name = "ChunkRenderError";
23
24
  this.error = error;
24
25
  this.message = error.message;
@@ -28,4 +29,5 @@ class ChunkRenderError extends WebpackError {
28
29
  }
29
30
  }
30
31
 
32
+ /** @type {typeof ChunkRenderError} */
31
33
  module.exports = ChunkRenderError;
@@ -70,6 +70,7 @@ const mergeAssets = (as1, as2) => {
70
70
  * @returns {Set<string>} Set of directory paths
71
71
  */
72
72
  function getDirectories(assets) {
73
+ /** @type {Set<string>} */
73
74
  const directories = new Set();
74
75
  /**
75
76
  * @param {string} filename asset filename
@@ -143,6 +144,7 @@ const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
143
144
  * @returns {Diff} diff
144
145
  */
145
146
  const getDiffToOldAssets = (currentAssets, oldAssets) => {
147
+ /** @type {Diff} */
146
148
  const diff = new Set();
147
149
  const now = Date.now();
148
150
  for (const [asset, ts] of oldAssets) {
@@ -416,7 +418,8 @@ class CleanPlugin {
416
418
  const currentAssets = new Map();
417
419
  const now = Date.now();
418
420
  for (const asset of Object.keys(compilation.assets)) {
419
- if (/^[A-Za-z]:\\|^\/|^\\\\/.test(asset)) continue;
421
+ if (/^[a-z]:\\|^\/|^\\\\/i.test(asset)) continue;
422
+ /** @type {string} */
420
423
  let normalizedAsset;
421
424
  let newNormalizedAsset = asset.replace(/\\/g, "/");
422
425
  do {
@@ -18,12 +18,18 @@ class CodeGenerationError extends WebpackError {
18
18
  constructor(module, error) {
19
19
  super();
20
20
 
21
+ /** @type {string} */
21
22
  this.name = "CodeGenerationError";
23
+ /** @type {Module} */
24
+ this.module = module;
25
+ /** @type {Error} */
22
26
  this.error = error;
27
+ /** @type {string} */
23
28
  this.message = error.message;
29
+ /** @type {string} */
24
30
  this.details = error.stack;
25
- this.module = module;
26
31
  }
27
32
  }
28
33
 
34
+ /** @type {typeof CodeGenerationError} */
29
35
  module.exports = CodeGenerationError;
@@ -17,16 +17,17 @@ const { RuntimeSpecMap, runtimeToString } = require("./util/runtime");
17
17
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
18
18
  /** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */
19
19
  /** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
20
- /** @typedef {typeof import("./util/Hash")} Hash */
20
+ /** @typedef {import("./util/Hash").HashFunction} HashFunction */
21
21
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
22
22
 
23
23
  class CodeGenerationResults {
24
24
  /**
25
- * @param {string | Hash} hashFunction the hash function to use
25
+ * @param {HashFunction} hashFunction the hash function to use
26
26
  */
27
27
  constructor(hashFunction = DEFAULTS.HASH_FUNCTION) {
28
28
  /** @type {Map<Module, RuntimeSpecMap<CodeGenerationResult>>} */
29
29
  this.map = new Map();
30
+ /** @type {HashFunction} */
30
31
  this._hashFunction = hashFunction;
31
32
  }
32
33
 
@@ -152,7 +153,13 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
152
153
  * @returns {void}
153
154
  */
154
155
  add(module, runtime, result) {
155
- const map = getOrInsert(this.map, module, () => new RuntimeSpecMap());
156
+ const map = getOrInsert(
157
+ this.map,
158
+ module,
159
+ () =>
160
+ /** @type {RuntimeSpecMap<CodeGenerationResult>} */
161
+ new RuntimeSpecMap()
162
+ );
156
163
  map.set(runtime, result);
157
164
  }
158
165
  }
@@ -18,8 +18,9 @@ class CommentCompilationWarning extends WebpackError {
18
18
  constructor(message, loc) {
19
19
  super(message);
20
20
 
21
+ /** @type {string} */
21
22
  this.name = "CommentCompilationWarning";
22
-
23
+ /** @type {DependencyLocation} */
23
24
  this.loc = loc;
24
25
  }
25
26
  }