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
@@ -8,7 +8,12 @@
8
8
  const parseJson = require("json-parse-even-better-errors");
9
9
  const { getContext, runLoaders } = require("loader-runner");
10
10
  const querystring = require("querystring");
11
- const { HookMap, SyncHook, AsyncSeriesBailHook } = require("tapable");
11
+ const {
12
+ HookMap,
13
+ SyncHook,
14
+ SyncWaterfallHook,
15
+ AsyncSeriesBailHook
16
+ } = require("tapable");
12
17
  const {
13
18
  CachedSource,
14
19
  OriginalSource,
@@ -57,6 +62,7 @@ const memoize = require("./util/memoize");
57
62
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
58
63
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
59
64
  /** @typedef {import("./Generator")} Generator */
65
+ /** @typedef {import("./Generator").GenerateErrorFn} GenerateErrorFn */
60
66
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
61
67
  /** @typedef {import("./Module").BuildMeta} BuildMeta */
62
68
  /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
@@ -65,6 +71,8 @@ const memoize = require("./util/memoize");
65
71
  /** @typedef {import("./Module").KnownBuildInfo} KnownBuildInfo */
66
72
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
67
73
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
74
+ /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
75
+ /** @typedef {import("./Module").BuildCallback} BuildCallback */
68
76
  /** @typedef {import("./Generator").SourceTypes} SourceTypes */
69
77
  /** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
70
78
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
@@ -73,6 +81,7 @@ const memoize = require("./util/memoize");
73
81
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
74
82
  /** @typedef {import("./NormalModuleFactory").ResourceDataWithData} ResourceDataWithData */
75
83
  /** @typedef {import("./Parser")} Parser */
84
+ /** @typedef {import("./Parser").PreparsedAst} PreparsedAst */
76
85
  /** @typedef {import("./RequestShortener")} RequestShortener */
77
86
  /** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */
78
87
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
@@ -84,15 +93,14 @@ const memoize = require("./util/memoize");
84
93
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
85
94
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
86
95
  /** @typedef {import("./util/createHash").Algorithm} Algorithm */
96
+ /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
87
97
  /**
88
98
  * @template T
89
99
  * @typedef {import("./util/deprecation").FakeHook<T>} FakeHook
90
100
  */
91
101
 
92
- /** @typedef {{[k: string]: any}} ParserOptions */
93
- /** @typedef {{[k: string]: any}} GeneratorOptions */
94
-
95
- /** @typedef {UnsafeCacheData & { parser: undefined | Parser, parserOptions: undefined | ParserOptions, generator: undefined | Generator, generatorOptions: undefined | GeneratorOptions }} NormalModuleUnsafeCacheData */
102
+ /** @typedef {{ [k: string]: EXPECTED_ANY }} ParserOptions */
103
+ /** @typedef {{ [k: string]: EXPECTED_ANY }} GeneratorOptions */
96
104
 
97
105
  /**
98
106
  * @template T
@@ -126,7 +134,7 @@ const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/;
126
134
  /**
127
135
  * @typedef {object} LoaderItem
128
136
  * @property {string} loader
129
- * @property {any} options
137
+ * @property {string | null | undefined | Record<string, EXPECTED_ANY>} options
130
138
  * @property {string?} ident
131
139
  * @property {string?} type
132
140
  */
@@ -134,7 +142,7 @@ const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/;
134
142
  /**
135
143
  * @param {string} context absolute context path
136
144
  * @param {string} source a source path
137
- * @param {object=} associatedObjectForCache an object to which the cache will be attached
145
+ * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
138
146
  * @returns {string} new source path
139
147
  */
140
148
  const contextifySourceUrl = (context, source, associatedObjectForCache) => {
@@ -149,13 +157,13 @@ const contextifySourceUrl = (context, source, associatedObjectForCache) => {
149
157
  /**
150
158
  * @param {string} context absolute context path
151
159
  * @param {SourceMap} sourceMap a source map
152
- * @param {object=} associatedObjectForCache an object to which the cache will be attached
160
+ * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
153
161
  * @returns {SourceMap} new source map
154
162
  */
155
163
  const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
156
164
  if (!Array.isArray(sourceMap.sources)) return sourceMap;
157
165
  const { sourceRoot } = sourceMap;
158
- /** @type {function(string): string} */
166
+ /** @type {(source: string) => string} */
159
167
  const mapper = !sourceRoot
160
168
  ? source => source
161
169
  : sourceRoot.endsWith("/")
@@ -202,7 +210,7 @@ const asBuffer = input => {
202
210
 
203
211
  class NonErrorEmittedError extends WebpackError {
204
212
  /**
205
- * @param {any} error value which is not an instance of Error
213
+ * @param {EXPECTED_ANY} error value which is not an instance of Error
206
214
  */
207
215
  constructor(error) {
208
216
  super();
@@ -218,14 +226,17 @@ makeSerializable(
218
226
  "NonErrorEmittedError"
219
227
  );
220
228
 
229
+ /** @typedef {[string | Buffer, string | SourceMapSource, PreparsedAst]} Result */
230
+
221
231
  /**
222
232
  * @typedef {object} NormalModuleCompilationHooks
223
- * @property {SyncHook<[LoaderContext<any>, NormalModule]>} loader
224
- * @property {SyncHook<[LoaderItem[], NormalModule, LoaderContext<any>]>} beforeLoaders
233
+ * @property {SyncHook<[LoaderContext<EXPECTED_ANY>, NormalModule]>} loader
234
+ * @property {SyncHook<[LoaderItem[], NormalModule, LoaderContext<EXPECTED_ANY>]>} beforeLoaders
225
235
  * @property {SyncHook<[NormalModule]>} beforeParse
226
236
  * @property {SyncHook<[NormalModule]>} beforeSnapshot
227
237
  * @property {HookMap<FakeHook<AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>>>} readResourceForScheme
228
- * @property {HookMap<AsyncSeriesBailHook<[LoaderContext<any>], string | Buffer | null>>} readResource
238
+ * @property {HookMap<AsyncSeriesBailHook<[LoaderContext<EXPECTED_ANY>], string | Buffer | null>>} readResource
239
+ * @property {SyncWaterfallHook<[Result, NormalModule]>} processResult
229
240
  * @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild
230
241
  */
231
242
 
@@ -238,7 +249,7 @@ makeSerializable(
238
249
  * @property {string} rawRequest request without resolving
239
250
  * @property {LoaderItem[]} loaders list of loaders
240
251
  * @property {string} resource path + query of the real resource
241
- * @property {Record<string, any>=} resourceResolveData resource resolve data
252
+ * @property {TODO=} resourceResolveData resource resolve data
242
253
  * @property {string} context context directory for resolving
243
254
  * @property {string=} matchResource path + query of the matched resource (virtual)
244
255
  * @property {Parser} parser the parser used
@@ -251,6 +262,8 @@ makeSerializable(
251
262
  /** @type {WeakMap<Compilation, NormalModuleCompilationHooks>} */
252
263
  const compilationHooksMap = new WeakMap();
253
264
 
265
+ /** @typedef {Map<string, EXPECTED_ANY>} CodeGeneratorData */
266
+
254
267
  class NormalModule extends Module {
255
268
  /**
256
269
  * @param {Compilation} compilation the compilation
@@ -304,6 +317,7 @@ class NormalModule extends Module {
304
317
  readResource: new HookMap(
305
318
  () => new AsyncSeriesBailHook(["loaderContext"])
306
319
  ),
320
+ processResult: new SyncWaterfallHook(["result", "module"]),
307
321
  needBuild: new AsyncSeriesBailHook(["module", "context"])
308
322
  };
309
323
  compilationHooksMap.set(
@@ -390,7 +404,7 @@ class NormalModule extends Module {
390
404
  this._isEvaluatingSideEffects = false;
391
405
  /** @type {WeakSet<ModuleGraph> | undefined} */
392
406
  this._addedSideEffectsBailout = undefined;
393
- /** @type {Map<string, any>} */
407
+ /** @type {CodeGeneratorData} */
394
408
  this._codeGeneratorData = new Map();
395
409
  }
396
410
 
@@ -490,9 +504,7 @@ class NormalModule extends Module {
490
504
  * @returns {UnsafeCacheData} cached data
491
505
  */
492
506
  getUnsafeCacheData() {
493
- const data =
494
- /** @type {NormalModuleUnsafeCacheData} */
495
- (super.getUnsafeCacheData());
507
+ const data = super.getUnsafeCacheData();
496
508
  data.parserOptions = this.parserOptions;
497
509
  data.generatorOptions = this.generatorOptions;
498
510
  return data;
@@ -500,7 +512,7 @@ class NormalModule extends Module {
500
512
 
501
513
  /**
502
514
  * restore unsafe cache data
503
- * @param {NormalModuleUnsafeCacheData} unsafeCacheData data from getUnsafeCacheData
515
+ * @param {UnsafeCacheData} unsafeCacheData data from getUnsafeCacheData
504
516
  * @param {NormalModuleFactory} normalModuleFactory the normal module factory handling the unsafe caching
505
517
  */
506
518
  restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory) {
@@ -509,7 +521,7 @@ class NormalModule extends Module {
509
521
 
510
522
  /**
511
523
  * restore unsafe cache data
512
- * @param {object} unsafeCacheData data from getUnsafeCacheData
524
+ * @param {UnsafeCacheData} unsafeCacheData data from getUnsafeCacheData
513
525
  * @param {NormalModuleFactory} normalModuleFactory the normal module factory handling the unsafe caching
514
526
  */
515
527
  _restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory) {
@@ -529,7 +541,7 @@ class NormalModule extends Module {
529
541
  * @param {string} name the asset name
530
542
  * @param {string | Buffer} content the content
531
543
  * @param {(string | SourceMap)=} sourceMap an optional source map
532
- * @param {object=} associatedObjectForCache object for caching
544
+ * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
533
545
  * @returns {Source} the created source
534
546
  */
535
547
  createSourceForAsset(
@@ -650,6 +662,10 @@ class NormalModule extends Module {
650
662
  /** @type {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} */
651
663
  const loaderContext = {
652
664
  version: 2,
665
+ /**
666
+ * @param {import("../declarations/LoaderContext").Schema} [schema] schema
667
+ * @returns {T} options
668
+ */
653
669
  getOptions: schema => {
654
670
  const loader = this.getCurrentLoader(loaderContext);
655
671
 
@@ -682,13 +698,13 @@ class NormalModule extends Module {
682
698
  if (schema.title && (match = /^(.+) (.+)$/.exec(schema.title))) {
683
699
  [, name, baseDataPath] = match;
684
700
  }
685
- getValidate()(schema, options, {
701
+ getValidate()(schema, /** @type {EXPECTED_OBJECT} */ (options), {
686
702
  name,
687
703
  baseDataPath
688
704
  });
689
705
  }
690
706
 
691
- return options;
707
+ return /** @type {T} */ (options);
692
708
  },
693
709
  emitWarning: warning => {
694
710
  if (!(warning instanceof Error)) {
@@ -723,24 +739,32 @@ class NormalModule extends Module {
723
739
  },
724
740
  getResolve(options) {
725
741
  const child = options ? resolver.withOptions(options) : resolver;
726
- return (context, request, callback) => {
727
- if (callback) {
728
- child.resolve({}, context, request, getResolveContext(), callback);
729
- } else {
730
- return new Promise((resolve, reject) => {
742
+ return /** @type {ReturnType<import("../declarations/LoaderContext").NormalModuleLoaderContext<T>["getResolve"]>} */ (
743
+ (context, request, callback) => {
744
+ if (callback) {
731
745
  child.resolve(
732
746
  {},
733
747
  context,
734
748
  request,
735
749
  getResolveContext(),
736
- (err, result) => {
737
- if (err) reject(err);
738
- else resolve(result);
739
- }
750
+ callback
740
751
  );
741
- });
752
+ } else {
753
+ return new Promise((resolve, reject) => {
754
+ child.resolve(
755
+ {},
756
+ context,
757
+ request,
758
+ getResolveContext(),
759
+ (err, result) => {
760
+ if (err) reject(err);
761
+ else resolve(result);
762
+ }
763
+ );
764
+ });
765
+ }
742
766
  }
743
- };
767
+ );
744
768
  },
745
769
  emitFile: (name, content, sourceMap, assetInfo) => {
746
770
  const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
@@ -791,7 +815,11 @@ class NormalModule extends Module {
791
815
 
792
816
  Object.assign(loaderContext, options.loader);
793
817
 
794
- hooks.loader.call(/** @type {LoaderContext<any>} */ (loaderContext), this);
818
+ hooks.loader.call(
819
+ /** @type {LoaderContext<EXPECTED_ANY>} */
820
+ (loaderContext),
821
+ this
822
+ );
795
823
 
796
824
  return loaderContext;
797
825
  }
@@ -819,7 +847,7 @@ class NormalModule extends Module {
819
847
  * @param {string} context the compilation context
820
848
  * @param {string | Buffer} content the content
821
849
  * @param {(string | SourceMapSource | null)=} sourceMap an optional source map
822
- * @param {object=} associatedObjectForCache object for caching
850
+ * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
823
851
  * @returns {Source} the created source
824
852
  */
825
853
  createSource(context, content, sourceMap, associatedObjectForCache) {
@@ -863,7 +891,7 @@ class NormalModule extends Module {
863
891
  * @param {ResolverWithOptions} resolver the resolver
864
892
  * @param {InputFileSystem} fs the file system
865
893
  * @param {NormalModuleCompilationHooks} hooks the hooks
866
- * @param {function((WebpackError | null)=): void} callback callback function
894
+ * @param {BuildCallback} callback callback function
867
895
  * @returns {void}
868
896
  */
869
897
  _doBuild(options, compilation, resolver, fs, hooks, callback) {
@@ -875,8 +903,6 @@ class NormalModule extends Module {
875
903
  hooks
876
904
  );
877
905
 
878
- /** @typedef {[string | Buffer, string | SourceMapSource, Record<string, any>]} Result */
879
-
880
906
  /**
881
907
  * @param {Error | null} err err
882
908
  * @param {(Result | null)=} _result result
@@ -897,8 +923,10 @@ class NormalModule extends Module {
897
923
  });
898
924
  return callback(error);
899
925
  }
900
-
901
- const result = /** @type {Result} */ (_result);
926
+ const result = hooks.processResult.call(
927
+ /** @type {Result} */ (_result),
928
+ this
929
+ );
902
930
  const source = result[0];
903
931
  const sourceMap = result.length >= 1 ? result[1] : null;
904
932
  const extraInfo = result.length >= 2 ? result[2] : null;
@@ -950,7 +978,8 @@ class NormalModule extends Module {
950
978
  hooks.beforeLoaders.call(
951
979
  this.loaders,
952
980
  this,
953
- /** @type {LoaderContext<any>} */ (loaderContext)
981
+ /** @type {LoaderContext<EXPECTED_ANY>} */
982
+ (loaderContext)
954
983
  );
955
984
  } catch (err) {
956
985
  processResult(/** @type {Error} */ (err));
@@ -997,10 +1026,9 @@ class NormalModule extends Module {
997
1026
  loaderContext._compilation =
998
1027
  loaderContext._compiler =
999
1028
  loaderContext._module =
1000
- // eslint-disable-next-line no-warning-comments
1001
- // @ts-ignore
1002
1029
  loaderContext.fs =
1003
- undefined;
1030
+ /** @type {EXPECTED_ANY} */
1031
+ (undefined);
1004
1032
 
1005
1033
  if (!result) {
1006
1034
  /** @type {BuildInfo} */
@@ -1122,7 +1150,7 @@ class NormalModule extends Module {
1122
1150
  * @param {Compilation} compilation the compilation
1123
1151
  * @param {ResolverWithOptions} resolver the resolver
1124
1152
  * @param {InputFileSystem} fs the file system
1125
- * @param {function(WebpackError=): void} callback callback function
1153
+ * @param {BuildCallback} callback callback function
1126
1154
  * @returns {void}
1127
1155
  */
1128
1156
  build(options, compilation, resolver, fs, callback) {
@@ -1232,8 +1260,8 @@ class NormalModule extends Module {
1232
1260
  (depWithoutGlob !== dep
1233
1261
  ? /** @type {NonNullable<KnownBuildInfo["contextDependencies"]>} */
1234
1262
  (
1235
- /** @type {BuildInfo} */ (this.buildInfo)
1236
- .contextDependencies
1263
+ /** @type {BuildInfo} */
1264
+ (this.buildInfo).contextDependencies
1237
1265
  )
1238
1266
  : deps
1239
1267
  ).add(absolute);
@@ -1416,16 +1444,35 @@ class NormalModule extends Module {
1416
1444
  runtimeRequirements.add(RuntimeGlobals.thisAsExports);
1417
1445
  }
1418
1446
 
1419
- /** @type {function(): Map<string, any>} */
1447
+ /**
1448
+ * @type {() => CodeGeneratorData}
1449
+ */
1420
1450
  const getData = () => this._codeGeneratorData;
1421
1451
 
1422
1452
  const sources = new Map();
1423
1453
  for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
1454
+ // TODO webpack@6 make generateError required
1455
+ const generator =
1456
+ /** @type {Generator & { generateError?: GenerateErrorFn }} */
1457
+ (this.generator);
1424
1458
  const source = this.error
1425
- ? new RawSource(
1426
- `throw new Error(${JSON.stringify(this.error.message)});`
1427
- )
1428
- : /** @type {Generator} */ (this.generator).generate(this, {
1459
+ ? generator.generateError
1460
+ ? generator.generateError(this.error, this, {
1461
+ dependencyTemplates,
1462
+ runtimeTemplate,
1463
+ moduleGraph,
1464
+ chunkGraph,
1465
+ runtimeRequirements,
1466
+ runtime,
1467
+ concatenationScope,
1468
+ codeGenerationResults,
1469
+ getData,
1470
+ type
1471
+ })
1472
+ : new RawSource(
1473
+ `throw new Error(${JSON.stringify(this.error.message)});`
1474
+ )
1475
+ : generator.generate(this, {
1429
1476
  dependencyTemplates,
1430
1477
  runtimeTemplate,
1431
1478
  moduleGraph,
@@ -1468,7 +1515,7 @@ class NormalModule extends Module {
1468
1515
 
1469
1516
  /**
1470
1517
  * @param {NeedBuildContext} context context info
1471
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
1518
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
1472
1519
  * @returns {void}
1473
1520
  */
1474
1521
  needBuild(context, callback) {
@@ -37,6 +37,7 @@ const {
37
37
  /** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
38
38
  /** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
39
39
  /** @typedef {import("./Generator")} Generator */
40
+ /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
40
41
  /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
41
42
  /** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
42
43
  /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
@@ -50,7 +51,10 @@ const {
50
51
  /** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */
51
52
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
52
53
  /** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
54
+ /** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
55
+ /** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */
53
56
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
57
+ /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
54
58
 
55
59
  /** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer'>} ModuleSettings */
56
60
  /** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */
@@ -61,7 +65,7 @@ const {
61
65
  * @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
62
66
  * @property {string} context
63
67
  * @property {string} request
64
- * @property {Record<string, any> | undefined} assertions
68
+ * @property {ImportAttributes | undefined} assertions
65
69
  * @property {ModuleDependency[]} dependencies
66
70
  * @property {string} dependencyType
67
71
  * @property {CreateData} createData
@@ -81,7 +85,7 @@ const {
81
85
  * @property {string=} context
82
86
  */
83
87
 
84
- /** @typedef {ResourceData & { data: Record<string, any> }} ResourceDataWithData */
88
+ /** @typedef {ResourceData & { data: Record<string, EXPECTED_ANY> }} ResourceDataWithData */
85
89
 
86
90
  /**
87
91
  * @typedef {object} ParsedLoaderRequest
@@ -186,20 +190,13 @@ const mergeGlobalOptions = (globalOptions, type, localOptions) => {
186
190
 
187
191
  // TODO webpack 6 remove
188
192
  /**
193
+ * @template {import("tapable").Hook<EXPECTED_ANY, EXPECTED_ANY>} T
189
194
  * @param {string} name name
190
- * @param {TODO} hook hook
195
+ * @param {T} hook hook
191
196
  * @returns {string} result
192
197
  */
193
198
  const deprecationChangedHookMessage = (name, hook) => {
194
- const names = hook.taps
195
- .map(
196
- /**
197
- * @param {TODO} tapped tapped
198
- * @returns {string} name
199
- */
200
- tapped => tapped.name
201
- )
202
- .join(", ");
199
+ const names = hook.taps.map(tapped => tapped.name).join(", ");
203
200
 
204
201
  return (
205
202
  `NormalModuleFactory.${name} (${names}) is no longer a waterfall hook, but a bailing hook instead. ` +
@@ -224,14 +221,16 @@ const ruleSetCompiler = new RuleSetCompiler([
224
221
  new BasicMatcherRulePlugin("issuerLayer"),
225
222
  new ObjectMatcherRulePlugin("assert", "assertions", value => {
226
223
  if (value) {
227
- return /** @type {any} */ (value)._isLegacyAssert !== undefined;
224
+ return (
225
+ /** @type {ImportAttributes} */ (value)._isLegacyAssert !== undefined
226
+ );
228
227
  }
229
228
 
230
229
  return false;
231
230
  }),
232
231
  new ObjectMatcherRulePlugin("with", "assertions", value => {
233
232
  if (value) {
234
- return !(/** @type {any} */ (value)._isLegacyAssert);
233
+ return !(/** @type {ImportAttributes} */ (value)._isLegacyAssert);
235
234
  }
236
235
  return false;
237
236
  }),
@@ -252,7 +251,7 @@ class NormalModuleFactory extends ModuleFactory {
252
251
  * @param {InputFileSystem} param.fs file system
253
252
  * @param {ResolverFactory} param.resolverFactory resolverFactory
254
253
  * @param {ModuleOptions} param.options options
255
- * @param {object} param.associatedObjectForCache an object to which the cache will be attached
254
+ * @param {AssociatedObjectForCache} param.associatedObjectForCache an object to which the cache will be attached
256
255
  * @param {boolean=} param.layers enable layers
257
256
  */
258
257
  constructor({
@@ -281,9 +280,9 @@ class NormalModuleFactory extends ModuleFactory {
281
280
  beforeResolve: new AsyncSeriesBailHook(["resolveData"]),
282
281
  /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
283
282
  afterResolve: new AsyncSeriesBailHook(["resolveData"]),
284
- /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
283
+ /** @type {AsyncSeriesBailHook<[CreateData, ResolveData], Module | void>} */
285
284
  createModule: new AsyncSeriesBailHook(["createData", "resolveData"]),
286
- /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData]>} */
285
+ /** @type {SyncWaterfallHook<[Module, CreateData, ResolveData]>} */
287
286
  module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
288
287
  /** @type {HookMap<SyncBailHook<[ParserOptions], Parser | void>>} */
289
288
  createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
@@ -305,19 +304,19 @@ class NormalModuleFactory extends ModuleFactory {
305
304
  this.resolverFactory = resolverFactory;
306
305
  this.ruleSet = ruleSetCompiler.compile([
307
306
  {
308
- rules: options.defaultRules
307
+ rules: /** @type {RuleSetRules} */ (options.defaultRules)
309
308
  },
310
309
  {
311
- rules: options.rules
310
+ rules: /** @type {RuleSetRules} */ (options.rules)
312
311
  }
313
312
  ]);
314
313
  this.context = context || "";
315
314
  this.fs = fs;
316
315
  this._globalParserOptions = options.parser;
317
316
  this._globalGeneratorOptions = options.generator;
318
- /** @type {Map<string, WeakMap<object, Parser>>} */
317
+ /** @type {Map<string, WeakMap<ParserOptions, Parser>>} */
319
318
  this.parserCache = new Map();
320
- /** @type {Map<string, WeakMap<object, Generator>>} */
319
+ /** @type {Map<string, WeakMap<GeneratorOptions, Generator>>} */
321
320
  this.generatorCache = new Map();
322
321
  /** @type {Set<Module>} */
323
322
  this._restoredUnsafeCacheEntries = new Set();
@@ -459,9 +458,10 @@ class NormalModuleFactory extends ModuleFactory {
459
458
  matchResource = join(this.fs, context, matchResource);
460
459
  }
461
460
  }
461
+
462
462
  matchResourceData = {
463
463
  resource: matchResource,
464
- ...cacheParseResource(matchResource)
464
+ .../** @type {TODO} */ (cacheParseResource(matchResource))
465
465
  };
466
466
  requestWithoutMatchResource = request.slice(
467
467
  matchResourceMatch[0].length
@@ -546,7 +546,11 @@ class NormalModuleFactory extends ModuleFactory {
546
546
 
547
547
  if (!resourceData) {
548
548
  // ignored
549
- return callback(null, dependencies[0].createIgnoredModule(context));
549
+ return callback(
550
+ null,
551
+ /** @type {TODO} */
552
+ (dependencies[0].createIgnoredModule(context))
553
+ );
550
554
  }
551
555
 
552
556
  const userRequest =
@@ -624,12 +628,13 @@ class NormalModuleFactory extends ModuleFactory {
624
628
  ] === "object" &&
625
629
  settings[/** @type {keyof ModuleSettings} */ (r.type)] !== null
626
630
  ) {
627
- settings[r.type] = cachedCleverMerge(
628
- settings[/** @type {keyof ModuleSettings} */ (r.type)],
629
- r.value
630
- );
631
+ const type = /** @type {keyof ModuleSettings} */ (r.type);
632
+ /** @type {TODO} */
633
+ (settings)[type] = cachedCleverMerge(settings[type], r.value);
631
634
  } else {
632
- settings[r.type] = r.value;
635
+ const type = /** @type {keyof ModuleSettings} */ (r.type);
636
+ /** @type {TODO} */
637
+ (settings)[type] = r.value;
633
638
  }
634
639
  }
635
640
  }
@@ -756,7 +761,7 @@ class NormalModuleFactory extends ModuleFactory {
756
761
  resourceData = {
757
762
  resource: unresolvedResource,
758
763
  data: {},
759
- ...cacheParseResource(unresolvedResource)
764
+ .../** @type {TODO} */ (cacheParseResource(unresolvedResource))
760
765
  };
761
766
  continueCallback();
762
767
  }
@@ -790,7 +795,8 @@ class NormalModuleFactory extends ModuleFactory {
790
795
  data:
791
796
  /** @type {ResolveRequest} */
792
797
  (resolvedResourceResolveData),
793
- ...cacheParseResource(resolvedResource)
798
+ .../** @type {TODO} */
799
+ (cacheParseResource(resolvedResource))
794
800
  };
795
801
  }
796
802
  continueCallback();
@@ -852,7 +858,7 @@ class NormalModuleFactory extends ModuleFactory {
852
858
 
853
859
  /**
854
860
  * @param {ModuleFactoryCreateData} data data object
855
- * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
861
+ * @param {ModuleFactoryCallback} callback callback
856
862
  * @returns {void}
857
863
  */
858
864
  create(data, callback) {
@@ -862,12 +868,11 @@ class NormalModuleFactory extends ModuleFactory {
862
868
  const dependency = dependencies[0];
863
869
  const request = dependency.request;
864
870
  const assertions = dependency.assertions;
871
+ const dependencyType = dependency.category || "";
865
872
  const contextInfo = data.contextInfo;
866
873
  const fileDependencies = new LazySet();
867
874
  const missingDependencies = new LazySet();
868
875
  const contextDependencies = new LazySet();
869
- const dependencyType =
870
- (dependencies.length > 0 && dependencies[0].category) || "";
871
876
  /** @type {ResolveData} */
872
877
  const resolveData = {
873
878
  contextInfo,
@@ -8,15 +8,16 @@
8
8
  const { join, dirname } = require("./util/fs");
9
9
 
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
+ /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
11
12
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
12
13
 
13
- /** @typedef {function(import("./NormalModuleFactory").ResolveData): void} ModuleReplacer */
14
+ /** @typedef {(resolveData: ResolveData) => void} ModuleReplacer */
14
15
 
15
16
  class NormalModuleReplacementPlugin {
16
17
  /**
17
18
  * Create an instance of the plugin
18
19
  * @param {RegExp} resourceRegExp the resource matcher
19
- * @param {string|ModuleReplacer} newResource the resource replacement
20
+ * @param {string | ModuleReplacer} newResource the resource replacement
20
21
  */
21
22
  constructor(resourceRegExp, newResource) {
22
23
  this.resourceRegExp = resourceRegExp;
@@ -7,13 +7,13 @@
7
7
 
8
8
  const ModuleFactory = require("./ModuleFactory");
9
9
 
10
+ /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
10
11
  /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
11
- /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
12
12
 
13
13
  class NullFactory extends ModuleFactory {
14
14
  /**
15
15
  * @param {ModuleFactoryCreateData} data data object
16
- * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
16
+ * @param {ModuleFactoryCallback} callback callback
17
17
  * @returns {void}
18
18
  */
19
19
  create(data, callback) {
package/lib/Parser.js CHANGED
@@ -5,10 +5,11 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
8
9
  /** @typedef {import("./Compilation")} Compilation */
9
10
  /** @typedef {import("./NormalModule")} NormalModule */
10
11
 
11
- /** @typedef {Record<string, any>} PreparsedAst */
12
+ /** @typedef {Record<string, EXPECTED_ANY>} PreparsedAst */
12
13
 
13
14
  /**
14
15
  * @typedef {object} ParserStateBase
@@ -16,10 +17,10 @@
16
17
  * @property {NormalModule} current
17
18
  * @property {NormalModule} module
18
19
  * @property {Compilation} compilation
19
- * @property {{[k: string]: any}} options
20
+ * @property {WebpackOptions} options
20
21
  */
21
22
 
22
- /** @typedef {Record<string, any> & ParserStateBase} ParserState */
23
+ /** @typedef {Record<string, EXPECTED_ANY> & ParserStateBase} ParserState */
23
24
 
24
25
  class Parser {
25
26
  /* istanbul ignore next */