webpack 5.112.0 → 5.112.1

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 (263) hide show
  1. package/bin/webpack.js +13 -7
  2. package/lib/Compilation.js +152 -60
  3. package/lib/Compiler.js +12 -25
  4. package/lib/asset/AssetBytesGenerator.js +14 -6
  5. package/lib/asset/AssetBytesParser.js +10 -8
  6. package/lib/asset/AssetGenerator.js +36 -48
  7. package/lib/asset/AssetModule.js +11 -0
  8. package/lib/asset/AssetModulesPlugin.js +5 -4
  9. package/lib/asset/AssetParser.js +8 -8
  10. package/lib/asset/AssetSourceGenerator.js +16 -8
  11. package/lib/asset/AssetSourceParser.js +10 -8
  12. package/lib/asset/WebManifestGenerator.js +11 -6
  13. package/lib/asset/WebManifestParser.js +3 -3
  14. package/lib/async-modules/AsyncModuleHelpers.js +8 -2
  15. package/lib/async-modules/InferAsyncModulesPlugin.js +7 -2
  16. package/lib/cache/CacheFacade.js +1 -1
  17. package/lib/cache/PackFileCacheStrategy.js +6 -10
  18. package/lib/cache/ResolverCachePlugin.js +58 -8
  19. package/lib/config/WebpackOptionsApply.js +8 -28
  20. package/lib/config/cli.js +9 -6
  21. package/lib/config/defaults.js +24 -13
  22. package/lib/config/getClaimedAssetTypes.js +2 -2
  23. package/lib/config/target.js +1 -1
  24. package/lib/context/ContextModule.js +1 -1
  25. package/lib/context/ContextModuleFactory.js +1 -1
  26. package/lib/context/ContextReplacementPlugin.js +3 -9
  27. package/lib/css/CssGenerator.js +40 -37
  28. package/lib/css/CssModule.js +10 -0
  29. package/lib/css/CssModulesPlugin.js +2 -2
  30. package/lib/css/CssParser.js +33 -32
  31. package/lib/css/conventions.js +1 -1
  32. package/lib/css/data.js +224 -219
  33. package/lib/css/syntax-parser.js +1159 -298
  34. package/lib/css/syntax-printer.js +90 -35
  35. package/lib/debug/ProfilingPlugin.js +65 -43
  36. package/lib/define/DefinePlugin.js +10 -15
  37. package/lib/define/DotenvPlugin.js +10 -6
  38. package/lib/define/EnvironmentPlugin.js +4 -2
  39. package/lib/dependencies/amd/AMDDefineDependencyParserPlugin.js +1 -2
  40. package/lib/dependencies/amd/AMDRequireDependenciesBlockParserPlugin.js +4 -1
  41. package/lib/dependencies/commonjs/CommonJsExportRequireDependency.js +1 -4
  42. package/lib/dependencies/commonjs/CommonJsExportsParserPlugin.js +18 -33
  43. package/lib/dependencies/commonjs/CommonJsImportsParserPlugin.js +1 -3
  44. package/lib/dependencies/commonjs/CommonJsObjectExportDependency.js +4 -4
  45. package/lib/dependencies/commonjs/CommonJsPlugin.js +2 -5
  46. package/lib/dependencies/commonjs/RequireEnsureDependenciesBlockParserPlugin.js +4 -1
  47. package/lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js +1 -2
  48. package/lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js +4 -7
  49. package/lib/dependencies/context/ImportMetaGlobHelpers.js +8 -10
  50. package/lib/dependencies/core/CachedConstDependency.js +9 -6
  51. package/lib/dependencies/css/CssIcssExportDependency.js +6 -7
  52. package/lib/dependencies/css/CssIcssImportDependency.js +1 -3
  53. package/lib/dependencies/css/CssUrlDependency.js +2 -6
  54. package/lib/dependencies/esm/ESMDetectionParserPlugin.js +2 -4
  55. package/lib/dependencies/esm/ESMExportExpressionDependency.js +2 -2
  56. package/lib/dependencies/esm/ESMExportImportedSpecifierDependency.js +16 -18
  57. package/lib/dependencies/esm/ESMExportSpecifierDependency.js +20 -3
  58. package/lib/dependencies/esm/ESMExports.js +2 -10
  59. package/lib/dependencies/esm/ESMImportDependency.js +17 -2
  60. package/lib/dependencies/esm/ESMImportDependencyParserPlugin.js +6 -17
  61. package/lib/dependencies/esm/ESMImportGuard.js +11 -23
  62. package/lib/dependencies/esm/ESMImportSideEffectDependency.js +1 -1
  63. package/lib/dependencies/esm/ESMImportSpecifierDependency.js +4 -1
  64. package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
  65. package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
  66. package/lib/dependencies/esm/ESMModulesPlugin.js +1 -3
  67. package/lib/dependencies/esm/TopLevelAwaitDependency.js +1 -8
  68. package/lib/dependencies/helpers/DynamicExports.js +4 -6
  69. package/lib/dependencies/html/HtmlEntryDependency.js +5 -14
  70. package/lib/dependencies/html/HtmlInlineHtmlDependency.js +1 -4
  71. package/lib/dependencies/html/HtmlInlineScriptDependency.js +2 -6
  72. package/lib/dependencies/html/HtmlInlineStyleDependency.js +1 -4
  73. package/lib/dependencies/import/ImportParserPlugin.js +3 -6
  74. package/lib/dependencies/import-meta/ImportMetaPlugin.js +4 -6
  75. package/lib/dependencies/url/URLParserPlugin.js +1 -1
  76. package/lib/dependencies/worker/WorkerAndWorkletPlugin.js +51 -20
  77. package/lib/devtool/ModuleFilenameHelpers.js +1 -1
  78. package/lib/devtool/SourceMapDevToolPlugin.js +1 -1
  79. package/lib/dll/DelegatedModule.js +3 -3
  80. package/lib/dll/DllModule.js +3 -1
  81. package/lib/dll/DllReferencePlugin.js +1 -4
  82. package/lib/errors/AbstractMethodError.js +1 -1
  83. package/lib/errors/ErrorHelpers.js +2 -1
  84. package/lib/errors/HookWebpackError.js +2 -1
  85. package/lib/errors/JSONParseError.js +4 -4
  86. package/lib/errors/WebpackError.js +3 -2
  87. package/lib/esm/ModuleChunkFormatPlugin.js +36 -1
  88. package/lib/externals/ExternalModule.js +12 -9
  89. package/lib/externals/ExternalModuleFactoryPlugin.js +1 -2
  90. package/lib/externals/ExternalsPlugin.js +1 -1
  91. package/lib/fs/FileSystemInfo.js +4 -4
  92. package/lib/graph/AsyncDependenciesBlock.js +1 -1
  93. package/lib/graph/ChunkGraph.js +5 -0
  94. package/lib/graph/Dependency.js +8 -2
  95. package/lib/graph/ExportsInfo.js +1 -1
  96. package/lib/graph/ModuleGraph.js +14 -3
  97. package/lib/graph/buildChunkGraph.js +17 -19
  98. package/lib/graph/findGraphRoots.js +1 -1
  99. package/lib/hmr/HotModuleReplacement.runtime.js +10 -9
  100. package/lib/hmr/HotModuleReplacementPlugin.js +5 -11
  101. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +16 -19
  102. package/lib/hmr/LazyCompilationPlugin.js +1 -7
  103. package/lib/html/HtmlGenerator.js +25 -17
  104. package/lib/html/HtmlModule.js +11 -1
  105. package/lib/html/HtmlModulesPlugin.js +12 -11
  106. package/lib/html/HtmlParser.js +10 -9
  107. package/lib/html/builtinEmbeddedRenderer.js +31 -33
  108. package/lib/html/data.js +42 -21
  109. package/lib/html/htmlMinify.js +4 -1
  110. package/lib/html/syntax-parser.js +34 -35
  111. package/lib/html/syntax-printer.js +2 -3
  112. package/lib/html/xmlMinify.js +4 -1
  113. package/lib/ids/HashedModuleIdsPlugin.js +1 -1
  114. package/lib/index.js +13 -12
  115. package/lib/javascript/APIPlugin.js +7 -13
  116. package/lib/javascript/BasicEvaluatedExpression.js +5 -5
  117. package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -7
  118. package/lib/javascript/ConstPlugin.js +1 -1
  119. package/lib/javascript/JavascriptGenerator.js +16 -11
  120. package/lib/javascript/JavascriptMetaInfoPlugin.js +3 -15
  121. package/lib/javascript/JavascriptModule.js +10 -0
  122. package/lib/javascript/JavascriptModulesPlugin.js +2 -4
  123. package/lib/javascript/JavascriptParser.js +99 -11
  124. package/lib/javascript/ScopeAnalyzer.js +183 -107
  125. package/lib/javascript/UseStrictPlugin.js +2 -5
  126. package/lib/javascript/jsMinify.js +1 -1
  127. package/lib/javascript/regexp.js +2 -2
  128. package/lib/javascript/syntax-parser.js +2114 -1506
  129. package/lib/javascript/syntax-printer-data.js +167 -1
  130. package/lib/javascript/syntax-printer.js +9554 -2782
  131. package/lib/json/JsonGenerator.js +15 -7
  132. package/lib/json/JsonModule.js +11 -0
  133. package/lib/json/JsonParser.js +7 -6
  134. package/lib/library/AssignLibraryPlugin.js +1 -1
  135. package/lib/library/JsonpLibraryPlugin.js +1 -1
  136. package/lib/library/ModuleLibraryPlugin.js +399 -23
  137. package/lib/loaders/LoaderRunner.js +76 -38
  138. package/lib/loaders/loadLoader.js +16 -10
  139. package/lib/module/Generator.js +17 -9
  140. package/lib/module/Module.js +2 -2
  141. package/lib/module/NormalModule.js +7 -5
  142. package/lib/module/NormalModuleFactory.js +11 -17
  143. package/lib/module/Parser.js +9 -2
  144. package/lib/module/extractSourceMap.js +69 -18
  145. package/lib/module/findCaseMismatch.js +2 -2
  146. package/lib/node/ExternalModuleInitFragment.js +2 -2
  147. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -12
  148. package/lib/node/ReadFileCompileWasmPlugin.js +2 -6
  149. package/lib/node/nodeConsole.js +4 -3
  150. package/lib/optimize/CircularModulesPlugin.js +1 -1
  151. package/lib/optimize/ConcatenatedModule.js +2 -6
  152. package/lib/optimize/FlagDependencyExportsPlugin.js +6 -11
  153. package/lib/optimize/FlagDependencyUsagePlugin.js +28 -3
  154. package/lib/optimize/InlineExports.js +4 -7
  155. package/lib/optimize/LazyBarrels.js +41 -5
  156. package/lib/optimize/ModuleConcatenationPlugin.js +8 -10
  157. package/lib/optimize/RealContentHashPlugin.js +2 -6
  158. package/lib/optimize/SideEffectsFlagPlugin.js +7 -21
  159. package/lib/optimize/SplitChunksPlugin.js +11 -24
  160. package/lib/optimize/TupleQueue.js +1 -1
  161. package/lib/output/CleanPlugin.js +3 -1
  162. package/lib/output/CopyPlugin.js +3 -4
  163. package/lib/performance/EvalUsagePlugin.js +1 -3
  164. package/lib/performance/HotspotsPlugin.js +33 -9
  165. package/lib/performance/PureAnnotationsPlugin.js +16 -10
  166. package/lib/performance/TopLevelThisPlugin.js +17 -9
  167. package/lib/prefetch/ResourceHintPlugin.js +1 -1
  168. package/lib/provide/ProvidedDependency.js +36 -4
  169. package/lib/rules/BasicEffectRulePlugin.js +1 -1
  170. package/lib/rules/RuleSetCompiler.js +15 -5
  171. package/lib/rules/UseEffectRulePlugin.js +1 -3
  172. package/lib/runtime/AsyncModuleRuntimeModule.js +7 -1
  173. package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -5
  174. package/lib/runtime/RuntimeGlobals.js +6 -0
  175. package/lib/runtime/RuntimePlugin.js +2 -0
  176. package/lib/schemes/HttpUriPlugin.js +1 -2
  177. package/lib/schemes/VirtualUrlPlugin.js +3 -1
  178. package/lib/serialization/AggregateErrorSerializer.js +3 -3
  179. package/lib/serialization/BinaryMiddleware.js +4 -1
  180. package/lib/serialization/ErrorObjectSerializer.js +2 -5
  181. package/lib/serialization/ObjectMiddleware.js +17 -15
  182. package/lib/serialization/PlainObjectSerializer.js +3 -7
  183. package/lib/serialization/Serializer.js +21 -11
  184. package/lib/serialization/SerializerMiddleware.js +8 -6
  185. package/lib/stats/DefaultStatsFactoryPlugin.js +35 -35
  186. package/lib/stats/DefaultStatsPresetPlugin.js +2 -6
  187. package/lib/stats/DefaultStatsPrinterPlugin.js +12 -11
  188. package/lib/stats/StatsFactory.js +194 -24
  189. package/lib/stats/StatsPrinter.js +126 -13
  190. package/lib/template/DependencyTemplate.js +1 -1
  191. package/lib/template/RuntimeTemplate.js +13 -32
  192. package/lib/template/Template.js +1 -1
  193. package/lib/util/SourceProcessor.js +98 -15
  194. package/lib/util/WeakTupleMap.js +10 -4
  195. package/lib/util/cleverMerge.js +61 -33
  196. package/lib/util/comparators.js +9 -5
  197. package/lib/util/dataURL.js +2 -0
  198. package/lib/util/deprecation.js +4 -3
  199. package/lib/util/globUtils.js +1 -4
  200. package/lib/util/internalSerializables.js +2 -0
  201. package/lib/util/makeSerializable.js +6 -4
  202. package/lib/util/memoize.js +1 -1
  203. package/lib/util/parseJson.js +2 -2
  204. package/lib/util/serialization.js +31 -27
  205. package/lib/wasm/AsyncWasmModule.js +12 -2
  206. package/lib/wasm/AsyncWebAssemblyGenerator.js +12 -4
  207. package/lib/wasm/AsyncWebAssemblyJavascriptGenerator.js +13 -5
  208. package/lib/wasm/AsyncWebAssemblyParser.js +7 -5
  209. package/lib/wasm/UniversalCompileAsyncWasmPlugin.js +2 -6
  210. package/lib/wasm-sync/SyncWasmModule.js +16 -1
  211. package/lib/wasm-sync/WebAssemblyGenerator.js +15 -10
  212. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +13 -5
  213. package/lib/wasm-sync/WebAssemblyParser.js +10 -12
  214. package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -12
  215. package/lib/web/FetchCompileWasmPlugin.js +2 -6
  216. package/package.json +16 -18
  217. package/schemas/WebpackOptions.check.js +3 -3
  218. package/schemas/WebpackOptions.json +2 -2
  219. package/schemas/plugins/BannerPlugin.check.js +3 -3
  220. package/schemas/plugins/HtmlGeneratorOptions.check.js +3 -3
  221. package/schemas/plugins/HtmlParserOptions.check.js +3 -3
  222. package/schemas/plugins/IgnorePlugin.check.js +3 -3
  223. package/schemas/plugins/LoaderOptionsPlugin.check.js +3 -3
  224. package/schemas/plugins/ManifestPlugin.check.js +3 -3
  225. package/schemas/plugins/ProgressPlugin.check.js +3 -3
  226. package/schemas/plugins/SSRManifestPlugin.check.js +3 -3
  227. package/schemas/plugins/SourceMapDevToolPlugin.check.js +3 -3
  228. package/schemas/plugins/WatchIgnorePlugin.check.js +3 -3
  229. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +3 -3
  230. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +3 -3
  231. package/schemas/plugins/asset/AssetParserOptions.check.js +3 -3
  232. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +3 -3
  233. package/schemas/plugins/container/ContainerPlugin.check.js +3 -3
  234. package/schemas/plugins/container/ContainerReferencePlugin.check.js +3 -3
  235. package/schemas/plugins/container/ExternalsType.check.js +3 -3
  236. package/schemas/plugins/container/ModuleFederationPlugin.check.js +3 -3
  237. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +3 -3
  238. package/schemas/plugins/css/CssGeneratorOptions.check.js +3 -3
  239. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +3 -3
  240. package/schemas/plugins/css/CssModuleParserOptions.check.js +3 -3
  241. package/schemas/plugins/css/CssParserOptions.check.js +3 -3
  242. package/schemas/plugins/debug/ProfilingPlugin.check.js +3 -3
  243. package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
  244. package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
  245. package/schemas/plugins/dll/DllPlugin.check.js +3 -3
  246. package/schemas/plugins/dll/DllReferencePlugin.check.js +3 -3
  247. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +3 -3
  248. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +3 -3
  249. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +3 -3
  250. package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +3 -3
  251. package/schemas/plugins/json/JsonModulesPluginParser.check.js +3 -3
  252. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +3 -3
  253. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +3 -3
  254. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +3 -3
  255. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +3 -3
  256. package/schemas/plugins/output/CleanOptions.check.js +7 -0
  257. package/schemas/plugins/output/CleanOptions.json +3 -0
  258. package/schemas/plugins/schemes/HttpUriPlugin.check.js +3 -3
  259. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +3 -3
  260. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +3 -3
  261. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +3 -3
  262. package/schemas/plugins/sharing/SharePlugin.check.js +3 -3
  263. package/types.d.ts +1482 -358
