webpack 5.98.0 → 5.99.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 (251) hide show
  1. package/README.md +7 -3
  2. package/lib/AsyncDependenciesBlock.js +3 -1
  3. package/lib/BannerPlugin.js +1 -1
  4. package/lib/Cache.js +9 -7
  5. package/lib/CacheFacade.js +5 -5
  6. package/lib/Chunk.js +2 -2
  7. package/lib/ChunkGraph.js +21 -16
  8. package/lib/ChunkTemplate.js +6 -6
  9. package/lib/CleanPlugin.js +10 -10
  10. package/lib/CodeGenerationResults.js +4 -3
  11. package/lib/CompatibilityPlugin.js +4 -1
  12. package/lib/Compilation.js +326 -152
  13. package/lib/Compiler.js +13 -18
  14. package/lib/ConditionalInitFragment.js +1 -1
  15. package/lib/ConstPlugin.js +5 -3
  16. package/lib/ContextModule.js +4 -2
  17. package/lib/ContextModuleFactory.js +3 -3
  18. package/lib/ContextReplacementPlugin.js +43 -16
  19. package/lib/DefinePlugin.js +25 -24
  20. package/lib/DelegatedModule.js +4 -2
  21. package/lib/DelegatedModuleFactoryPlugin.js +2 -1
  22. package/lib/Dependency.js +19 -13
  23. package/lib/DependencyTemplates.js +4 -3
  24. package/lib/DllModule.js +4 -2
  25. package/lib/DllModuleFactory.js +2 -2
  26. package/lib/DllReferencePlugin.js +2 -1
  27. package/lib/DynamicEntryPlugin.js +1 -1
  28. package/lib/EnvironmentPlugin.js +4 -2
  29. package/lib/ExportsInfo.js +72 -40
  30. package/lib/ExternalModule.js +14 -5
  31. package/lib/ExternalModuleFactoryPlugin.js +24 -12
  32. package/lib/FileSystemInfo.js +129 -94
  33. package/lib/FlagDependencyExportsPlugin.js +6 -4
  34. package/lib/FlagDependencyUsagePlugin.js +1 -1
  35. package/lib/Generator.js +29 -1
  36. package/lib/HookWebpackError.js +2 -2
  37. package/lib/HotModuleReplacementPlugin.js +3 -9
  38. package/lib/IgnoreErrorModuleFactory.js +2 -2
  39. package/lib/IgnorePlugin.js +0 -5
  40. package/lib/InitFragment.js +1 -1
  41. package/lib/LoaderOptionsPlugin.js +8 -5
  42. package/lib/MainTemplate.js +7 -7
  43. package/lib/Module.js +40 -17
  44. package/lib/ModuleBuildError.js +3 -1
  45. package/lib/ModuleDependencyError.js +4 -3
  46. package/lib/ModuleDependencyWarning.js +4 -3
  47. package/lib/ModuleFactory.js +9 -3
  48. package/lib/ModuleFilenameHelpers.js +13 -13
  49. package/lib/ModuleGraph.js +20 -14
  50. package/lib/ModuleGraphConnection.js +7 -13
  51. package/lib/ModuleNotFoundError.js +1 -1
  52. package/lib/ModuleParseError.js +2 -1
  53. package/lib/ModuleSourceTypesConstants.js +11 -0
  54. package/lib/ModuleTemplate.js +5 -5
  55. package/lib/ModuleTypeConstants.js +15 -0
  56. package/lib/MultiCompiler.js +4 -4
  57. package/lib/MultiStats.js +1 -1
  58. package/lib/NormalModule.js +101 -54
  59. package/lib/NormalModuleFactory.js +38 -33
  60. package/lib/NormalModuleReplacementPlugin.js +3 -2
  61. package/lib/NullFactory.js +2 -2
  62. package/lib/Parser.js +4 -3
  63. package/lib/ProgressPlugin.js +1 -2
  64. package/lib/RawModule.js +4 -2
  65. package/lib/RecordIdsPlugin.js +6 -2
  66. package/lib/RequestShortener.js +3 -1
  67. package/lib/ResolverFactory.js +12 -9
  68. package/lib/RuntimeModule.js +4 -2
  69. package/lib/RuntimeTemplate.js +2 -1
  70. package/lib/SelfModuleFactory.js +2 -2
  71. package/lib/SourceMapDevToolPlugin.js +0 -8
  72. package/lib/Template.js +6 -5
  73. package/lib/TemplatedPathPlugin.js +15 -12
  74. package/lib/WebpackOptionsApply.js +1 -1
  75. package/lib/asset/AssetGenerator.js +237 -170
  76. package/lib/asset/AssetModulesPlugin.js +50 -8
  77. package/lib/asset/AssetSourceGenerator.js +18 -0
  78. package/lib/asset/RawDataUrlModule.js +4 -2
  79. package/lib/buildChunkGraph.js +14 -4
  80. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  81. package/lib/cache/PackFileCacheStrategy.js +137 -121
  82. package/lib/cache/ResolverCachePlugin.js +15 -7
  83. package/lib/cache/getLazyHashedEtag.js +4 -3
  84. package/lib/cli.js +23 -15
  85. package/lib/config/defaults.js +93 -26
  86. package/lib/config/normalization.js +14 -13
  87. package/lib/config/target.js +8 -8
  88. package/lib/container/ContainerEntryModule.js +4 -2
  89. package/lib/container/ContainerEntryModuleFactory.js +2 -2
  90. package/lib/container/FallbackModule.js +4 -2
  91. package/lib/container/FallbackModuleFactory.js +2 -2
  92. package/lib/container/RemoteModule.js +4 -2
  93. package/lib/container/options.js +5 -5
  94. package/lib/css/CssGenerator.js +71 -9
  95. package/lib/css/CssModulesPlugin.js +30 -5
  96. package/lib/css/CssParser.js +37 -17
  97. package/lib/css/walkCssTokens.js +17 -17
  98. package/lib/debug/ProfilingPlugin.js +98 -38
  99. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
  100. package/lib/dependencies/AMDPlugin.js +5 -2
  101. package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
  102. package/lib/dependencies/AMDRequireContextDependency.js +2 -1
  103. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
  104. package/lib/dependencies/AMDRuntimeModules.js +3 -1
  105. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
  106. package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
  107. package/lib/dependencies/CommonJsImportsParserPlugin.js +8 -7
  108. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
  109. package/lib/dependencies/ContextDependencyHelpers.js +13 -6
  110. package/lib/dependencies/CssIcssExportDependency.js +15 -12
  111. package/lib/dependencies/CssIcssImportDependency.js +4 -1
  112. package/lib/dependencies/CssLocalIdentifierDependency.js +17 -14
  113. package/lib/dependencies/ExportsInfoDependency.js +6 -1
  114. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
  115. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
  116. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
  117. package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
  118. package/lib/dependencies/HarmonyImportDependency.js +8 -6
  119. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
  120. package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
  121. package/lib/dependencies/ImportContextDependency.js +2 -1
  122. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
  123. package/lib/dependencies/JsonExportsDependency.js +24 -8
  124. package/lib/dependencies/LoaderPlugin.js +4 -14
  125. package/lib/dependencies/RequireContextDependency.js +2 -1
  126. package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
  127. package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
  128. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
  129. package/lib/dependencies/RequireResolveContextDependency.js +1 -1
  130. package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
  131. package/lib/dependencies/WorkerDependency.js +6 -3
  132. package/lib/dependencies/WorkerPlugin.js +100 -41
  133. package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
  134. package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
  135. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
  136. package/lib/hmr/LazyCompilationPlugin.js +32 -24
  137. package/lib/hmr/lazyCompilationBackend.js +1 -1
  138. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  139. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  140. package/lib/ids/IdHelpers.js +15 -14
  141. package/lib/ids/SyncModuleIdsPlugin.js +9 -5
  142. package/lib/index.js +5 -5
  143. package/lib/javascript/BasicEvaluatedExpression.js +6 -6
  144. package/lib/javascript/JavascriptGenerator.js +11 -1
  145. package/lib/javascript/JavascriptModulesPlugin.js +51 -31
  146. package/lib/javascript/JavascriptParser.js +272 -188
  147. package/lib/javascript/JavascriptParserHelpers.js +10 -9
  148. package/lib/javascript/StartupHelpers.js +4 -1
  149. package/lib/json/JsonData.js +4 -4
  150. package/lib/json/JsonGenerator.js +54 -22
  151. package/lib/json/JsonModulesPlugin.js +16 -2
  152. package/lib/json/JsonParser.js +8 -4
  153. package/lib/library/AbstractLibraryPlugin.js +7 -3
  154. package/lib/library/AssignLibraryPlugin.js +29 -1
  155. package/lib/library/EnableLibraryPlugin.js +7 -10
  156. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  157. package/lib/library/ModuleLibraryPlugin.js +121 -15
  158. package/lib/logging/Logger.js +2 -2
  159. package/lib/logging/createConsoleLogger.js +4 -4
  160. package/lib/node/NodeEnvironmentPlugin.js +6 -2
  161. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
  162. package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
  163. package/lib/node/nodeConsole.js +3 -1
  164. package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
  165. package/lib/optimize/ConcatenatedModule.js +19 -12
  166. package/lib/optimize/InnerGraph.js +3 -2
  167. package/lib/optimize/InnerGraphPlugin.js +13 -7
  168. package/lib/optimize/LimitChunkCountPlugin.js +20 -0
  169. package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
  170. package/lib/optimize/RealContentHashPlugin.js +8 -4
  171. package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
  172. package/lib/optimize/SplitChunksPlugin.js +87 -65
  173. package/lib/rules/BasicEffectRulePlugin.js +9 -1
  174. package/lib/rules/BasicMatcherRulePlugin.js +15 -4
  175. package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
  176. package/lib/rules/RuleSetCompiler.js +25 -14
  177. package/lib/rules/UseEffectRulePlugin.js +47 -17
  178. package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
  179. package/lib/schemes/HttpUriPlugin.js +38 -17
  180. package/lib/serialization/BinaryMiddleware.js +52 -19
  181. package/lib/serialization/FileMiddleware.js +78 -48
  182. package/lib/serialization/ObjectMiddleware.js +78 -29
  183. package/lib/serialization/PlainObjectSerializer.js +1 -1
  184. package/lib/serialization/Serializer.js +15 -10
  185. package/lib/serialization/SerializerMiddleware.js +80 -41
  186. package/lib/serialization/SingleItemMiddleware.js +10 -7
  187. package/lib/serialization/types.js +1 -1
  188. package/lib/sharing/ConsumeSharedModule.js +4 -2
  189. package/lib/sharing/ProvideSharedModule.js +4 -2
  190. package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
  191. package/lib/sharing/utils.js +2 -2
  192. package/lib/stats/DefaultStatsFactoryPlugin.js +80 -78
  193. package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
  194. package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
  195. package/lib/stats/StatsFactory.js +11 -11
  196. package/lib/stats/StatsPrinter.js +7 -7
  197. package/lib/util/ArrayHelpers.js +2 -4
  198. package/lib/util/ArrayQueue.js +1 -1
  199. package/lib/util/AsyncQueue.js +4 -4
  200. package/lib/util/IterableHelpers.js +1 -1
  201. package/lib/util/LazyBucketSortedSet.js +41 -23
  202. package/lib/util/LazySet.js +3 -2
  203. package/lib/util/MapHelpers.js +1 -1
  204. package/lib/util/ParallelismFactorCalculator.js +1 -1
  205. package/lib/util/Semaphore.js +3 -3
  206. package/lib/util/SetHelpers.js +1 -1
  207. package/lib/util/SortableSet.js +9 -7
  208. package/lib/util/TupleQueue.js +9 -8
  209. package/lib/util/TupleSet.js +2 -2
  210. package/lib/util/WeakTupleMap.js +12 -11
  211. package/lib/util/binarySearchBounds.js +2 -1
  212. package/lib/util/cleverMerge.js +84 -54
  213. package/lib/util/comparators.js +22 -21
  214. package/lib/util/compileBooleanMatcher.js +3 -3
  215. package/lib/util/concatenate.js +6 -4
  216. package/lib/util/create-schema-validation.js +4 -4
  217. package/lib/util/createHash.js +2 -2
  218. package/lib/util/deprecation.js +35 -33
  219. package/lib/util/deterministicGrouping.js +6 -6
  220. package/lib/util/findGraphRoots.js +1 -1
  221. package/lib/util/fs.js +39 -39
  222. package/lib/util/hash/wasm-hash.js +2 -2
  223. package/lib/util/identifier.js +15 -18
  224. package/lib/util/makeSerializable.js +1 -1
  225. package/lib/util/memoize.js +4 -1
  226. package/lib/util/objectToMap.js +3 -2
  227. package/lib/util/processAsyncTree.js +2 -2
  228. package/lib/util/propertyName.js +0 -1
  229. package/lib/util/registerExternalSerializer.js +15 -18
  230. package/lib/util/removeBOM.js +25 -0
  231. package/lib/util/runtime.js +34 -27
  232. package/lib/util/serialization.js +5 -16
  233. package/lib/util/smartGrouping.js +3 -3
  234. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  235. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
  236. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
  237. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
  238. package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
  239. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
  240. package/lib/wasm-sync/WebAssemblyParser.js +9 -4
  241. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
  242. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
  243. package/package.json +19 -17
  244. package/schemas/WebpackOptions.check.js +1 -1
  245. package/schemas/WebpackOptions.json +48 -13
  246. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
  247. package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
  248. package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
  249. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  250. package/types.d.ts +918 -615
  251. package/lib/library/ModernModuleLibraryPlugin.js +0 -144
