webpack 5.95.0 → 5.96.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 (145) hide show
  1. package/README.md +1 -1
  2. package/lib/AsyncDependenciesBlock.js +1 -1
  3. package/lib/BannerPlugin.js +2 -1
  4. package/lib/Chunk.js +30 -0
  5. package/lib/ChunkGraph.js +11 -6
  6. package/lib/ChunkGroup.js +2 -2
  7. package/lib/CleanPlugin.js +4 -5
  8. package/lib/CodeGenerationResults.js +6 -5
  9. package/lib/Compilation.js +71 -48
  10. package/lib/Compiler.js +7 -5
  11. package/lib/ConcatenationScope.js +7 -20
  12. package/lib/ContextModule.js +7 -8
  13. package/lib/CssModule.js +25 -21
  14. package/lib/DefinePlugin.js +14 -8
  15. package/lib/DelegatedModule.js +3 -3
  16. package/lib/DllModule.js +4 -4
  17. package/lib/DynamicEntryPlugin.js +29 -22
  18. package/lib/EvalDevToolModulePlugin.js +5 -2
  19. package/lib/EvalSourceMapDevToolPlugin.js +5 -2
  20. package/lib/ExternalModule.js +40 -7
  21. package/lib/ExternalModuleFactoryPlugin.js +33 -9
  22. package/lib/FileSystemInfo.js +12 -8
  23. package/lib/Generator.js +5 -4
  24. package/lib/HotModuleReplacementPlugin.js +8 -6
  25. package/lib/IgnorePlugin.js +19 -1
  26. package/lib/LoaderOptionsPlugin.js +3 -1
  27. package/lib/Module.js +9 -8
  28. package/lib/ModuleSourceTypesConstants.js +100 -0
  29. package/lib/NormalModule.js +27 -17
  30. package/lib/NormalModuleFactory.js +38 -22
  31. package/lib/OptionsApply.js +12 -1
  32. package/lib/ProgressPlugin.js +50 -10
  33. package/lib/RawModule.js +3 -4
  34. package/lib/RuntimeModule.js +3 -4
  35. package/lib/RuntimePlugin.js +11 -4
  36. package/lib/RuntimeTemplate.js +13 -42
  37. package/lib/SourceMapDevToolPlugin.js +10 -7
  38. package/lib/Watching.js +2 -2
  39. package/lib/WebpackOptionsApply.js +42 -21
  40. package/lib/asset/AssetGenerator.js +347 -194
  41. package/lib/asset/AssetModulesPlugin.js +2 -1
  42. package/lib/asset/AssetSourceGenerator.js +82 -27
  43. package/lib/asset/RawDataUrlModule.js +5 -4
  44. package/lib/buildChunkGraph.js +2 -2
  45. package/lib/cache/PackFileCacheStrategy.js +69 -31
  46. package/lib/cache/ResolverCachePlugin.js +248 -173
  47. package/lib/config/defaults.js +134 -126
  48. package/lib/container/ContainerEntryModule.js +3 -4
  49. package/lib/container/ContainerPlugin.js +8 -0
  50. package/lib/container/FallbackModule.js +2 -2
  51. package/lib/container/HoistContainerReferencesPlugin.js +250 -0
  52. package/lib/container/ModuleFederationPlugin.js +38 -1
  53. package/lib/container/RemoteModule.js +4 -2
  54. package/lib/container/RemoteRuntimeModule.js +4 -2
  55. package/lib/css/CssExportsGenerator.js +16 -12
  56. package/lib/css/CssGenerator.js +22 -16
  57. package/lib/css/CssLoadingRuntimeModule.js +7 -6
  58. package/lib/css/CssModulesPlugin.js +122 -77
  59. package/lib/css/CssParser.js +655 -526
  60. package/lib/css/walkCssTokens.js +1168 -338
  61. package/lib/debug/ProfilingPlugin.js +5 -0
  62. package/lib/dependencies/CommonJsExportsParserPlugin.js +5 -2
  63. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -6
  64. package/lib/dependencies/CssExportDependency.js +3 -3
  65. package/lib/dependencies/CssLocalIdentifierDependency.js +26 -17
  66. package/lib/dependencies/CssUrlDependency.js +33 -3
  67. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -3
  68. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +39 -14
  69. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +15 -82
  70. package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -2
  71. package/lib/dependencies/ImportParserPlugin.js +9 -7
  72. package/lib/dependencies/LoaderPlugin.js +19 -0
  73. package/lib/dependencies/SystemPlugin.js +2 -1
  74. package/lib/dependencies/URLPlugin.js +7 -1
  75. package/lib/dependencies/WorkerPlugin.js +1 -1
  76. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +4 -2
  77. package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
  78. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
  79. package/lib/hmr/LazyCompilationPlugin.js +16 -4
  80. package/lib/hmr/lazyCompilationBackend.js +1 -7
  81. package/lib/index.js +37 -7
  82. package/lib/javascript/EnableChunkLoadingPlugin.js +2 -2
  83. package/lib/javascript/JavascriptGenerator.js +8 -8
  84. package/lib/javascript/JavascriptModulesPlugin.js +126 -73
  85. package/lib/javascript/JavascriptParser.js +338 -117
  86. package/lib/json/JsonGenerator.js +5 -5
  87. package/lib/library/EnableLibraryPlugin.js +2 -2
  88. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  89. package/lib/library/UmdLibraryPlugin.js +16 -8
  90. package/lib/logging/Logger.js +11 -11
  91. package/lib/logging/createConsoleLogger.js +14 -14
  92. package/lib/logging/truncateArgs.js +1 -1
  93. package/lib/node/NodeWatchFileSystem.js +3 -1
  94. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +20 -18
  95. package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
  96. package/lib/node/nodeConsole.js +11 -8
  97. package/lib/optimize/AggressiveSplittingPlugin.js +21 -7
  98. package/lib/optimize/ConcatenatedModule.js +43 -145
  99. package/lib/optimize/FlagIncludedChunksPlugin.js +6 -0
  100. package/lib/optimize/InnerGraphPlugin.js +57 -16
  101. package/lib/optimize/LimitChunkCountPlugin.js +2 -4
  102. package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
  103. package/lib/optimize/RealContentHashPlugin.js +1 -1
  104. package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
  105. package/lib/rules/RuleSetCompiler.js +2 -2
  106. package/lib/runtime/GetChunkFilenameRuntimeModule.js +2 -2
  107. package/lib/schemes/DataUriPlugin.js +1 -1
  108. package/lib/serialization/BinaryMiddleware.js +32 -19
  109. package/lib/serialization/ObjectMiddleware.js +23 -9
  110. package/lib/serialization/SerializerMiddleware.js +3 -2
  111. package/lib/serialization/types.js +2 -2
  112. package/lib/sharing/ConsumeSharedModule.js +2 -3
  113. package/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
  114. package/lib/sharing/ProvideSharedModule.js +2 -3
  115. package/lib/stats/DefaultStatsFactoryPlugin.js +22 -20
  116. package/lib/stats/StatsFactory.js +12 -12
  117. package/lib/stats/StatsPrinter.js +7 -7
  118. package/lib/util/AsyncQueue.js +17 -1
  119. package/lib/util/IterableHelpers.js +1 -1
  120. package/lib/util/SetHelpers.js +1 -1
  121. package/lib/util/cleverMerge.js +48 -24
  122. package/lib/util/concatenate.js +227 -0
  123. package/lib/util/create-schema-validation.js +22 -9
  124. package/lib/util/deprecation.js +86 -28
  125. package/lib/util/fs.js +9 -9
  126. package/lib/util/hash/wasm-hash.js +12 -1
  127. package/lib/util/magicComment.js +21 -0
  128. package/lib/util/makeSerializable.js +24 -1
  129. package/lib/util/memoize.js +2 -1
  130. package/lib/util/runtime.js +4 -1
  131. package/lib/util/semver.js +130 -23
  132. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
  133. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  134. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +5 -5
  135. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -5
  136. package/lib/wasm-sync/WebAssemblyGenerator.js +8 -9
  137. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -5
  138. package/lib/web/FetchCompileAsyncWasmPlugin.js +1 -2
  139. package/lib/web/FetchCompileWasmPlugin.js +1 -2
  140. package/lib/web/JsonpChunkLoadingRuntimeModule.js +6 -6
  141. package/package.json +18 -19
  142. package/schemas/WebpackOptions.check.js +1 -1
  143. package/schemas/WebpackOptions.json +8 -2
  144. package/types.d.ts +801 -259
  145. package/lib/util/mergeScope.js +0 -76