@@ -25,7 +25,6 @@ const makeSerializable = require("../util/makeSerializable");
25
25
  * SnapshotOptions
26
26
  * } from "../fs/FileSystemInfo"
27
27
  */
28
- /** @import { ResolveOptionsWithDependencyType } from "../resolve/ResolverFactory" */
29
28
  /**
30
29
  * @import {
31
30
  * ObjectDeserializerContext,
@@ -128,6 +127,10 @@ class ResolverCachePlugin {
128
127
  let fileSystemInfo;
129
128
  /** @type {SnapshotOptions | undefined} */
130
129
  let snapshotOptions;
130
+ // paths the watcher reported for this build; a snapshot can miss them when
131
+ // the resolve read a cached file system state, e.g. inside a managed path
132
+ /** @type {Set<string> | undefined} */
133
+ let changedPaths;
131
134
  let realResolves = 0;
132
135
  let cachedResolves = 0;
133
136
  let cacheInvalidResolves = 0;
@@ -137,10 +140,17 @@ class ResolverCachePlugin {
137
140
  compiler.hooks.shutdown.tap(PLUGIN_NAME, () => {
138
141
  fileSystemInfo = undefined;
139
142
  snapshotOptions = undefined;
143
+ changedPaths = undefined;
140
144
  });
141
145
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
142
146
  snapshotOptions = compilation.options.snapshot.resolve;
143
147
  fileSystemInfo = compilation.fileSystemInfo;
148
+ const { modifiedFiles, removedFiles } = compiler;
149
+ changedPaths =
150
+ (modifiedFiles && modifiedFiles.size > 0) ||
151
+ (removedFiles && removedFiles.size > 0)
152
+ ? new Set([...(modifiedFiles || []), ...(removedFiles || [])])
153
+ : undefined;
144
154
  compilation.hooks.finishModules.tap(PLUGIN_NAME, () => {
145
155
  if (realResolves + cachedResolves > 0) {
146
156
  const logger = compilation.getLogger(`webpack.${PLUGIN_NAME}`);
@@ -157,6 +167,24 @@ class ResolverCachePlugin {
157
167
  });
158
168
  });
159
169
 
170
+ /**
171
+ * @param {InstanceType<Snapshot>} snapshot snapshot of a cached resolve
172
+ * @returns {boolean} true, when the watcher reported one of its paths
173
+ */
174
+ const dependsOnChangedPath = (snapshot) => {
175
+ if (changedPaths === undefined) return false;
176
+ for (const iterable of [
177
+ snapshot.getMissingIterable(),
178
+ snapshot.getFileIterable(),
179
+ snapshot.getContextIterable()
180
+ ]) {
181
+ for (const item of iterable) {
182
+ if (changedPaths.has(item)) return true;
183
+ }
184
+ }
185
+ return false;
186
+ };
187
+
160
188
  /** @typedef {(err?: Error | null, resolveRequest?: ResolveRequest | null) => void} Callback */
161
189
  /** @typedef {ResolveRequest & { _ResolverCachePluginCacheMiss: true }} ResolveRequestWithCacheMiss */
162
190
 
@@ -227,9 +255,20 @@ class ResolverCachePlugin {
227
255
  const fileDependencies = newResolveContext.fileDependencies;
228
256
  const contextDependencies = newResolveContext.contextDependencies;
229
257
  const missingDependencies = newResolveContext.missingDependencies;
230
- // Only reachable past the `!fileSystemInfo` guard on the resolve tap.
231
- const fsInfo = /** @type {FileSystemInfo} */ (fileSystemInfo);
232
- fsInfo.createSnapshot(
258
+ const resolveResult = withYield ? yieldResult : result;
259
+ // the compiler was closed while resolving, e.g. after a bailed build
260
+ if (!fileSystemInfo) {
261
+ if (withYield && result) {
262
+ /** @type {ResolveRequest[]} */
263
+ (yieldResult).push(result);
264
+ }
265
+ return callback(
266
+ null,
267
+ /** @type {ResolveRequest} */
268
+ (resolveResult)
269
+ );
270
+ }
271
+ fileSystemInfo.createSnapshot(
233
272
  resolveTime,
234
273
  /** @type {Dependencies} */
235
274
  (fileDependencies),
@@ -240,7 +279,6 @@ class ResolverCachePlugin {
240
279
  snapshotOptions,
241
280
  (err, snapshot) => {
242
281
  if (err) return callback(err);
243
- const resolveResult = withYield ? yieldResult : result;
244
282
  // since we intercept resolve hook
245
283
  // we still can get result in callback
246
284
  if (withYield && result) {
@@ -287,9 +325,7 @@ class ResolverCachePlugin {
287
325
  const activeRequests = new Map();
288
326
  /** @type {Map<string, [ActiveRequest[], Yield[]]>} */
289
327
  const activeRequestsWithYield = new Map();
290
- const hook =
291
- /** @type {SyncHook<[Resolver, ResolveOptions, ResolveOptionsWithDependencyType]>} */
292
- (_hook);
328
+ const hook = _hook;
293
329
  hook.tap(PLUGIN_NAME, (resolver, options, userOptions) => {
294
330
  if (
295
331
  /** @type {ResolveOptions & { cache: boolean }} */
@@ -416,6 +452,20 @@ class ResolverCachePlugin {
416
452
  const processCacheResult = (err, cacheEntry) => {
417
453
  if (err) return done(err);
418
454
 
455
+ // the compiler was closed while reading the cache
456
+ if (
457
+ cacheEntry &&
458
+ (!fileSystemInfo || dependsOnChangedPath(cacheEntry.snapshot))
459
+ ) {
460
+ cacheInvalidResolves++;
461
+ return doRealResolve(
462
+ itemCache,
463
+ resolver,
464
+ resolveContext,
465
+ request,
466
+ done
467
+ );
468
+ }
419
469
  if (cacheEntry) {
420
470
  const { snapshot, result } = cacheEntry;
421
471
  const fsInfo = /** @type {FileSystemInfo} */ (fileSystemInfo);
@@ -342,9 +342,7 @@ class WebpackOptionsApply extends OptionsApply {
342
342
  }
343
343
  }
344
344
 
345
- const enabledChunkLoadingTypes =
346
- /** @type {NonNullable<WebpackOptions["output"]["enabledChunkLoadingTypes"]>} */
347
- (options.output.enabledChunkLoadingTypes);
345
+ const enabledChunkLoadingTypes = options.output.enabledChunkLoadingTypes;
348
346
 
349
347
  if (enabledChunkLoadingTypes.length > 0) {
350
348
  for (const type of enabledChunkLoadingTypes) {
@@ -354,9 +352,7 @@ class WebpackOptionsApply extends OptionsApply {
354
352
  }
355
353
  }
356
354
 
357
- const enabledWasmLoadingTypes =
358
- /** @type {NonNullable<WebpackOptions["output"]["enabledWasmLoadingTypes"]>} */
359
- (options.output.enabledWasmLoadingTypes);
355
+ const enabledWasmLoadingTypes = options.output.enabledWasmLoadingTypes;
360
356
 
361
357
  if (enabledWasmLoadingTypes.length > 0) {
362
358
  for (const type of enabledWasmLoadingTypes) {
@@ -366,9 +362,7 @@ class WebpackOptionsApply extends OptionsApply {
366
362
  }
367
363
  }
368
364
 
369
- const enabledLibraryTypes =
370
- /** @type {NonNullable<WebpackOptions["output"]["enabledLibraryTypes"]>} */
371
- (options.output.enabledLibraryTypes);
365
+ const enabledLibraryTypes = options.output.enabledLibraryTypes;
372
366
 
373
367
  if (enabledLibraryTypes.length > 0) {
374
368
  let once = true;
@@ -755,9 +749,7 @@ class WebpackOptionsApply extends OptionsApply {
755
749
  hashFunction:
756
750
  /** @type {NonNullable<WebpackOptions["output"]["hashFunction"]>} */
757
751
  (options.output.hashFunction),
758
- hashDigest:
759
- /** @type {NonNullable<WebpackOptions["output"]["hashDigest"]>} */
760
- (options.output.hashDigest),
752
+ hashDigest: options.output.hashDigest,
761
753
  onDemand: !options.optimization.realContentHash
762
754
  }).apply(compiler);
763
755
  }
@@ -1115,26 +1107,14 @@ class WebpackOptionsApply extends OptionsApply {
1115
1107
  } = require("../util/globUtils");
1116
1108
 
1117
1109
  return compileRelativeGlobPaths(paths, (pattern) =>
1118
- createPathGlobPrefixRegExp(
1119
- pattern,
1120
- /** @type {string} */ (options.context)
1121
- )
1110
+ createPathGlobPrefixRegExp(pattern, options.context)
1122
1111
  );
1123
1112
  };
1124
1113
  const snapshotOptions = {
1125
1114
  ...options.snapshot,
1126
- managedPaths: compileSnapshotPaths(
1127
- /** @type {NonNullable<WebpackOptions["snapshot"]["managedPaths"]>} */
1128
- (options.snapshot.managedPaths)
1129
- ),
1130
- immutablePaths: compileSnapshotPaths(
1131
- /** @type {NonNullable<WebpackOptions["snapshot"]["immutablePaths"]>} */
1132
- (options.snapshot.immutablePaths)
1133
- ),
1134
- unmanagedPaths: compileSnapshotPaths(
1135
- /** @type {NonNullable<WebpackOptions["snapshot"]["unmanagedPaths"]>} */
1136
- (options.snapshot.unmanagedPaths)
1137
- )
1115
+ managedPaths: compileSnapshotPaths(options.snapshot.managedPaths),
1116
+ immutablePaths: compileSnapshotPaths(options.snapshot.immutablePaths),
1117
+ unmanagedPaths: compileSnapshotPaths(options.snapshot.unmanagedPaths)
1138
1118
  };
1139
1119
 
1140
1120
  new AddManagedPathsPlugin(
package/lib/config/cli.js CHANGED
@@ -229,8 +229,10 @@ const getArguments = (schema = webpackSchema) => {
229
229
  description: undefined,
230
230
  simpleType:
231
231
  /** @type {SimpleType} */
232
- (/** @type {unknown} */ (undefined)),
233
- multiple: /** @type {boolean} */ (/** @type {unknown} */ (undefined))
232
+ (/** @type {SimpleType | undefined} */ (undefined)),
233
+ multiple: /** @type {boolean} */ (
234
+ /** @type {boolean | undefined} */ (undefined)
235
+ )
234
236
  };
235
237
  };
236
238
 
@@ -278,8 +280,10 @@ const getArguments = (schema = webpackSchema) => {
278
280
  description: undefined,
279
281
  simpleType:
280
282
  /** @type {SimpleType} */
281
- (/** @type {unknown} */ (undefined)),
282
- multiple: /** @type {boolean} */ (/** @type {unknown} */ (undefined))
283
+ (/** @type {SimpleType | undefined} */ (undefined)),
284
+ multiple: /** @type {boolean} */ (
285
+ /** @type {boolean | undefined} */ (undefined)
286
+ )
283
287
  };
284
288
  }
285
289
 
@@ -440,8 +444,7 @@ const getArguments = (schema = webpackSchema) => {
440
444
 
441
445
  for (let i = 0; i < items.length; i++) {
442
446
  addedArguments += traverse(
443
- /** @type {Schema} */
444
- (items[i]),
447
+ items[i],
445
448
  schemaPath,
446
449
  fullPath,
447
450
  inArray,
@@ -87,6 +87,8 @@ const {
87
87
  */
88
88
  /** @import { WasmLoadingTypes } from "../wasm/EnableWasmLoadingPlugin" */
89
89
  /** @import { PlatformTargetProperties, TargetProperties } from "./target" */
90
+ /** @import Compiler from "../Compiler" */
91
+ /** @typedef {Parameters<import("minimizer-webpack-plugin")["apply"]>[0]} MinimizerCompiler */
90
92
 
91
93
  /**
92
94
  * Defines the recursive non nullable type used by this module.
@@ -279,18 +281,20 @@ const A = (obj, prop, factory) => {
279
281
  if (value === undefined) {
280
282
  obj[prop] = factory();
281
283
  } else if (Array.isArray(value)) {
282
- /** @type {EXPECTED_ANY[] | undefined} */
284
+ /** @type {(T[P] extends (infer E)[] ? E : never)[] | undefined} */
283
285
  let newArray;
284
286
  for (let i = 0; i < value.length; i++) {
285
287
  const item = value[i];
286
288
  if (item === "...") {
287
289
  if (newArray === undefined) {
288
290
  newArray = value.slice(0, i);
289
- obj[prop] = /** @type {T[P]} */ (/** @type {unknown} */ (newArray));
291
+ obj[prop] = /** @type {T[P]} */ (
292
+ /** @type {T[P] | NonNullable<typeof newArray>} */ (newArray)
293
+ );
290
294
  }
291
295
  const items =
292
- /** @type {EXPECTED_ANY[]} */
293
- (/** @type {unknown} */ (factory()));
296
+ /** @type {NonNullable<typeof newArray>} */
297
+ (/** @type {T[P] | NonNullable<typeof newArray>} */ (factory()));
294
298
  if (items !== undefined) {
295
299
  for (const item of items) {
296
300
  newArray.push(item);
@@ -1708,7 +1712,7 @@ const applyOutputDefaults = (
1708
1712
  )
1709
1713
  );
1710
1714
 
1711
- const environment = /** @type {Environment} */ (output.environment);
1715
+ const environment = output.environment;
1712
1716
  /**
1713
1717
  * Returns true, when v is truthy or undefined.
1714
1718
  * @param {boolean | undefined} v value
@@ -2498,13 +2502,12 @@ const applyOptimizationDefaults = (
2498
2502
  D(optimization, "realContentHash", production);
2499
2503
  // A plugin assigning the object shorthand in `apply()` runs after
2500
2504
  // normalization: it replaces `minimizeOptions`, keeping `minimize` boolean.
2501
- const minimizeAssignedInApply = /** @type {unknown} */ (
2502
- optimization.minimize
2503
- );
2504
- if (typeof minimizeAssignedInApply === "object") {
2505
- optimization.minimizeOptions = /** @type {OptimizationMinimizeOptions} */ (
2506
- minimizeAssignedInApply
2505
+ const minimizeAssignedInApply =
2506
+ /** @type {Optimization["minimize"] | OptimizationMinimizeOptions} */ (
2507
+ optimization.minimize
2507
2508
  );
2509
+ if (typeof minimizeAssignedInApply === "object") {
2510
+ optimization.minimizeOptions = minimizeAssignedInApply;
2508
2511
  optimization.minimize = true;
2509
2512
  }
2510
2513
  D(optimization, "minimize", production);
@@ -2613,7 +2616,11 @@ const applyOptimizationDefaults = (
2613
2616
  test: assetNameTest(["[cm]?js"]),
2614
2617
  minify: javascriptMinify,
2615
2618
  minimizerOptions: javascriptOptions
2616
- }).apply(/** @type {EXPECTED_ANY} */ (compiler));
2619
+ }).apply(
2620
+ /** @type {MinimizerCompiler} */ (
2621
+ /** @type {Compiler | MinimizerCompiler} */ (compiler)
2622
+ )
2623
+ );
2617
2624
  return;
2618
2625
  }
2619
2626
  /** @type {(typeof javascriptMinify | string)[]} */
@@ -2703,7 +2710,11 @@ const applyOptimizationDefaults = (
2703
2710
  test: assetNameTest(extensions),
2704
2711
  minify,
2705
2712
  minimizerOptions
2706
- }).apply(/** @type {EXPECTED_ANY} */ (compiler));
2713
+ }).apply(
2714
+ /** @type {MinimizerCompiler} */ (
2715
+ /** @type {Compiler | MinimizerCompiler} */ (compiler)
2716
+ )
2717
+ );
2707
2718
  }
2708
2719
  }
2709
2720
  ]);
@@ -9,10 +9,10 @@ const { matchObject } = require("../devtool/ModuleFilenameHelpers");
9
9
 
10
10
  /** @import Compiler from "../Compiler" */
11
11
  /** @import { MatchObject } from "../devtool/ModuleFilenameHelpers" */
12
- /** @typedef {MatchObject & { minimizer?: import("minimizer-webpack-plugin").InternalPluginOptions<EXPECTED_ANY>["minimizer"] }} MinimizerOptions */
12
+ /** @typedef {MatchObject & { minimizer?: import("minimizer-webpack-plugin").InternalPluginOptions<import("terser").MinifyOptions>["minimizer"] }} MinimizerOptions */
13
13
 
14
14
  /**
15
- * @param {unknown} candidate a configured plugin or minimizer entry
15
+ * @param {NonNullable<Compiler["options"]["optimization"]["minimizer"]>[number] | Compiler["options"]["plugins"][number]} candidate a configured plugin or minimizer entry
16
16
  * @param {string} file probe filename
17
17
  * @returns {boolean} whether the candidate minimizes that file
18
18
  */
@@ -120,7 +120,7 @@ const getDefaultTarget = (context) => {
120
120
  */
121
121
  const versionDependent = (major, minor) => {
122
122
  if (!major) {
123
- return () => /** @type {undefined} */ (undefined);
123
+ return () => undefined;
124
124
  }
125
125
  /** @type {number} */
126
126
  const nMajor = Number(major);
@@ -659,7 +659,7 @@ class ContextModule extends Module {
659
659
  snapshotOptions,
660
660
  (err, snapshot) => {
661
661
  if (err) return callback(err);
662
- /** @type {BuildInfo} */
662
+ /** @type {ContextModuleBuildInfo} */
663
663
  (this.buildInfo).snapshot = snapshot;
664
664
  callback();
665
665
  }
@@ -588,7 +588,7 @@ class ContextModuleFactory extends ModuleFactory {
588
588
  )) {
589
589
  if (
590
590
  !(regExp instanceof RegExp) ||
591
- !regExp.test(/** @type {string} */ (alt.request))
591
+ !regExp.test(alt.request)
592
592
  ) {
593
593
  continue;
594
594
  }
@@ -82,17 +82,11 @@ class ContextReplacementPlugin {
82
82
  newContentRecursive = undefined;
83
83
  }
84
84
  // new webpack.ContextReplacementPlugin(/selector/, './folder', false, /selector/);
85
- this.newContentResource =
86
- /** @type {string | undefined} */
87
- (newContentResource);
85
+ this.newContentResource = newContentResource;
88
86
  /** @type {boolean | undefined} */
89
- this.newContentRecursive =
90
- /** @type {boolean | undefined} */
91
- (newContentRecursive);
87
+ this.newContentRecursive = newContentRecursive;
92
88
  /** @type {RegExp | undefined} */
93
- this.newContentRegExp =
94
- /** @type {RegExp | undefined} */
95
- (newContentRegExp);
89
+ this.newContentRegExp = newContentRegExp;
96
90
  }
97
91
  }
98
92
 
@@ -49,6 +49,7 @@ const CSS_TYPE_PREFIX = `${CSS_TYPE}/`;
49
49
 
50
50
  const URL_SCHEME_REGEXP = /^(?:data|https?):/;
51
51
 
52
+ /** @import CssModule, { BuiltCssModule, CssNormalModule } from "./CssModule" */
52
53
  /** @import { Source, RawSourceMap } from "webpack-sources" */
53
54
  /**
54
55
  * @import {
@@ -77,12 +78,6 @@ const URL_SCHEME_REGEXP = /^(?:data|https?):/;
77
78
  /** @import NormalModule from "../module/NormalModule" */
78
79
  /** @import Hash from "../util/Hash" */
79
80
  /** @import { ModuleFactoryCacheEntry } from "./CssModulesPlugin" */
80
- /**
81
- * @import CssModule, {
82
- * CssModuleBuildInfo,
83
- * CssModuleBuildMeta
84
- * } from "./CssModule"
85
- */
86
81
 
87
82
  /** @typedef {{ line: number, column: number }} SourcePosition */
88
83
  /** @typedef {Map<string, SourcePosition>} ExportLocsMap */
@@ -152,6 +147,14 @@ const buildExportsSourceMap = (
152
147
  };
153
148
  };
154
149
 
150
+ /**
151
+ * The module type the JSDoc inherited from `Generator` names.
152
+ * @typedef {CssNormalModule} TModule
153
+ */
154
+
155
+ /**
156
+ * @extends {Generator<TModule>}
157
+ */
155
158
  class CssGenerator extends Generator {
156
159
  /**
157
160
  * Creates an instance of CssGenerator.
@@ -189,7 +192,7 @@ class CssGenerator extends Generator {
189
192
 
190
193
  /**
191
194
  * Returns the reason this module cannot be concatenated, when one exists.
192
- * @param {NormalModule} module module for which the bailout reason should be determined
195
+ * @param {TModule} module module for which the bailout reason should be determined
193
196
  * @param {ConcatenationBailoutReasonContext} context context
194
197
  * @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
195
198
  */
@@ -224,7 +227,7 @@ class CssGenerator extends Generator {
224
227
 
225
228
  /**
226
229
  * Processes the provided module.
227
- * @param {NormalModule} module the module to generate
230
+ * @param {TModule} module the module to generate
228
231
  * @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
229
232
  * @param {ReplaceSource} source the current replace source which can be modified
230
233
  * @param {GenerateContext & { cssData: CssData }} generateContext the generateContext
@@ -233,7 +236,7 @@ class CssGenerator extends Generator {
233
236
  sourceModule(module, initFragments, source, generateContext) {
234
237
  // Only `dependency` varies across `template.apply` calls, so one context
235
238
  // (and one lazy `chunkInitFragments` getter) serves the whole module.
236
- /** @type {InitFragment<GenerateContext>[] | undefined} */
239
+ /** @type {InitFragment<import("../javascript/JavascriptModulesPlugin").ChunkRenderContext>[] | undefined} */
237
240
  let chunkInitFragments;
238
241
  /** @type {CssDependencyTemplateContext} */
239
242
  const templateContext = {
@@ -280,12 +283,13 @@ class CssGenerator extends Generator {
280
283
 
281
284
  /**
282
285
  * Generates generated code for this runtime module.
283
- * @param {NormalModule} module module for which the code should be generated
286
+ * @param {TModule} module module for which the code should be generated
284
287
  * @param {GenerateContext} generateContext context for generate
285
288
  * @returns {Source | null} generated code
286
289
  */
287
290
  generate(module, generateContext) {
288
291
  const exportType = /** @type {CssModule} */ (module).exportType || "link";
292
+ const { buildInfo, buildMeta } = /** @type {BuiltCssModule} */ (module);
289
293
  const source =
290
294
  generateContext.type === JAVASCRIPT_TYPE && exportType === "link"
291
295
  ? new ReplaceSource(new RawSource(""))
@@ -314,8 +318,7 @@ class CssGenerator extends Generator {
314
318
  case JAVASCRIPT_TYPE: {
315
319
  const compilation = generateContext.runtimeTemplate.compilation;
316
320
  const devtool = compilation.options.devtool;
317
- const isCssModule = /** @type {CssModuleBuildMeta} */ (module.buildMeta)
318
- .isCssModule;
321
+ const isCssModule = buildMeta.isCssModule;
319
322
 
320
323
  const generateContentCode = () => {
321
324
  switch (exportType) {
@@ -412,8 +415,7 @@ class CssGenerator extends Generator {
412
415
  /** @type {Source | null} */
413
416
  const defaultExport = generateJSDefaultExport();
414
417
 
415
- /** @type {CssModuleBuildInfo} */
416
- (module.buildInfo).cssData = cssData;
418
+ buildInfo.cssData = cssData;
417
419
 
418
420
  // Required for HMR
419
421
  if (module.hot) {
@@ -575,7 +577,7 @@ class CssGenerator extends Generator {
575
577
  // `SourceMapDevToolPlugin` can match the module and apply the
576
578
  // devtool filename template instead of leaking this raw name
577
579
  const sourceName = contextifySourceUrl(
578
- /** @type {string} */ (compilation.options.context),
580
+ compilation.options.context,
579
581
  module.identifier(),
580
582
  compilation.compiler.root
581
583
  );
@@ -611,7 +613,7 @@ class CssGenerator extends Generator {
611
613
  /**
612
614
  * Generates fallback output for the provided error condition.
613
615
  * @param {Error} error the error
614
- * @param {NormalModule} module module for which the code should be generated
616
+ * @param {TModule} module module for which the code should be generated
615
617
  * @param {GenerateContext} generateContext context for generate
616
618
  * @returns {Source | null} generated code
617
619
  */
@@ -641,7 +643,7 @@ class CssGenerator extends Generator {
641
643
 
642
644
  /**
643
645
  * Returns the source types available for this module.
644
- * @param {NormalModule} module fresh module
646
+ * @param {TModule} module fresh module
645
647
  * @returns {SourceTypes} available types (do not mutate)
646
648
  */
647
649
  getTypes(module) {
@@ -730,22 +732,20 @@ class CssGenerator extends Generator {
730
732
 
731
733
  /**
732
734
  * Returns the estimated size for the requested source type.
733
- * @param {NormalModule} module the module
735
+ * @param {TModule} module the module
734
736
  * @param {SourceType=} type source type
735
737
  * @returns {number} estimate size of the module
736
738
  */
737
739
  getSize(module, type) {
738
740
  switch (type) {
739
741
  case JAVASCRIPT_TYPE: {
740
- const cssData = /** @type {CssModuleBuildInfo} */ (module.buildInfo)
741
- .cssData;
742
+ const { buildInfo, buildMeta } = /** @type {BuiltCssModule} */ (module);
743
+ const cssData = buildInfo.cssData;
742
744
  if (!cssData) {
743
745
  return 42;
744
746
  }
745
747
  if (cssData.exports.size === 0) {
746
- if (
747
- /** @type {CssModuleBuildMeta} */ (module.buildMeta).isCssModule
748
- ) {
748
+ if (buildMeta.isCssModule) {
749
749
  return 42;
750
750
  }
751
751
  return 0;
@@ -778,7 +778,7 @@ class CssGenerator extends Generator {
778
778
  /**
779
779
  * Updates the hash with the data contributed by this instance.
780
780
  * @param {Hash} hash hash that will be modified
781
- * @param {UpdateHashContext} updateHashContext context for updating hash
781
+ * @param {UpdateHashContext<TModule>} updateHashContext context for updating hash
782
782
  */
783
783
  updateHash(hash, { module, runtimeTemplate }) {
784
784
  hash.update(/** @type {boolean} */ (this._esModule).toString());
@@ -805,7 +805,7 @@ class CssGenerator extends Generator {
805
805
 
806
806
  /**
807
807
  * Resolve the effective `@charset` by walking text imports.
808
- * @param {NormalModule} module the module
808
+ * @param {TModule} module the module
809
809
  * @param {ModuleGraph} moduleGraph module graph
810
810
  * @param {WeakSet<NormalModule>=} visited cycle guard
811
811
  * @returns {string | undefined} the effective charset
@@ -817,14 +817,12 @@ class CssGenerator extends Generator {
817
817
  return undefined;
818
818
  }
819
819
  visited.add(module);
820
- const own =
821
- module.buildInfo &&
822
- /** @type {CssModuleBuildInfo} */ (module.buildInfo).charset;
820
+ const own = module.buildInfo && module.buildInfo.charset;
823
821
  if (own !== undefined) return own;
824
822
  if (exportType !== "text") return undefined;
825
823
  for (const dep of module.dependencies) {
826
824
  if (isDependencyKind(dep, "css-import")) {
827
- const depModule = /** @type {NormalModule} */ (
825
+ const depModule = /** @type {BuiltCssModule} */ (
828
826
  moduleGraph.getModule(dep)
829
827
  );
830
828
  const inherited = this._getEffectiveCharset(
@@ -840,7 +838,7 @@ class CssGenerator extends Generator {
840
838
 
841
839
  /**
842
840
  * Generate JS expressions for `@import` side effects (`style` exportType only).
843
- * @param {NormalModule} module the module to generate CSS text for
841
+ * @param {TModule} module the module to generate CSS text for
844
842
  * @param {GenerateContext} generateContext the generate context
845
843
  * @returns {string[]} JS expressions, one per `@import` dependency
846
844
  */
@@ -850,7 +848,10 @@ class CssGenerator extends Generator {
850
848
 
851
849
  for (const dep of module.dependencies) {
852
850
  if (!isDependencyKind(dep, "css-import")) continue;
853
- const depModule = /** @type {CssModule} */ (moduleGraph.getModule(dep));
851
+ const depModule = /** @type {CssModule & BuiltCssModule} */ (
852
+ moduleGraph.getModule(dep)
853
+ );
854
+ if (!depModule) continue;
854
855
  if (concatenationScope && concatenationScope.isModuleInScope(depModule)) {
855
856
  continue;
856
857
  }
@@ -870,7 +871,7 @@ class CssGenerator extends Generator {
870
871
 
871
872
  /**
872
873
  * Recursively merge `@import`'d CSS into a single Source (text/css-style-sheet only).
873
- * @param {NormalModule} module the module to render
874
+ * @param {TModule} module the module to render
874
875
  * @param {GenerateContext} generateContext the generate context
875
876
  * @param {Set<NormalModule>} ancestors modules on the current path (cycle guard)
876
877
  * @returns {Source | null} merged CSS source, or null when the module has no content
@@ -885,7 +886,9 @@ class CssGenerator extends Generator {
885
886
 
886
887
  for (const dep of module.dependencies) {
887
888
  if (!isDependencyKind(dep, "css-import")) continue;
888
- const depModule = /** @type {CssModule} */ (moduleGraph.getModule(dep));
889
+ const depModule = /** @type {CssModule & BuiltCssModule} */ (
890
+ moduleGraph.getModule(dep)
891
+ );
889
892
  if (!depModule) continue;
890
893
  const depExportType = depModule.exportType;
891
894
  if (depExportType !== "text" && depExportType !== "css-style-sheet") {
@@ -912,7 +915,7 @@ class CssGenerator extends Generator {
912
915
 
913
916
  /**
914
917
  * Generate CSS source for the current module
915
- * @param {NormalModule} module the module to generate CSS source for
918
+ * @param {TModule} module the module to generate CSS source for
916
919
  * @param {GenerateContext} generateContext the generate context
917
920
  * @returns {Source | null} the CSS source
918
921
  */
@@ -957,7 +960,7 @@ class CssGenerator extends Generator {
957
960
  const { compilation } = runtimeTemplate;
958
961
  const outputOptions = compilation.outputOptions;
959
962
  const absolutify = makePathsAbsolute.bindContextCache(
960
- /** @type {string} */ (compilation.options.context),
963
+ compilation.options.context,
961
964
  compilation.compiler.root
962
965
  );
963
966
  const options = {
@@ -1013,7 +1016,7 @@ class CssGenerator extends Generator {
1013
1016
  * Offer CSS bound for a JS string literal to `renderEmbeddedSource`. No `.css`
1014
1017
  * asset carries this text, so an asset-level minimizer never sees it.
1015
1018
  * @param {Source} cssSource the CSS source
1016
- * @param {NormalModule} module the module
1019
+ * @param {TModule} module the module
1017
1020
  * @param {GenerateContext} generateContext the generate context
1018
1021
  * @returns {Source} the source a tap returned, or the original
1019
1022
  */
@@ -1077,7 +1080,7 @@ class CssGenerator extends Generator {
1077
1080
  /**
1078
1081
  * Generate the merged CSS text for a module, optionally wrapped as a
1079
1082
  * JS string literal for embedding in JavaScript output.
1080
- * @param {NormalModule} module the module
1083
+ * @param {TModule} module the module
1081
1084
  * @param {GenerateContext} generateContext the generate context
1082
1085
  * @param {boolean} asJsLiteral wrap the result as a JS string literal
1083
1086
  * @returns {Source} the CSS text source
@@ -47,6 +47,16 @@ const makeSerializable = require("../util/makeSerializable");
47
47
 
48
48
  /** @typedef {BuildMeta & KnownCssModuleBuildMeta} CssModuleBuildMeta */
49
49
 
50
+ /**
51
+ * A css module before or after its build, typed with its build info and build meta.
52
+ * @typedef {NormalModule & { buildInfo?: CssModuleBuildInfo, buildMeta?: CssModuleBuildMeta }} CssNormalModule
53
+ */
54
+
55
+ /**
56
+ * A built css module, typed with its build info and build meta.
57
+ * @typedef {NormalModule & { buildInfo: CssModuleBuildInfo, buildMeta: CssModuleBuildMeta }} BuiltCssModule
58
+ */
59
+
50
60
  class CssModule extends NormalModule {
51
61
  /**
52
62
  * Creates an instance of CssModule.