webpack 5.90.2 → 5.91.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (182) hide show
  1. package/README.md +5 -5
  2. package/bin/webpack.js +5 -1
  3. package/lib/APIPlugin.js +8 -4
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/BannerPlugin.js +3 -1
  6. package/lib/Cache.js +7 -1
  7. package/lib/CacheFacade.js +3 -3
  8. package/lib/ChunkGraph.js +32 -18
  9. package/lib/ChunkGroup.js +14 -14
  10. package/lib/CleanPlugin.js +7 -5
  11. package/lib/Compilation.js +263 -94
  12. package/lib/Compiler.js +199 -83
  13. package/lib/ConditionalInitFragment.js +4 -5
  14. package/lib/ContextModule.js +4 -1
  15. package/lib/ContextModuleFactory.js +4 -2
  16. package/lib/ContextReplacementPlugin.js +3 -2
  17. package/lib/CssModule.js +0 -3
  18. package/lib/DefinePlugin.js +4 -2
  19. package/lib/DelegatedModule.js +2 -1
  20. package/lib/Dependency.js +4 -2
  21. package/lib/DependencyTemplate.js +7 -2
  22. package/lib/DllModule.js +3 -1
  23. package/lib/DllReferencePlugin.js +6 -2
  24. package/lib/EntryOptionPlugin.js +4 -1
  25. package/lib/EntryPlugin.js +6 -1
  26. package/lib/Entrypoint.js +1 -1
  27. package/lib/ExportsInfo.js +1 -4
  28. package/lib/ExternalModule.js +120 -25
  29. package/lib/ExternalModuleFactoryPlugin.js +37 -2
  30. package/lib/FileSystemInfo.js +1 -1
  31. package/lib/Generator.js +2 -1
  32. package/lib/HookWebpackError.js +2 -2
  33. package/lib/InitFragment.js +5 -3
  34. package/lib/LibManifestPlugin.js +15 -7
  35. package/lib/Module.js +54 -5
  36. package/lib/ModuleFilenameHelpers.js +1 -1
  37. package/lib/ModuleGraph.js +56 -27
  38. package/lib/ModuleGraphConnection.js +2 -1
  39. package/lib/MultiCompiler.js +61 -17
  40. package/lib/NodeStuffPlugin.js +14 -3
  41. package/lib/NormalModule.js +239 -86
  42. package/lib/NormalModuleFactory.js +163 -32
  43. package/lib/NormalModuleReplacementPlugin.js +5 -1
  44. package/lib/ProvidePlugin.js +3 -1
  45. package/lib/RawModule.js +4 -2
  46. package/lib/ResolverFactory.js +5 -1
  47. package/lib/RuntimeModule.js +6 -5
  48. package/lib/RuntimePlugin.js +1 -0
  49. package/lib/RuntimeTemplate.js +102 -34
  50. package/lib/SourceMapDevToolPlugin.js +4 -1
  51. package/lib/Stats.js +12 -5
  52. package/lib/TemplatedPathPlugin.js +32 -6
  53. package/lib/Watching.js +67 -60
  54. package/lib/WebpackError.js +6 -6
  55. package/lib/WebpackOptionsApply.js +18 -5
  56. package/lib/asset/RawDataUrlModule.js +5 -2
  57. package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
  58. package/lib/buildChunkGraph.js +220 -392
  59. package/lib/cache/IdleFileCachePlugin.js +8 -3
  60. package/lib/cache/MemoryCachePlugin.js +1 -1
  61. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  62. package/lib/cache/PackFileCacheStrategy.js +49 -16
  63. package/lib/cache/ResolverCachePlugin.js +14 -6
  64. package/lib/cache/getLazyHashedEtag.js +1 -1
  65. package/lib/config/defaults.js +24 -1
  66. package/lib/config/normalization.js +3 -1
  67. package/lib/container/ContainerEntryDependency.js +2 -1
  68. package/lib/container/ContainerEntryModule.js +5 -2
  69. package/lib/container/ContainerPlugin.js +14 -10
  70. package/lib/container/FallbackModule.js +3 -2
  71. package/lib/container/RemoteModule.js +2 -1
  72. package/lib/container/RemoteRuntimeModule.js +12 -3
  73. package/lib/css/CssExportsGenerator.js +34 -17
  74. package/lib/css/CssGenerator.js +20 -2
  75. package/lib/css/CssLoadingRuntimeModule.js +212 -96
  76. package/lib/css/CssModulesPlugin.js +47 -13
  77. package/lib/debug/ProfilingPlugin.js +27 -2
  78. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
  79. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
  80. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
  81. package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
  82. package/lib/dependencies/CommonJsExportsDependency.js +13 -5
  83. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
  84. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
  85. package/lib/dependencies/ContextDependencyHelpers.js +49 -29
  86. package/lib/dependencies/ContextElementDependency.js +8 -1
  87. package/lib/dependencies/CssLocalIdentifierDependency.js +63 -8
  88. package/lib/dependencies/CssUrlDependency.js +5 -3
  89. package/lib/dependencies/ExportsInfoDependency.js +4 -3
  90. package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
  91. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
  92. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
  93. package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
  94. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
  95. package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
  96. package/lib/dependencies/HarmonyImportDependency.js +28 -12
  97. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +44 -16
  98. package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
  99. package/lib/dependencies/HarmonyImportSpecifierDependency.js +21 -10
  100. package/lib/dependencies/ImportDependency.js +9 -2
  101. package/lib/dependencies/ImportEagerDependency.js +4 -2
  102. package/lib/dependencies/ImportMetaContextDependency.js +7 -0
  103. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
  104. package/lib/dependencies/ImportParserPlugin.js +12 -4
  105. package/lib/dependencies/ImportWeakDependency.js +4 -2
  106. package/lib/dependencies/LoaderDependency.js +2 -1
  107. package/lib/dependencies/LoaderImportDependency.js +2 -1
  108. package/lib/dependencies/ModuleDependency.js +4 -5
  109. package/lib/dependencies/PureExpressionDependency.js +4 -1
  110. package/lib/dependencies/RequireContextPlugin.js +1 -1
  111. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
  112. package/lib/dependencies/RequireEnsureDependency.js +1 -1
  113. package/lib/dependencies/URLDependency.js +7 -4
  114. package/lib/dependencies/WorkerDependency.js +1 -1
  115. package/lib/dependencies/WorkerPlugin.js +6 -5
  116. package/lib/dependencies/getFunctionExpression.js +3 -1
  117. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +2 -1
  118. package/lib/hmr/LazyCompilationPlugin.js +2 -1
  119. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  120. package/lib/javascript/ChunkHelpers.js +2 -2
  121. package/lib/javascript/JavascriptParser.js +169 -57
  122. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  123. package/lib/javascript/StartupHelpers.js +22 -5
  124. package/lib/logging/Logger.js +27 -2
  125. package/lib/logging/createConsoleLogger.js +11 -7
  126. package/lib/node/NodeEnvironmentPlugin.js +13 -7
  127. package/lib/node/NodeWatchFileSystem.js +37 -26
  128. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
  129. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
  130. package/lib/node/nodeConsole.js +24 -1
  131. package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
  132. package/lib/optimize/ConcatenatedModule.js +140 -55
  133. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  134. package/lib/optimize/InnerGraph.js +7 -2
  135. package/lib/optimize/InnerGraphPlugin.js +36 -13
  136. package/lib/optimize/ModuleConcatenationPlugin.js +12 -2
  137. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  138. package/lib/optimize/RuntimeChunkPlugin.js +6 -1
  139. package/lib/optimize/SideEffectsFlagPlugin.js +46 -15
  140. package/lib/optimize/SplitChunksPlugin.js +2 -2
  141. package/lib/performance/SizeLimitsPlugin.js +11 -0
  142. package/lib/rules/ObjectMatcherRulePlugin.js +4 -0
  143. package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
  144. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
  145. package/lib/serialization/FileMiddleware.js +1 -0
  146. package/lib/serialization/ObjectMiddleware.js +2 -0
  147. package/lib/serialization/Serializer.js +19 -0
  148. package/lib/sharing/ConsumeSharedModule.js +3 -2
  149. package/lib/sharing/ConsumeSharedPlugin.js +17 -3
  150. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
  151. package/lib/sharing/ProvideSharedModule.js +2 -1
  152. package/lib/sharing/ProvideSharedPlugin.js +12 -5
  153. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  154. package/lib/sharing/utils.js +13 -6
  155. package/lib/util/StackedCacheMap.js +26 -0
  156. package/lib/util/WeakTupleMap.js +57 -13
  157. package/lib/util/cleverMerge.js +24 -11
  158. package/lib/util/comparators.js +34 -14
  159. package/lib/util/conventions.js +129 -0
  160. package/lib/util/fs.js +379 -65
  161. package/lib/util/hash/BatchedHash.js +3 -0
  162. package/lib/util/hash/xxhash64.js +2 -2
  163. package/lib/util/memoize.js +2 -0
  164. package/lib/util/runtime.js +1 -1
  165. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
  166. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +15 -6
  167. package/lib/wasm-sync/WebAssemblyGenerator.js +27 -6
  168. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +2 -1
  169. package/lib/wasm-sync/WebAssemblyParser.js +7 -4
  170. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -1
  171. package/lib/webpack.js +11 -5
  172. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
  173. package/package.json +25 -26
  174. package/schemas/WebpackOptions.check.js +1 -1
  175. package/schemas/WebpackOptions.json +69 -8
  176. package/schemas/plugins/BannerPlugin.check.js +1 -1
  177. package/schemas/plugins/BannerPlugin.json +5 -1
  178. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  179. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  180. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  181. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  182. package/types.d.ts +1772 -673