package/lib/Compiler.js CHANGED
@@ -42,7 +42,6 @@ const { isSourceEqual } = require("./util/source");
42
42
  /** @typedef {import("./Chunk")} Chunk */
43
43
  /** @typedef {import("./Compilation").References} References */
44
44
  /** @typedef {import("./Dependency")} Dependency */
45
- /** @typedef {import("./FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
46
45
  /** @typedef {import("./Module")} Module */
47
46
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
48
47
  /** @typedef {import("./config/target").PlatformTargetProperties} PlatformTargetProperties */
@@ -51,14 +50,9 @@ const { isSourceEqual } = require("./util/source");
51
50
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
52
51
  /** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
53
52
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
53
+ /** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */
54
54
  /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
55
55
 
56
- /**
57
- * @template {any[]} T
58
- * @template V
59
- * @typedef {import("./util/WeakTupleMap")<T, V>} WeakTupleMap
60
- */
61
-
62
56
  /**
63
57
  * @typedef {object} CompilationParams
64
58
  * @property {NormalModuleFactory} normalModuleFactory
@@ -96,9 +90,10 @@ const { isSourceEqual } = require("./util/source");
96
90
  */
97
91
 
98
92
  /** @typedef {{ sizeOnlySource: SizeOnlySource | undefined, writtenTo: Map<string, number> }} CacheEntry */