@@ -8,50 +8,86 @@
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const ConcatenationScope = require("../ConcatenationScope");
10
10
  const Generator = require("../Generator");
11
+ const {
12
+ NO_TYPES,
13
+ CSS_URL_TYPES,
14
+ JS_TYPES,
15
+ JS_AND_CSS_URL_TYPES
16
+ } = require("../ModuleSourceTypesConstants");
11
17
  const RuntimeGlobals = require("../RuntimeGlobals");
12
18
 
13
19
  /** @typedef {import("webpack-sources").Source} Source */
14
20
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
15
21
  /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
22
+ /** @typedef {import("../Module").SourceTypes} SourceTypes */
23
+ /** @typedef {import("../ModuleGraph")} ModuleGraph */
16
24
  /** @typedef {import("../NormalModule")} NormalModule */
17
25
 
18
- const TYPES = new Set(["javascript"]);
19
-
20
26
  class AssetSourceGenerator extends Generator {
27
+ /**
28
+ * @param {ModuleGraph} moduleGraph the module graph
29
+ */
30
+ constructor(moduleGraph) {
31
+ super();
32
+
33
+ this._moduleGraph = moduleGraph;
34
+ }
35
+
21
36
  /**
22
37
  * @param {NormalModule} module module for which the code should be generated
23
38
  * @param {GenerateContext} generateContext context for generate
24
- * @returns {Source} generated code
39
+ * @returns {Source | null} generated code
25
40
  */
26
41
  generate(
27
42
  module,
28
- { concatenationScope, chunkGraph, runtimeTemplate, runtimeRequirements }
43
+ { type, concatenationScope, getData, runtimeTemplate, runtimeRequirements }
29
44
  ) {
30
45
  const originalSource = module.originalSource();
46
+ const data = getData ? getData() : undefined;
31
47
 
32
- if (!originalSource) {
33
- return new RawSource("");
34
- }
48
+ switch (type) {
49
+ case "javascript": {
50
+ if (!originalSource) {
51
+ return new RawSource("");
52
+ }
53
+
54
+ const content = originalSource.source();
55
+ const encodedSource =
56
+ typeof content === "string" ? content : content.toString("utf-8");
35
57
 
36
- const content = originalSource.source();
37
- const encodedSource =
38
- typeof content === "string" ? content : content.toString("utf-8");
39
-
40
- let sourceContent;
41
- if (concatenationScope) {
42
- concatenationScope.registerNamespaceExport(
43
- ConcatenationScope.NAMESPACE_OBJECT_EXPORT
44
- );
45
- sourceContent = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${
46
- ConcatenationScope.NAMESPACE_OBJECT_EXPORT
47
- } = ${JSON.stringify(encodedSource)};`;
48
- } else {
49
- runtimeRequirements.add(RuntimeGlobals.module);
50
- sourceContent = `${RuntimeGlobals.module}.exports = ${JSON.stringify(
51
- encodedSource
52
- )};`;
58
+ let sourceContent;
59
+ if (concatenationScope) {
60
+ concatenationScope.registerNamespaceExport(
61
+ ConcatenationScope.NAMESPACE_OBJECT_EXPORT
62
+ );
63
+ sourceContent = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${
64
+ ConcatenationScope.NAMESPACE_OBJECT_EXPORT
65
+ } = ${JSON.stringify(encodedSource)};`;
66
+ } else {
67
+ runtimeRequirements.add(RuntimeGlobals.module);
68
+ sourceContent = `${RuntimeGlobals.module}.exports = ${JSON.stringify(
69
+ encodedSource
70
+ )};`;
71
+ }
72
+ return new RawSource(sourceContent);
73
+ }
74
+ case "css-url": {
75
+ if (!originalSource) {
76
+ return null;
77
+ }
78
+
79
+ const content = originalSource.source();
80
+ const encodedSource =
81
+ typeof content === "string" ? content : content.toString("utf-8");
82
+
83
+ if (data) {
84
+ data.set("url", { [type]: encodedSource });
85
+ }
86
+ return null;
87
+ }
88
+ default:
89
+ return null;
53
90
  }
54
- return new RawSource(sourceContent);
55
91
  }
56
92
 
57
93
  /**
@@ -65,10 +101,29 @@ class AssetSourceGenerator extends Generator {
65
101
 
66
102
  /**
67
103
  * @param {NormalModule} module fresh module
68
- * @returns {Set<string>} available types (do not mutate)
104
+ * @returns {SourceTypes} available types (do not mutate)
69
105
  */
70
106
  getTypes(module) {
71
- return TYPES;
107
+ const sourceTypes = new Set();
108
+ const connections = this._moduleGraph.getIncomingConnections(module);
109
+
110
+ for (const connection of connections) {
111
+ if (!connection.originModule) {
112
+ continue;
113
+ }
114
+
115
+ sourceTypes.add(connection.originModule.type.split("/")[0]);
116
+ }
117
+
118
+ if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
119
+ return JS_AND_CSS_URL_TYPES;
120
+ } else if (sourceTypes.has("javascript")) {
121
+ return JS_TYPES;
122
+ } else if (sourceTypes.has("css")) {
123
+ return CSS_URL_TYPES;
124
+ }
125
+
126
+ return NO_TYPES;
72
127
  }