package/lib/Watching.js CHANGED
@@ -13,11 +13,12 @@ const Stats = require("./Stats");
13
13
  /** @typedef {import("./FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
14
14
  /** @typedef {import("./WebpackError")} WebpackError */
15
15
  /** @typedef {import("./logging/Logger").Logger} Logger */
16
+ /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
16
17
 
17
18
  /**
18
19
  * @template T
19
20
  * @callback Callback
20
- * @param {(Error | null)=} err
21
+ * @param {Error | null} err
21
22
  * @param {T=} result
22
23
  */
23
24
 
@@ -171,8 +172,16 @@ class Watching {
171
172
  this._invalidReported = false;
172
173
  this.compiler.hooks.watchRun.callAsync(this.compiler, err => {
173
174
  if (err) return this._done(err);
174
- const onCompiled = (err, compilation) => {
175
- if (err) return this._done(err, compilation);
175
+ /**
176
+ * @param {Error | null} err error
177
+ * @param {Compilation=} _compilation compilation
178
+ * @returns {void}
179
+ */
180
+ const onCompiled = (err, _compilation) => {
181
+ if (err) return this._done(err, _compilation);
182
+
183
+ const compilation = /** @type {Compilation} */ (_compilation);
184
+
176
185
  if (this.invalid) return this._done(null, compilation);
177
186
 
178
187
  if (this.compiler.hooks.shouldEmit.call(compilation) === false) {
@@ -195,7 +204,9 @@ class Watching {
195
204
  if (compilation.hooks.needAdditionalPass.call()) {
196
205
  compilation.needAdditionalPass = true;
197
206
 
198
- compilation.startTime = this.startTime;
207
+ compilation.startTime = /** @type {number} */ (
208
+ this.startTime
209
+ );
199
210
  compilation.endTime = Date.now();
200
211
  logger.time("done hook");
201
212
  const stats = new Stats(compilation);
@@ -239,10 +250,12 @@ class Watching {
239
250
  _done(err, compilation) {
240
251
  this.running = false;
241
252
 
242
- const logger = compilation && compilation.getLogger("webpack.Watching");
253
+ const logger =
254
+ /** @type {Logger} */
255
+ (compilation && compilation.getLogger("webpack.Watching"));
243
256
 
244
- /** @type {Stats | null} */
245
- let stats = null;
257
+ /** @type {Stats | undefined} */
258
+ let stats = undefined;
246
259
 
247
260
  /**
248
261
  * @param {Error} err error
@@ -267,13 +280,11 @@ class Watching {
267
280
  !(this._isBlocked() && (this.blocked = true))
268
281
  ) {
269
282
  if (compilation) {
270
- /** @type {Logger} */
271
- (logger).time("storeBuildDependencies");
283
+ logger.time("storeBuildDependencies");
272
284
  this.compiler.cache.storeBuildDependencies(
273
285
  compilation.buildDependencies,
274
286
  err => {
275
- /** @type {Logger} */
276
- (logger).timeEnd("storeBuildDependencies");
287
+ logger.timeEnd("storeBuildDependencies");
277
288
  if (err) return handleError(err);
278
289
  this._go();
279
290
  }
@@ -285,7 +296,7 @@ class Watching {
285
296
  }
286
297
 
287
298
  if (compilation) {
288
- compilation.startTime = this.startTime;
299
+ compilation.startTime = /** @type {number} */ (this.startTime);
289
300
  compilation.endTime = Date.now();
290
301
  stats = new Stats(compilation);
291
302
  }
@@ -294,28 +305,22 @@ class Watching {
294
305
 
295
306
  const cbs = this.callbacks;
296
307
  this.callbacks = [];
297
- /** @type {Logger} */
298
- (logger).time("done hook");
308
+ logger.time("done hook");
299
309
  this.compiler.hooks.done.callAsync(/** @type {Stats} */ (stats), err => {
300
- /** @type {Logger} */
301
- (logger).timeEnd("done hook");
310
+ logger.timeEnd("done hook");
302
311
  if (err) return handleError(err, cbs);
303
- this.handler(null, /** @type {Stats} */ (stats));
304
- /** @type {Logger} */
305
- (logger).time("storeBuildDependencies");
312
+ this.handler(null, stats);
313
+ logger.time("storeBuildDependencies");
306
314
  this.compiler.cache.storeBuildDependencies(
307
315
  /** @type {Compilation} */
308
316
  (compilation).buildDependencies,
309
317
  err => {
310
- /** @type {Logger} */
311
- (logger).timeEnd("storeBuildDependencies");
318
+ logger.timeEnd("storeBuildDependencies");
312
319
  if (err) return handleError(err, cbs);
313
- /** @type {Logger} */
314
- (logger).time("beginIdle");
320
+ logger.time("beginIdle");
315
321
  this.compiler.cache.beginIdle();
316
322
  this.compiler.idle = true;
317
- /** @type {Logger} */
318
- (logger).timeEnd("beginIdle");
323
+ logger.timeEnd("beginIdle");
319
324
  process.nextTick(() => {
320
325
  if (!this.closed) {
321
326
  this.watch(
@@ -343,43 +348,45 @@ class Watching {
343
348
  */
344
349
  watch(files, dirs, missing) {
345
350
  this.pausedWatcher = null;
346
- this.watcher = this.compiler.watchFileSystem.watch(
347
- files,
348
- dirs,
349
- missing,
350
- this.lastWatcherStartTime,
351
- this.watchOptions,
352
- (
353
- err,
354
- fileTimeInfoEntries,
355
- contextTimeInfoEntries,
356
- changedFiles,
357
- removedFiles
358
- ) => {
359
- if (err) {
360
- this.compiler.modifiedFiles = undefined;
361
- this.compiler.removedFiles = undefined;
362
- this.compiler.fileTimestamps = undefined;
363
- this.compiler.contextTimestamps = undefined;
364
- this.compiler.fsStartTime = undefined;
365
- return this.handler(err);
366
- }
367
- this._invalidate(
351
+ this.watcher =
352
+ /** @type {WatchFileSystem} */
353
+ (this.compiler.watchFileSystem).watch(
354
+ files,
355
+ dirs,
356
+ missing,
357
+ /** @type {number} */ (this.lastWatcherStartTime),
358
+ this.watchOptions,
359
+ (
360
+ err,
368
361
  fileTimeInfoEntries,
369
362
  contextTimeInfoEntries,
370
363
  changedFiles,
371
364
  removedFiles
372
- );
373
- this._onChange();
374
- },
375
- (fileName, changeTime) => {
376
- if (!this._invalidReported) {
377
- this._invalidReported = true;
378
- this.compiler.hooks.invalid.call(fileName, changeTime);
365
+ ) => {
366
+ if (err) {
367
+ this.compiler.modifiedFiles = undefined;
368
+ this.compiler.removedFiles = undefined;
369
+ this.compiler.fileTimestamps = undefined;
370
+ this.compiler.contextTimestamps = undefined;
371
+ this.compiler.fsStartTime = undefined;
372
+ return this.handler(err);
373
+ }
374
+ this._invalidate(
375
+ fileTimeInfoEntries,
376
+ contextTimeInfoEntries,
377
+ changedFiles,
378
+ removedFiles
379
+ );
380
+ this._onChange();
381
+ },
382
+ (fileName, changeTime) => {
383
+ if (!this._invalidReported) {
384
+ this._invalidReported = true;
385
+ this.compiler.hooks.invalid.call(fileName, changeTime);
386
+ }
387
+ this._onInvalid();
379
388
  }
380
- this._onInvalid();
381
- }
382
- );
389
+ );
383
390
  }
384
391
 
385
392
  /**
@@ -452,7 +459,7 @@ class Watching {
452
459
  return;
453
460
  }
454
461
  /**
455
- * @param {(WebpackError | null)=} err error if any
462
+ * @param {WebpackError | null} err error if any
456
463
  * @param {Compilation=} compilation compilation if any
457
464
  */
458
465
  const finalCallback = (err, compilation) => {
@@ -466,7 +473,7 @@ class Watching {
466
473
  this.compiler.contextTimestamps = undefined;
467
474
  this.compiler.fsStartTime = undefined;
468
475
  /**
469
- * @param {(WebpackError | null)=} err error if any
476
+ * @param {WebpackError | null} err error if any
470
477
  */
471
478
  const shutdown = err => {
472
479
  this.compiler.hooks.watchClose.call();
@@ -508,7 +515,7 @@ class Watching {
508
515
  this.invalid = true;
509
516
  this._done = finalCallback;
510
517
  } else {
511
- finalCallback();
518
+ finalCallback(null);
512
519
  }
513
520
  }
514
521
  }
@@ -22,17 +22,17 @@ class WebpackError extends Error {
22
22
  constructor(message) {
23
23
  super(message);
24
24
 
25
- /** @type {string | undefined} */
25
+ /** @type {string=} */
26
26
  this.details = undefined;
27
- /** @type {Module | undefined | null} */
27
+ /** @type {(Module | null)=} */
28
28
  this.module = undefined;
29
- /** @type {DependencyLocation | undefined} */
29
+ /** @type {DependencyLocation=} */
30
30
  this.loc = undefined;
31
- /** @type {boolean | undefined} */
31
+ /** @type {boolean=} */
32
32
  this.hideStack = undefined;
33
- /** @type {Chunk | undefined} */
33
+ /** @type {Chunk=} */
34
34
  this.chunk = undefined;
35
- /** @type {string | undefined} */
35
+ /** @type {string=} */
36
36
  this.file = undefined;
37
37
  }
38
38
 
@@ -57,6 +57,8 @@ const { cleverMerge } = require("./util/cleverMerge");
57
57
 
58
58
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
59
59
  /** @typedef {import("./Compiler")} Compiler */
60
+ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
61
+ /** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
60
62
 
61
63
  class WebpackOptionsApply extends OptionsApply {
62
64
  constructor() {
@@ -455,7 +457,10 @@ class WebpackOptionsApply extends OptionsApply {
455
457
  }
456
458
  if (options.optimization.runtimeChunk) {
457
459
  const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
458
- new RuntimeChunkPlugin(options.optimization.runtimeChunk).apply(compiler);
460
+ new RuntimeChunkPlugin(
461
+ /** @type {{ name?: (entrypoint: { name: string }) => string }} */
462
+ (options.optimization.runtimeChunk)
463
+ ).apply(compiler);
459
464
  }
460
465
  if (!options.optimization.emitOnErrors) {
461
466
  const NoEmitOnErrorsPlugin = require("./NoEmitOnErrorsPlugin");
@@ -649,7 +654,9 @@ class WebpackOptionsApply extends OptionsApply {
649
654
  new IdleFileCachePlugin(
650
655
  new PackFileCacheStrategy({
651
656
  compiler,
652
- fs: compiler.intermediateFileSystem,
657
+ fs: /** @type {IntermediateFileSystem} */ (
658
+ compiler.intermediateFileSystem
659
+ ),
653
660
  context: options.context,
654
661
  cacheLocation: cacheOptions.cacheLocation,
655
662
  version: cacheOptions.version,
@@ -694,14 +701,18 @@ class WebpackOptionsApply extends OptionsApply {
694
701
  .for("normal")
695
702
  .tap("WebpackOptionsApply", resolveOptions => {
696
703
  resolveOptions = cleverMerge(options.resolve, resolveOptions);
697
- resolveOptions.fileSystem = compiler.inputFileSystem;
704
+ resolveOptions.fileSystem =
705
+ /** @type {InputFileSystem} */
706
+ (compiler.inputFileSystem);
698
707
  return resolveOptions;
699
708
  });
700
709
  compiler.resolverFactory.hooks.resolveOptions
701
710
  .for("context")
702
711
  .tap("WebpackOptionsApply", resolveOptions => {
703
712
  resolveOptions = cleverMerge(options.resolve, resolveOptions);
704
- resolveOptions.fileSystem = compiler.inputFileSystem;
713
+ resolveOptions.fileSystem =
714
+ /** @type {InputFileSystem} */
715
+ (compiler.inputFileSystem);
705
716
  resolveOptions.resolveToContext = true;
706
717
  return resolveOptions;
707
718
  });
@@ -709,7 +720,9 @@ class WebpackOptionsApply extends OptionsApply {
709
720
  .for("loader")
710
721
  .tap("WebpackOptionsApply", resolveOptions => {
711
722
  resolveOptions = cleverMerge(options.resolveLoader, resolveOptions);
712
- resolveOptions.fileSystem = compiler.inputFileSystem;
723
+ resolveOptions.fileSystem =
724
+ /** @type {InputFileSystem} */
725
+ (compiler.inputFileSystem);
713
726
  return resolveOptions;
714
727
  });
715
728
  compiler.hooks.afterResolvers.call(compiler);
@@ -17,6 +17,7 @@ const makeSerializable = require("../util/makeSerializable");
17
17
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
18
18
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
19
19
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
20
+ /** @typedef {import("../Module").SourceTypes} SourceTypes */
20
21
  /** @typedef {import("../RequestShortener")} RequestShortener */
21
22
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
22
23
  /** @typedef {import("../WebpackError")} WebpackError */
@@ -42,7 +43,7 @@ class RawDataUrlModule extends Module {
42
43
  }
43
44
 
44
45
  /**
45
- * @returns {Set<string>} types available (do not mutate)
46
+ * @returns {SourceTypes} types available (do not mutate)
46
47
  */
47
48
  getSourceTypes() {
48
49
  return TYPES;
@@ -70,7 +71,9 @@ class RawDataUrlModule extends Module {
70
71
  * @returns {string} a user readable identifier of the module
71
72
  */
72
73
  readableIdentifier(requestShortener) {
73
- return requestShortener.shorten(this.readableIdentifierStr);
74
+ return /** @type {string} */ (
75
+ requestShortener.shorten(this.readableIdentifierStr)
76
+ );
74
77
  }
75
78
 
76
79
  /**
@@ -13,7 +13,7 @@ const Template = require("../Template");
13
13
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
14
14
 
15
15
  /**
16
- * @typedef {GenerateContext} Context
16
+ * @extends {InitFragment<GenerateContext>}
17
17
  */
18
18
  class AwaitDependenciesInitFragment extends InitFragment {
19
19
  /**
@@ -43,7 +43,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
43
43
 
44
44
  /**
45
45
  * @param {GenerateContext} context context
46
- * @returns {string | Source} the source code that will be included as initialization code
46
+ * @returns {string | Source | undefined} the source code that will be included as initialization code
47
47
  */
48
48
  getContent({ runtimeRequirements }) {
49
49
  runtimeRequirements.add(RuntimeGlobals.module);