99
- /** @typedef {{ path: string, source: Source, size: number | undefined, waiting: ({ cacheEntry: any, file: string }[] | undefined) }} SimilarEntry */
100
93
 
101
- /** @typedef {{ buildInfo: BuildInfo, references: References | undefined, memCache: WeakTupleMap<any, any> }} ModuleMemCachesItem */
94
+ /** @typedef {{ path: string, source: Source, size: number | undefined, waiting: ({ cacheEntry: CacheEntry, file: string }[] | undefined) }} SimilarEntry */
95
+
96
+ /** @typedef {{ buildInfo: BuildInfo, references: References | undefined, memCache: import("./util/WeakTupleMap")<Module[], string> }} ModuleMemCachesItem */
102
97
 
103
98
  /**
104
99
  * @param {string[]} array an array
@@ -112,13 +107,13 @@ const isSorted = array => {
112
107
  };
113
108
 
114
109
  /**
115
- * @param {{[key: string]: any}} obj an object
116
- * @param {string[]} keys the keys of the object
117
- * @returns {{[key: string]: any}} the object with properties sorted by property name
110
+ * @template {object} T
111
+ * @param {T} obj an object
112
+ * @param {(keyof T)[]} keys the keys of the object
113
+ * @returns {T} the object with properties sorted by property name
118
114
  */