73
128
 
74
129
  /**
@@ -7,6 +7,7 @@
7
7
 
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const Module = require("../Module");
10
+ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
10
11
  const { ASSET_MODULE_TYPE_RAW_DATA_URL } = require("../ModuleTypeConstants");
11
12
  const RuntimeGlobals = require("../RuntimeGlobals");
12
13
  const makeSerializable = require("../util/makeSerializable");
@@ -26,8 +27,6 @@ const makeSerializable = require("../util/makeSerializable");
26
27
  /** @typedef {import("../util/Hash")} Hash */
27
28
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
28
29
 
29
- const TYPES = new Set(["javascript"]);
30
-
31
30
  class RawDataUrlModule extends Module {
32
31
  /**
33
32
  * @param {string} url raw url
@@ -46,7 +45,7 @@ class RawDataUrlModule extends Module {
46
45
  * @returns {SourceTypes} types available (do not mutate)
47
46
  */
48
47
  getSourceTypes() {
49
- return TYPES;
48
+ return JS_TYPES;
50
49
  }
51
50
 
52
51
  /**
@@ -114,7 +113,9 @@ class RawDataUrlModule extends Module {
114
113
  new RawSource(`module.exports = ${JSON.stringify(this.url)};`)
115
114
  );
116
115
  const data = new Map();
117
- data.set("url", this.urlBuffer);
116
+ data.set("url", {
117
+ javascript: this.url
118
+ });
118
119
  const runtimeRequirements = new Set();
119
120
  runtimeRequirements.add(RuntimeGlobals.module);
120
121
  return { sources, runtimeRequirements, data };
@@ -454,7 +454,7 @@ const visitModules = (
454
454
 
455
455
  /** @type {Set<ChunkGroupInfo>} */
456
456
  const outdatedChunkGroupInfo = new Set();
457
- /** @type {Set<[ChunkGroupInfo, QueueItem]>} */
457
+ /** @type {Set<[ChunkGroupInfo, QueueItem | null]>} */
458
458
  const chunkGroupsForMerging = new Set();
459
459
  /** @type {QueueItem[]} */
460
460
  let queueDelayed = [];
@@ -640,7 +640,7 @@ const visitModules = (
640
640
  queueConnect.set(chunkGroupInfo, connectList);
641
641
  }
642
642
  connectList.add([
643
- cgi,
643
+ /** @type {ChunkGroupInfo} */ (cgi),
644
644
  {
645
645
  action: PROCESS_BLOCK,
646
646
  block: b,
@@ -98,7 +98,7 @@ const MAX_TIME_IN_FRESH_PACK = 1 * 60 * 1000; // 1 min
98
98
  class PackItemInfo {
99
99
  /**
100
100
  * @param {string} identifier identifier of item
101
- * @param {string | null} etag etag of item
101
+ * @param {string | null | undefined} etag etag of item
102
102
  * @param {any} value fresh value of item
103
103
  */
104
104
  constructor(identifier, etag, value) {
@@ -268,20 +268,21 @@ class Pack {
268
268
  }
269
269
 
270
270
  _persistFreshContent() {
271
+ /** @typedef {{ items: Items, map: Map<string, any>, loc: number }} PackItem */
271
272
  const itemsCount = this.freshContent.size;
272
273
  if (itemsCount > 0) {
273
274
  const packCount = Math.ceil(itemsCount / MAX_ITEMS_IN_FRESH_PACK);
274
275
  const itemsPerPack = Math.ceil(itemsCount / packCount);
276
+ /** @type {PackItem[]} */
275
277
  const packs = [];
276
278
  let i = 0;
277
279
  let ignoreNextTimeTick = false;
278
280
  const createNextPack = () => {
279
281
  const loc = this._findLocation();
280
- this.content[loc] = null; // reserve
282
+ this.content[loc] = /** @type {EXPECTED_ANY} */ (null); // reserve
283
+ /** @type {PackItem} */
281
284
  const pack = {
282
- /** @type {Items} */
283
285
  items: new Set(),
284
- /** @type {Map<string, any>} */
285
286
  map: new Map(),
286
287
  loc
287
288
  };
@@ -407,7 +408,9 @@ class Pack {
407
408
  await content.unpack(
408
409
  "it should be merged with other small pack contents"
409
410
  );
410
- for (const [identifier, value] of content.content) {
411
+ for (const [identifier, value] of /** @type {Content} */ (
412
+ content.content
413
+ )) {
411
414
  map.set(identifier, value);
412
415
  }
413
416
  });
@@ -423,7 +426,7 @@ class Pack {
423
426
  mergedItems,
424
427
  mergedUsedItems,
425
428
  memoize(async () => {
426
- /** @type {Map<string, any>} */
429
+ /** @type {Content} */
427
430
  const map = new Map();
428
431
  await Promise.all(addToMergedMap.map(fn => fn(map)));
429
432
  return new PackContentItems(map);
@@ -471,7 +474,11 @@ class Pack {
471
474
  );
472
475
  const map = new Map();
473
476
  for (const identifier of usedItems) {
474
- map.set(identifier, content.content.get(identifier));
477
+ map.set(
478
+ identifier,
479
+ /** @type {Content} */
480
+ (content.content).get(identifier)
481
+ );
475
482
  }
476
483
  return new PackContentItems(map);
477
484
  }
@@ -498,7 +505,11 @@ class Pack {
498
505
  );
499
506
  const map = new Map();
500
507
  for (const identifier of unusedItems) {
501
- map.set(identifier, content.content.get(identifier));
508
+ map.set(
509
+ identifier,
510
+ /** @type {Content} */
511
+ (content.content).get(identifier)
512
+ );
502
513
  }
503
514
  return new PackContentItems(map);
504
515
  }
@@ -552,7 +563,11 @@ class Pack {
552
563
  );
553
564
  const map = new Map();
554
565
  for (const identifier of items) {
555
- map.set(identifier, content.content.get(identifier));
566
+ map.set(
567
+ identifier,
568
+ /** @type {Content} */
569
+ (content.content).get(identifier)
570
+ );
556
571
  }
557
572
  return new PackContentItems(map);
558
573
  })
@@ -633,7 +648,8 @@ class Pack {
633
648
  )
634
649
  );
635
650
  for (const identifier of items) {
636
- this.itemInfo.get(identifier).location = idx;
651
+ /** @type {PackItemInfo} */
652
+ (this.itemInfo.get(identifier)).location = idx;
637
653
  }
638
654
  }
639
655
  items = read();
@@ -643,9 +659,11 @@ class Pack {
643
659
 
644
660
  makeSerializable(Pack, "webpack/lib/cache/PackFileCacheStrategy", "Pack");
645
661
 
662
+ /** @typedef {Map<string, any>} Content */
663
+
646
664
  class PackContentItems {
647
665
  /**
648
- * @param {Map<string, any>} map items
666
+ * @param {Content} map items
649
667
  */
650
668
  constructor(map) {
651
669
  this.map = map;
@@ -680,12 +698,17 @@ class PackContentItems {
680
698
  rollback(s);
681
699
  if (err === NOT_SERIALIZABLE) continue;
682
700
  const msg = "Skipped not serializable cache item";
683
- if (err.message.includes("ModuleBuildError")) {
684
- logger.log(`${msg} (in build error): ${err.message}`);
685
- logger.debug(`${msg} '${key}' (in build error): ${err.stack}`);
701
+ const notSerializableErr = /** @type {Error} */ (err);
702
+ if (notSerializableErr.message.includes("ModuleBuildError")) {
703
+ logger.log(
704
+ `${msg} (in build error): ${notSerializableErr.message}`
705
+ );
706
+ logger.debug(
707
+ `${msg} '${key}' (in build error): ${notSerializableErr.stack}`
708
+ );
686
709
  } else {
687
- logger.warn(`${msg}: ${err.message}`);
688
- logger.debug(`${msg} '${key}': ${err.stack}`);
710
+ logger.warn(`${msg}: ${notSerializableErr.message}`);
711
+ logger.debug(`${msg} '${key}': ${notSerializableErr.stack}`);
689
712
  }
690
713
  }
691
714
  }
@@ -710,10 +733,11 @@ class PackContentItems {
710
733
  } catch (err) {
711
734
  rollback(s);
712
735
  if (err === NOT_SERIALIZABLE) continue;
736
+ const notSerializableErr = /** @type {Error} */ (err);
713
737
  logger.warn(
714
- `Skipped not serializable cache item '${key}': ${err.message}`
738
+ `Skipped not serializable cache item '${key}': ${notSerializableErr.message}`
715
739
  );
716
- logger.debug(err.stack);
740
+ logger.debug(notSerializableErr.stack);
717
741
  }
718
742
  }
719
743
  write(null);
@@ -767,6 +791,8 @@ makeSerializable(
767
791
  "PackContentItems"
768
792
  );
769
793
 
794
+ /** @typedef {(function(): Promise<PackContentItems> | PackContentItems)} LazyFn */
795
+
770
796
  class PackContent {
771
797
  /*
772
798
  This class can be in these states:
@@ -796,9 +822,9 @@ class PackContent {
796
822
  */
797
823
  constructor(items, usedItems, dataOrFn, logger, lazyName) {
798
824
  this.items = items;
799
- /** @type {(function(): Promise<PackContentItems> | PackContentItems) | undefined} */
825
+ /** @type {LazyFn | undefined} */
800
826
  this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined;
801
- /** @type {Map<string, any> | undefined} */
827
+ /** @type {Content | undefined} */
802
828
  this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map;
803
829
  this.outdated = false;
804
830
  this.used = usedItems;
@@ -834,7 +860,7 @@ class PackContent {
834
860
  );
835
861
  logger.time(timeMessage);
836
862
  }
837
- const value = this.lazy();
863
+ const value = /** @type {LazyFn} */ (this.lazy)();
838
864
  if ("then" in value) {
839
865
  return value.then(data => {
840
866
  const map = data.map;
@@ -843,7 +869,10 @@ class PackContent {
843
869
  }
844
870
  // Move to state C
845
871
  this.content = map;
846
- this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy);
872
+ this.lazy = SerializerMiddleware.unMemoizeLazy(
873
+ /** @type {LazyFn} */
874
+ (this.lazy)
875
+ );
847
876
  return map.get(identifier);
848
877
  });
849
878
  }
@@ -854,7 +883,10 @@ class PackContent {
854
883
  }
855
884
  // Move to state C
856
885
  this.content = map;
857
- this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy);
886
+ this.lazy = SerializerMiddleware.unMemoizeLazy(
887
+ /** @type {LazyFn} */
888
+ (this.lazy)
889
+ );
858
890
  return map.get(identifier);
859
891
  }
860
892
 
@@ -944,7 +976,7 @@ class PackContent {
944
976
  }
945
977
  if (this.content) {
946
978
  // State A2 or C2
947
- /** @type {Map<string, any>} */
979
+ /** @type {Content} */
948
980
  const map = new Map();
949
981
  for (const item of this.items) {
950
982
  map.set(item, this.content.get(item));
@@ -975,7 +1007,7 @@ class PackContent {
975
1007
  );
976
1008
  logger.time(timeMessage);
977
1009
  }
978
- const value = this.lazy();
1010
+ const value = /** @type {LazyFn} */ (this.lazy)();
979
1011
  this.outdated = false;
980
1012
  if ("then" in value) {
981
1013
  // Move to state B1
@@ -985,14 +1017,17 @@ class PackContent {
985
1017
  logger.timeEnd(timeMessage);
986
1018
  }
987
1019
  const oldMap = data.map;
988
- /** @type {Map<string, any>} */
1020
+ /** @type {Content} */
989
1021
  const map = new Map();
990
1022
  for (const item of this.items) {
991
1023
  map.set(item, oldMap.get(item));
992
1024
  }
993
1025
  // Move to state C1 (or maybe C2)
994
1026
  this.content = map;
995
- this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy);
1027
+ this.lazy = SerializerMiddleware.unMemoizeLazy(
1028
+ /** @type {LazyFn} */
1029
+ (this.lazy)
1030
+ );
996
1031
 
997
1032
  return new PackContentItems(map);
998
1033
  })
@@ -1003,7 +1038,7 @@ class PackContent {
1003
1038
  logger.timeEnd(timeMessage);
1004
1039
  }
1005
1040
  const oldMap = value.map;
1006
- /** @type {Map<string, any>} */
1041
+ /** @type {Content} */
1007
1042
  const map = new Map();
1008
1043
  for (const item of this.items) {
1009
1044
  map.set(item, oldMap.get(item));
@@ -1448,10 +1483,13 @@ class PackFileCacheStrategy {
1448
1483
  const content = new PackContainer(
1449
1484
  pack,
1450
1485
  this.version,
1451
- /** @type {Snapshot} */ (this.buildSnapshot),
1486
+ /** @type {Snapshot} */
1487
+ (this.buildSnapshot),
1452
1488
  updatedBuildDependencies,
1453
- this.resolveResults,
1454
- this.resolveBuildDependenciesSnapshot
1489
+ /** @type {ResolveResults} */
1490
+ (this.resolveResults),
1491
+ /** @type {Snapshot} */
1492
+ (this.resolveBuildDependenciesSnapshot)
1455
1493
  );
1456
1494
  return this.fileSerializer
1457
1495
  .serialize(content, {