119
115
  const sortObject = (obj, keys) => {
120
- /** @type {{[key: string]: any}} */
121
- const o = {};
116
+ const o = /** @type {T} */ ({});
122
117
  for (const k of keys.sort()) {
123
118
  o[k] = obj[k];
124
119
  }
@@ -203,7 +198,7 @@ class Compiler {
203
198
  /** @type {AsyncSeriesHook<[]>} */
204
199
  shutdown: new AsyncSeriesHook([]),
205
200
 
206
- /** @type {SyncBailHook<[string, string, any[] | undefined], true | void>} */
201
+ /** @type {SyncBailHook<[string, string, EXPECTED_ANY[] | undefined], true | void>} */
207
202
  infrastructureLog: new SyncBailHook(["origin", "type", "args"]),
208
203
 
209
204
  // TODO the following hooks are weirdly located here
@@ -259,9 +254,9 @@ class Compiler {
259
254
  this.modifiedFiles = undefined;
260
255
  /** @type {ReadonlySet<string> | undefined} */
261
256
  this.removedFiles = undefined;
262
- /** @type {ReadonlyMap<string, FileSystemInfoEntry | "ignore" | null> | undefined} */
257
+ /** @type {TimeInfoEntries | undefined} */
263
258
  this.fileTimestamps = undefined;
264
- /** @type {ReadonlyMap<string, FileSystemInfoEntry | "ignore" | null> | undefined} */
259
+ /** @type {TimeInfoEntries | undefined} */
265
260
  this.contextTimestamps = undefined;
266
261
  /** @type {number | undefined} */
267
262
  this.fsStartTime = undefined;
@@ -341,7 +336,7 @@ class Compiler {
341
336
  }
342
337
 
343
338
  /**
344
- * @param {string | (function(): string)} name name of the logger, or function called once to get the logger name
339
+ * @param {string | (() => string)} name name of the logger, or function called once to get the logger name
345
340
  * @returns {Logger} a logger with that name
346
341
  */
347
342
  getInfrastructureLogger(name) {
@@ -78,7 +78,7 @@ class ConditionalInitFragment extends InitFragment {
78
78
 
79
79
  /**
80
80
  * @param {GenerateContext} context context
81
- * @returns {string|Source=} the source code that will be included at the end of the module
81
+ * @returns {string | Source=} the source code that will be included at the end of the module
82
82
  */
83
83
  getEndContent(context) {
84
84
  if (this.runtimeCondition === false || !this.endContent) return "";
@@ -22,6 +22,7 @@ const { parseResource } = require("./util/identifier");
22
22
  /** @typedef {import("estree").SourceLocation} SourceLocation */
23
23
  /** @typedef {import("estree").Statement} Statement */
24
24
  /** @typedef {import("estree").Super} Super */
25
+ /** @typedef {import("estree").VariableDeclaration} VariableDeclaration */
25
26
  /** @typedef {import("./Compiler")} Compiler */
26
27
  /** @typedef {import("./javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
27
28
  /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
@@ -68,7 +69,7 @@ const collectDeclaration = (declarations, pattern) => {
68
69
  */
69
70
  const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
70
71
  const declarations = new Set();
71
- /** @type {Array<TODO | null | undefined>} */
72
+ /** @type {Array<Statement | null | undefined>} */
72
73
  const stack = [branch];
73
74
  while (stack.length > 0) {
74
75
  const node = stack.pop();
@@ -87,12 +88,12 @@ const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
87
88
  stack.push(node.alternate);
88
89
  break;
89
90
  case "ForStatement":
90
- stack.push(node.init);
91
+ stack.push(/** @type {VariableDeclaration} */ (node.init));
91
92
  stack.push(node.body);
92
93
  break;
93
94
  case "ForInStatement":
94
95
  case "ForOfStatement":
95
- stack.push(node.left);
96
+ stack.push(/** @type {VariableDeclaration} */ (node.left));
96
97
  stack.push(node.body);
97
98
  break;
98
99
  case "DoWhileStatement":
@@ -158,6 +159,7 @@ class ConstPlugin {
158
159
  * @param {JavascriptParser} parser the parser
159
160
  */
160
161
  const handler = parser => {
162
+ parser.hooks.terminate.tap(PLUGIN_NAME, statement => true);
161
163
  parser.hooks.statementIf.tap(PLUGIN_NAME, statement => {
162
164
  if (parser.scope.isAsmJs) return;
163
165
  const param = parser.evaluateExpression(statement.test);
@@ -39,11 +39,13 @@ const makeSerializable = require("./util/makeSerializable");
39
39
  /** @typedef {import("./Dependency")} Dependency */
40
40
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
41
41
  /** @typedef {import("./Generator").SourceTypes} SourceTypes */
42
+ /** @typedef {import("./Module").BuildCallback} BuildCallback */
42
43
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
43
44
  /** @typedef {import("./Module").BuildMeta} BuildMeta */
44
45
  /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
45
46
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
46
47
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
48
+ /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
47
49
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
48
50
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
49
51
  /** @typedef {import("./RequestShortener")} RequestShortener */
@@ -399,7 +401,7 @@ class ContextModule extends Module {
399
401
 
400
402
  /**
401
403
  * @param {NeedBuildContext} context context info
402
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
404
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
403
405
  * @returns {void}
404
406
  */
405
407
  needBuild({ fileSystemInfo }, callback) {
@@ -422,7 +424,7 @@ class ContextModule extends Module {
422
424
  * @param {Compilation} compilation the compilation
423
425
  * @param {ResolverWithOptions} resolver the resolver
424
426
  * @param {InputFileSystem} fs the file system
425
- * @param {function(WebpackError=): void} callback callback function
427
+ * @param {BuildCallback} callback callback function
426
428
  * @returns {void}
427
429
  */
428
430
  build(options, compilation, resolver, fs, callback) {
@@ -19,7 +19,7 @@ const { join } = require("./util/fs");
19
19
  /** @typedef {import("./ContextModule").ResolveDependenciesCallback} ResolveDependenciesCallback */
20
20
  /** @typedef {import("./Module")} Module */
21
21
  /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
22
- /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
22
+ /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
23
23
  /** @typedef {import("./ResolverFactory")} ResolverFactory */
24
24
  /** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
25
25
  /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
@@ -86,7 +86,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
86
86
 
87
87
  /**
88
88
  * @param {ModuleFactoryCreateData} data data object
89
- * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
89
+ * @param {ModuleFactoryCallback} callback callback
90
90
  * @returns {void}
91
91
  */
92
92
  create(data, callback) {
@@ -335,7 +335,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
335
335
  /**
336
336
  * @param {string} ctx context
337
337
  * @param {string} directory directory
338
- * @param {function(string, string, function(): void): void} addSubDirectory addSubDirectoryFn
338
+ * @param {(context: string, subResource: string, callback: () => void) => void} addSubDirectory addSubDirectoryFn
339
339
  * @param {ResolveDependenciesCallback} callback callback
340
340
  */
341
341
  const addDirectory = (ctx, directory, addSubDirectory, callback) => {
@@ -9,13 +9,16 @@ const ContextElementDependency = require("./dependencies/ContextElementDependenc
9
9
  const { join } = require("./util/fs");
10
10
 
11
11
  /** @typedef {import("./Compiler")} Compiler */
12
+ /** @typedef {import("./ContextModule").ContextModuleOptions} ContextModuleOptions */
12
13
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
13
14
 
15
+ /** @typedef {Record<string, string>} NewContentCreateContextMap */
16
+
14
17
  class ContextReplacementPlugin {
15
18
  /**
16
19
  * @param {RegExp} resourceRegExp A regular expression that determines which files will be selected
17
- * @param {TODO=} newContentResource A new resource to replace the match
18
- * @param {TODO=} newContentRecursive If true, all subdirectories are searched for matches
20
+ * @param {(string | ((context: TODO) => void) | RegExp | boolean)=} newContentResource A new resource to replace the match
21
+ * @param {(boolean | NewContentCreateContextMap | RegExp)=} newContentRecursive If true, all subdirectories are searched for matches
19
22
  * @param {RegExp=} newContentRegExp A regular expression that determines which files will be selected
20
23
  */
21
24
  constructor(
@@ -26,35 +29,56 @@ class ContextReplacementPlugin {
26
29
  ) {
27
30
  this.resourceRegExp = resourceRegExp;
28
31
 
32
+ // new webpack.ContextReplacementPlugin(/selector/, (context) => { /* Logic */ });
29
33
  if (typeof newContentResource === "function") {
30
34
  this.newContentCallback = newContentResource;
31
- } else if (
35
+ }
36
+ // new ContextReplacementPlugin(/selector/, './folder', { './request': './request' });
37
+ else if (
32
38
  typeof newContentResource === "string" &&
33
39
  typeof newContentRecursive === "object"
34
40
  ) {
35
41
  this.newContentResource = newContentResource;
42
+ /**
43
+ * @param {InputFileSystem} fs input file system
44
+ * @param {(err: null | Error, newContentRecursive: NewContentCreateContextMap) => void} callback callback
45
+ */
36
46
  this.newContentCreateContextMap = (fs, callback) => {
37
- callback(null, newContentRecursive);
47
+ callback(
48
+ null,
49
+ /** @type {NewContentCreateContextMap} */ (newContentRecursive)
50
+ );
38
51
  };
39
- } else if (
52
+ }
53
+ // new ContextReplacementPlugin(/selector/, './folder', (context) => { /* Logic */ });
54
+ else if (
40
55
  typeof newContentResource === "string" &&
41
56
  typeof newContentRecursive === "function"
42
57
  ) {
43
58
  this.newContentResource = newContentResource;
44
59
  this.newContentCreateContextMap = newContentRecursive;
45
60
  } else {
61
+ // new webpack.ContextReplacementPlugin(/selector/, false, /reg-exp/);
46
62
  if (typeof newContentResource !== "string") {
47
- newContentRegExp = newContentRecursive;
48
- newContentRecursive = newContentResource;
63
+ newContentRegExp = /** @type {RegExp} */ (newContentRecursive);
64
+ newContentRecursive = /** @type {boolean} */ (newContentResource);
49
65
  newContentResource = undefined;
50
66
  }
67
+ // new webpack.ContextReplacementPlugin(/selector/, /de|fr|hu/);
51
68
  if (typeof newContentRecursive !== "boolean") {
52
- newContentRegExp = newContentRecursive;
69
+ newContentRegExp = /** @type {RegExp} */ (newContentRecursive);
53
70
  newContentRecursive = undefined;
54
71
  }
55
- this.newContentResource = newContentResource;
56
- this.newContentRecursive = newContentRecursive;
57
- this.newContentRegExp = newContentRegExp;
72
+ // new webpack.ContextReplacementPlugin(/selector/, './folder', false, /selector/);
73
+ this.newContentResource =
74
+ /** @type {string | undefined} */
75
+ (newContentResource);
76
+ this.newContentRecursive =
77
+ /** @type {boolean | undefined} */
78
+ (newContentRecursive);
79
+ this.newContentRegExp =
80
+ /** @type {RegExp | undefined} */
81
+ (newContentRegExp);
58
82
  }
59
83
  }
60
84
 
@@ -150,8 +174,12 @@ class ContextReplacementPlugin {
150
174
  }
151
175
  }
152
176
 
153
- const createResolveDependenciesFromContextMap = createContextMap => {
154
- const resolveDependenciesFromContextMap = (fs, options, callback) => {
177
+ /**
178
+ * @param {(fs: InputFileSystem, callback: (err: null | Error, map: NewContentCreateContextMap) => void) => void} createContextMap create context map function
179
+ * @returns {(fs: InputFileSystem, options: ContextModuleOptions, callback: (err: null | Error, dependencies?: ContextElementDependency[]) => void) => void} resolve resolve dependencies from context map function
180
+ */
181
+ const createResolveDependenciesFromContextMap =
182
+ createContextMap => (fs, options, callback) => {
155
183
  createContextMap(fs, (err, map) => {
156
184
  if (err) return callback(err);
157
185
  const dependencies = Object.keys(map).map(
@@ -159,14 +187,13 @@ const createResolveDependenciesFromContextMap = createContextMap => {
159
187
  new ContextElementDependency(
160
188
  map[key] + options.resourceQuery + options.resourceFragment,
161
189
  key,
162
- options.category,
190
+ options.typePrefix,
191
+ /** @type {string} */ (options.category),
163
192
  options.referencedExports
164
193
  )
165
194
  );
166
195
  callback(null, dependencies);
167
196
  });
168
197
  };
169
- return resolveDependenciesFromContextMap;
170
- };
171
198
 
172
199
  module.exports = ContextReplacementPlugin;
@@ -33,8 +33,8 @@ const createHash = require("./util/createHash");
33
33
  /** @typedef {import("./logging/Logger").Logger} Logger */
34
34
  /** @typedef {import("./util/createHash").Algorithm} Algorithm */
35
35
 
36
- /** @typedef {null|undefined|RegExp|Function|string|number|boolean|bigint|undefined} CodeValuePrimitive */
37
- /** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive|RuntimeValue>} CodeValue */
36
+ /** @typedef {null | undefined | RegExp | EXPECTED_FUNCTION | string | number | boolean | bigint | undefined} CodeValuePrimitive */
37
+ /** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive | RuntimeValue>} CodeValue */
38
38
 
39
39
  /**
40
40
  * @typedef {object} RuntimeValueOptions
@@ -42,11 +42,11 @@ const createHash = require("./util/createHash");
42
42
  * @property {string[]=} contextDependencies
43
43
  * @property {string[]=} missingDependencies
44
44
  * @property {string[]=} buildDependencies
45
- * @property {string|function(): string=} version
45
+ * @property {string| (() => string)=} version
46
46
  */
47
47
 
48
48
  /** @typedef {string | Set<string>} ValueCacheVersion */
49
- /** @typedef {function({ module: NormalModule, key: string, readonly version: ValueCacheVersion }): CodeValuePrimitive} GeneratorFn */
49
+ /** @typedef {(value: { module: NormalModule, key: string, readonly version: ValueCacheVersion }) => CodeValuePrimitive} GeneratorFn */
50
50
 
51
51
  class RuntimeValue {
52
52
  /**
@@ -137,7 +137,7 @@ function getObjKeys(properties) {
137
137
  /** @typedef {boolean | undefined | null} AsiSafe */
138
138
 
139
139
  /**
140
- * @param {any[]|{[k: string]: any}} obj obj
140
+ * @param {EXPECTED_ANY[] | {[k: string]: EXPECTED_ANY}} obj obj
141
141
  * @param {JavascriptParser} parser Parser
142
142
  * @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
143
143
  * @param {string} key the defined key
@@ -160,21 +160,19 @@ const stringifyObj = (
160
160
  let code;
161
161
  const arr = Array.isArray(obj);
162
162
  if (arr) {
163
- code = `[${
164
- /** @type {any[]} */ (obj)
165
- .map(code =>
166
- toCode(
167
- code,
168
- parser,
169
- valueCacheVersions,
170
- key,
171
- runtimeTemplate,
172
- logger,
173
- null
174
- )
163
+ code = `[${obj
164
+ .map(code =>
165
+ toCode(
166
+ code,
167
+ parser,
168
+ valueCacheVersions,
169
+ key,
170
+ runtimeTemplate,
171
+ logger,
172
+ null
175
173
  )
176
- .join(",")
177
- }]`;
174
+ )
175
+ .join(",")}]`;
178
176
  } else {
179
177
  let keys = Object.keys(obj);
180
178
  if (objKeys) {
@@ -182,7 +180,7 @@ const stringifyObj = (
182
180
  }
183
181
  code = `{${keys
184
182
  .map(key => {
185
- const code = /** @type {{[k: string]: any}} */ (obj)[key];
183
+ const code = obj[key];
186
184
  return `${JSON.stringify(key)}:${toCode(
187
185
  code,
188
186
  parser,
@@ -310,7 +308,10 @@ const toCacheVersion = code => {
310
308
  if (typeof code === "object") {
311
309
  const items = Object.keys(code).map(key => ({
312
310
  key,
313
- value: toCacheVersion(/** @type {Record<string, any>} */ (code)[key])
311
+ value: toCacheVersion(
312
+ /** @type {Record<string, EXPECTED_ANY>} */
313
+ (code)[key]
314
+ )
314
315
  }));
315
316
  if (items.some(({ value }) => value === undefined)) return;
316
317
  return `{${items.map(({ key, value }) => `${key}: ${value}`).join(", ")}}`;
@@ -408,10 +409,10 @@ class DefinePlugin {
408
409
  };
409
410
 
410
411
  /**
411
- * @template {Function} T
412
+ * @template T
412
413
  * @param {string} key key
413
- * @param {T} fn fn
414
- * @returns {function(TODO): TODO} result
414
+ * @param {(expression: Expression) => T} fn fn
415
+ * @returns {(expression: Expression) => T} result
415
416
  */
416
417
  const withValueDependency =
417
418
  (key, fn) =>
@@ -22,9 +22,11 @@ const makeSerializable = require("./util/makeSerializable");
22
22
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
23
23
  /** @typedef {import("./Generator").SourceTypes} SourceTypes */
24
24
  /** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
25
+ /** @typedef {import("./Module").BuildCallback} BuildCallback */
25
26
  /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
26
27
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
27
28
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
29
+ /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
28
30
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
29
31
  /** @typedef {import("./Module").SourceContext} SourceContext */
30
32
  /** @typedef {import("./RequestShortener")} RequestShortener */
@@ -106,7 +108,7 @@ class DelegatedModule extends Module {
106
108
 
107
109
  /**
108
110
  * @param {NeedBuildContext} context context info
109
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
111
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
110
112
  * @returns {void}
111
113
  */
112
114
  needBuild(context, callback) {
@@ -118,7 +120,7 @@ class DelegatedModule extends Module {
118
120
  * @param {Compilation} compilation the compilation
119
121
  * @param {ResolverWithOptions} resolver the resolver
120
122
  * @param {InputFileSystem} fs the file system
121
- * @param {function(WebpackError=): void} callback callback function
123
+ * @param {BuildCallback} callback callback function
122
124
  * @returns {void}
123
125
  */
124
126
  build(options, compilation, resolver, fs, callback) {
@@ -13,6 +13,7 @@ const DelegatedModule = require("./DelegatedModule");
13
13
  /** @typedef {import("./DelegatedModule").SourceRequest} SourceRequest */
14
14
  /** @typedef {import("./DelegatedModule").Type} Type */
15
15
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
16
+ /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
16
17
 
17
18
  /**
18
19
  * @typedef {object} Options
@@ -22,7 +23,7 @@ const DelegatedModule = require("./DelegatedModule");
22
23
  * @property {DllReferencePluginOptions["type"]} type type
23
24
  * @property {DllReferencePluginOptions["extensions"]} extensions extensions
24
25
  * @property {DllReferencePluginOptions["scope"]} scope scope
25
- * @property {object=} associatedObjectForCache object for caching
26
+ * @property {AssociatedObjectForCache=} associatedObjectForCache object for caching
26
27
  */
27
28
 
28
29
  class DelegatedModuleFactoryPlugin {
package/lib/Dependency.js CHANGED
@@ -81,7 +81,7 @@ const memoize = require("./util/memoize");
81
81
  * @property {boolean=} canMangle when false, referenced export can not be mangled, defaults to true
82
82
  */
83
83
 
84
- /** @typedef {function(ModuleGraphConnection, RuntimeSpec): ConnectionState} GetConditionFn */
84
+ /** @typedef {(moduleGraphConnection: ModuleGraphConnection, runtime: RuntimeSpec) => ConnectionState} GetConditionFn */
85
85
 
86
86
  const TRANSITIVE = Symbol("transitive");
87
87
 
@@ -132,19 +132,23 @@ class Dependency {
132
132
  get loc() {
133
133
  if (this._loc !== undefined) return this._loc;
134
134
  /** @type {SyntheticDependencyLocation & RealDependencyLocation} */
135
- const loc = {};
135
+ const loc = {
136
+ start: { line: 0, column: 0 },
137
+ end: { line: 0, column: 0 },
138
+ name: "",
139
+ index: -1
140
+ };
136
141
  if (this._locSL > 0) {
137
142
  loc.start = { line: this._locSL, column: this._locSC };
138
143
  }
139
144
  if (this._locEL > 0) {
140
145
  loc.end = { line: this._locEL, column: this._locEC };
141
146
  }
142
- if (this._locN !== undefined) {
143
- loc.name = this._locN;
144
- }
145
- if (this._locI !== undefined) {
146
- loc.index = this._locI;
147
- }
147
+
148
+ loc.name = this._locN;
149
+
150
+ loc.index = this._locI;
151
+
148
152
  return (this._loc = loc);
149
153
  }
150
154
 
@@ -328,12 +332,11 @@ Dependency.NO_EXPORTS_REFERENCED = [];
328
332
  /** @type {string[][]} */
329
333
  Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
330
334
 
331
- // eslint-disable-next-line no-warning-comments
332
- // @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
335
+ // TODO remove in webpack 6
333
336
  Object.defineProperty(Dependency.prototype, "module", {
334
337
  /**
335
338
  * @deprecated
336
- * @returns {never} throws
339
+ * @returns {EXPECTED_ANY} throws
337
340
  */
338
341
  get() {
339
342
  throw new Error(
@@ -352,9 +355,12 @@ Object.defineProperty(Dependency.prototype, "module", {
352
355
  }
353
356
  });
354
357
 
355
- // eslint-disable-next-line no-warning-comments
356
- // @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
358
+ // TODO remove in webpack 6
357
359
  Object.defineProperty(Dependency.prototype, "disconnect", {
360
+ /**
361
+ * @deprecated
362
+ * @returns {EXPECTED_ANY} throws
363
+ */
358
364
  get() {
359
365
  throw new Error(
360
366
  "disconnect was removed from Dependency (Dependency no longer carries graph specific information)"
@@ -5,20 +5,21 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { DEFAULTS } = require("./config/defaults");
8
9
  const createHash = require("./util/createHash");
9
10
 
10
11
  /** @typedef {import("./Dependency")} Dependency */
11
12
  /** @typedef {import("./DependencyTemplate")} DependencyTemplate */
12
13
  /** @typedef {typeof import("./util/Hash")} Hash */
13
14
 
14
- /** @typedef {new (...args: any[]) => Dependency} DependencyConstructor */
15
+ /** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */
15
16
 
16
17
  class DependencyTemplates {
17
18
  /**
18
19
  * @param {string | Hash} hashFunction the hash function to use
19
20
  */
20
- constructor(hashFunction = "md4") {
21
- /** @type {Map<Function, DependencyTemplate>} */
21
+ constructor(hashFunction = DEFAULTS.HASH_FUNCTION) {
22
+ /** @type {Map<DependencyConstructor, DependencyTemplate>} */
22
23
  this._map = new Map();
23
24
  /** @type {string} */
24
25
  this._hash = "31d6cfe0d16ae931b73c59d7e0c089c0";
package/lib/DllModule.js CHANGED
@@ -20,8 +20,10 @@ const makeSerializable = require("./util/makeSerializable");
20
20
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
21
21
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
22
22
  /** @typedef {import("./Generator").SourceTypes} SourceTypes */
23
+ /** @typedef {import("./Module").BuildCallback} BuildCallback */
23
24
  /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
24
25
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
26
+ /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
25
27
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
26
28
  /** @typedef {import("./Module").SourceContext} SourceContext */
27
29
  /** @typedef {import("./RequestShortener")} RequestShortener */
@@ -80,7 +82,7 @@ class DllModule extends Module {
80
82
  * @param {Compilation} compilation the compilation
81
83
  * @param {ResolverWithOptions} resolver the resolver
82
84
  * @param {InputFileSystem} fs the file system
83
- * @param {function(WebpackError=): void} callback callback function
85
+ * @param {BuildCallback} callback callback function
84
86
  * @returns {void}
85
87
  */
86
88
  build(options, compilation, resolver, fs, callback) {
@@ -107,7 +109,7 @@ class DllModule extends Module {
107
109
 
108
110
  /**
109
111
  * @param {NeedBuildContext} context context info
110
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
112
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
111
113
  * @returns {void}
112
114
  */
113
115
  needBuild(context, callback) {
@@ -8,8 +8,8 @@
8
8
  const DllModule = require("./DllModule");
9
9
  const ModuleFactory = require("./ModuleFactory");
10
10
 
11
+ /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
11
12
  /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
12
- /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
13
13
  /** @typedef {import("./dependencies/DllEntryDependency")} DllEntryDependency */
14
14
 
15
15
  class DllModuleFactory extends ModuleFactory {
@@ -20,7 +20,7 @@ class DllModuleFactory extends ModuleFactory {
20
20
 
21
21
  /**
22
22
  * @param {ModuleFactoryCreateData} data data object
23
- * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
23
+ * @param {ModuleFactoryCallback} callback callback
24
24
  * @returns {void}
25
25
  */
26
26
  create(data, callback) {
@@ -18,6 +18,7 @@ const makePathsRelative = require("./util/identifier").makePathsRelative;
18
18
  /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
19
19
  /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsManifest} DllReferencePluginOptionsManifest */
20
20
  /** @typedef {import("./Compiler")} Compiler */
21
+ /** @typedef {import("./Compiler").CompilationParams} CompilationParams */
21
22
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
22
23
 
23
24
  const validate = createSchemaValidation(
@@ -38,7 +39,7 @@ class DllReferencePlugin {
38
39
  constructor(options) {
39
40
  validate(options);
40
41
  this.options = options;
41
- /** @type {WeakMap<object, CompilationDataItem>} */
42
+ /** @type {WeakMap<CompilationParams, CompilationDataItem>} */
42
43
  this._compilationData = new WeakMap();
43
44
  }
44
45
 
@@ -58,7 +58,7 @@ class DynamicEntryPlugin {
58
58
  promises.push(
59
59
  new Promise(
60
60
  /**
61
- * @param {(value?: any) => void} resolve resolve
61
+ * @param {(value?: undefined) => void} resolve resolve
62
62
  * @param {(reason?: Error) => void} reject reject
63
63
  */
64
64
  (resolve, reject) => {
@@ -13,7 +13,7 @@ const WebpackError = require("./WebpackError");
13
13
 
14
14
  class EnvironmentPlugin {
15
15
  /**
16
- * @param {(string | string[] | Record<string, any>)[]} keys keys
16
+ * @param {(string | string[] | Record<string, EXPECTED_ANY>)[]} keys keys
17
17
  */
18
18
  constructor(...keys) {
19
19
  if (keys.length === 1 && Array.isArray(keys[0])) {
@@ -22,7 +22,9 @@ class EnvironmentPlugin {
22
22
  this.defaultValues = {};
23
23
  } else if (keys.length === 1 && keys[0] && typeof keys[0] === "object") {
24
24
  this.keys = Object.keys(keys[0]);
25
- this.defaultValues = /** @type {Record<string, any>} */ (keys[0]);
25
+ this.defaultValues =
26
+ /** @type {Record<string, EXPECTED_ANY>} */
27
+ (keys[0]);
26
28
  } else {
27
29
  this.keys = /** @type {string[]} */ (keys);
28
30
  this.defaultValues = {};