webpack 5.99.6 → 5.99.8

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 (219) hide show
  1. package/lib/AutomaticPrefetchPlugin.js +21 -22
  2. package/lib/BannerPlugin.js +31 -35
  3. package/lib/CleanPlugin.js +5 -3
  4. package/lib/Compilation.js +21 -15
  5. package/lib/Compiler.js +2 -1
  6. package/lib/ContextExclusionPlugin.js +4 -2
  7. package/lib/ContextModule.js +1 -1
  8. package/lib/ContextModuleFactory.js +1 -2
  9. package/lib/ContextReplacementPlugin.js +7 -4
  10. package/lib/DefinePlugin.js +2 -2
  11. package/lib/DelegatedModule.js +18 -8
  12. package/lib/DelegatedModuleFactoryPlugin.js +9 -7
  13. package/lib/DelegatedPlugin.js +4 -2
  14. package/lib/DllEntryPlugin.js +4 -2
  15. package/lib/DllPlugin.js +5 -3
  16. package/lib/DllReferencePlugin.js +56 -60
  17. package/lib/DynamicEntryPlugin.js +4 -2
  18. package/lib/EntryOptionPlugin.js +3 -1
  19. package/lib/EntryPlugin.js +4 -2
  20. package/lib/EnvironmentPlugin.js +4 -2
  21. package/lib/EvalDevToolModulePlugin.js +9 -7
  22. package/lib/EvalSourceMapDevToolPlugin.js +138 -139
  23. package/lib/ExportsInfo.js +35 -16
  24. package/lib/ExternalModule.js +6 -5
  25. package/lib/ExternalsPlugin.js +3 -1
  26. package/lib/FileSystemInfo.js +2 -2
  27. package/lib/FlagDependencyExportsPlugin.js +2 -1
  28. package/lib/IgnorePlugin.js +6 -4
  29. package/lib/IgnoreWarningsPlugin.js +4 -2
  30. package/lib/LibManifestPlugin.js +5 -6
  31. package/lib/LoaderOptionsPlugin.js +4 -2
  32. package/lib/LoaderTargetPlugin.js +4 -2
  33. package/lib/Module.js +19 -12
  34. package/lib/ModuleFilenameHelpers.js +8 -4
  35. package/lib/ModuleInfoHeaderPlugin.js +11 -12
  36. package/lib/MultiCompiler.js +5 -3
  37. package/lib/NoEmitOnErrorsPlugin.js +5 -3
  38. package/lib/NormalModule.js +13 -8
  39. package/lib/NormalModuleReplacementPlugin.js +33 -36
  40. package/lib/PlatformPlugin.js +3 -1
  41. package/lib/PrefetchPlugin.js +4 -2
  42. package/lib/ProgressPlugin.js +23 -26
  43. package/lib/RecordIdsPlugin.js +72 -102
  44. package/lib/RuntimePlugin.js +34 -32
  45. package/lib/SourceMapDevToolPlugin.js +9 -8
  46. package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
  47. package/lib/WarnNoModeSetPlugin.js +3 -1
  48. package/lib/WatchIgnorePlugin.js +3 -1
  49. package/lib/WebpackError.js +11 -3
  50. package/lib/WebpackOptionsApply.js +6 -7
  51. package/lib/asset/AssetGenerator.js +2 -2
  52. package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
  53. package/lib/cache/IdleFileCachePlugin.js +11 -12
  54. package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
  55. package/lib/cache/ResolverCachePlugin.js +8 -6
  56. package/lib/cli.js +5 -1
  57. package/lib/config/defaults.js +10 -6
  58. package/lib/config/normalization.js +14 -8
  59. package/lib/container/ContainerReferencePlugin.js +24 -26
  60. package/lib/container/ModuleFederationPlugin.js +2 -1
  61. package/lib/css/CssGenerator.js +1 -1
  62. package/lib/css/CssModulesPlugin.js +8 -6
  63. package/lib/debug/ProfilingPlugin.js +18 -21
  64. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
  65. package/lib/dependencies/ContextElementDependency.js +1 -1
  66. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  67. package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
  68. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
  69. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
  70. package/lib/dependencies/LoaderPlugin.js +5 -3
  71. package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
  72. package/lib/dependencies/RequireContextPlugin.js +2 -1
  73. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
  74. package/lib/dependencies/WorkerPlugin.js +2 -2
  75. package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
  76. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  77. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -2
  78. package/lib/hmr/LazyCompilationPlugin.js +17 -18
  79. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
  80. package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
  81. package/lib/ids/HashedModuleIdsPlugin.js +4 -2
  82. package/lib/ids/NamedChunkIdsPlugin.js +4 -2
  83. package/lib/ids/NamedModuleIdsPlugin.js +4 -2
  84. package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
  85. package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
  86. package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
  87. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
  88. package/lib/index.js +11 -0
  89. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  90. package/lib/javascript/JavascriptParser.js +634 -656
  91. package/lib/json/JsonModulesPlugin.js +4 -4
  92. package/lib/library/AbstractLibraryPlugin.js +1 -1
  93. package/lib/library/ModuleLibraryPlugin.js +60 -42
  94. package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
  95. package/lib/node/NodeEnvironmentPlugin.js +3 -1
  96. package/lib/node/nodeConsole.js +3 -2
  97. package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
  98. package/lib/optimize/ConcatenatedModule.js +15 -16
  99. package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
  100. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  101. package/lib/optimize/MangleExportsPlugin.js +15 -16
  102. package/lib/optimize/MinChunkSizePlugin.js +4 -2
  103. package/lib/optimize/ModuleConcatenationPlugin.js +6 -4
  104. package/lib/optimize/RealContentHashPlugin.js +4 -2
  105. package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
  106. package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
  107. package/lib/optimize/RuntimeChunkPlugin.js +21 -23
  108. package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
  109. package/lib/optimize/SplitChunksPlugin.js +9 -7
  110. package/lib/performance/SizeLimitsPlugin.js +3 -1
  111. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
  112. package/lib/rules/BasicEffectRulePlugin.js +1 -2
  113. package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
  114. package/lib/rules/RuleSetCompiler.js +19 -5
  115. package/lib/rules/UseEffectRulePlugin.js +4 -6
  116. package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
  117. package/lib/schemes/DataUriPlugin.js +5 -3
  118. package/lib/schemes/FileUriPlugin.js +5 -3
  119. package/lib/schemes/HttpUriPlugin.js +186 -188
  120. package/lib/serialization/AggregateErrorSerializer.js +42 -0
  121. package/lib/serialization/ErrorObjectSerializer.js +7 -2
  122. package/lib/serialization/ObjectMiddleware.js +13 -0
  123. package/lib/sharing/ProvideSharedPlugin.js +6 -4
  124. package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
  125. package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
  126. package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
  127. package/lib/util/concatenate.js +4 -2
  128. package/lib/util/createHash.js +3 -3
  129. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
  130. package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
  131. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
  132. package/package.json +35 -30
  133. package/schemas/WebpackOptions.check.d.ts +1 -1
  134. package/schemas/WebpackOptions.check.js +2 -2
  135. package/schemas/WebpackOptions.json +267 -26
  136. package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
  137. package/schemas/plugins/BannerPlugin.check.js +1 -1
  138. package/schemas/plugins/DllPlugin.check.d.ts +1 -1
  139. package/schemas/plugins/DllPlugin.check.js +1 -1
  140. package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
  141. package/schemas/plugins/DllReferencePlugin.check.js +1 -1
  142. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
  143. package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
  144. package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
  145. package/schemas/plugins/IgnorePlugin.check.js +1 -1
  146. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
  147. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  148. package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
  149. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  150. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
  151. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  152. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  153. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
  154. package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
  155. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
  156. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  157. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
  158. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
  159. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
  160. package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
  161. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
  162. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  163. package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
  164. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  165. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
  166. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  167. package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
  168. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  169. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
  170. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  171. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
  172. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  173. package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
  174. package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
  175. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
  176. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  177. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
  178. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  179. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
  180. package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
  181. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
  182. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  183. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
  184. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  185. package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
  186. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  187. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
  188. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  189. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
  190. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
  191. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
  192. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
  193. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  194. package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
  195. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  196. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  197. package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
  198. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  199. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
  200. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
  201. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
  202. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
  203. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
  204. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
  205. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
  206. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
  207. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
  208. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  209. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
  210. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
  211. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
  212. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
  213. package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
  214. package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
  215. package/types.d.ts +587 -207
  216. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
  217. package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
  218. package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
  219. package/schemas/plugins/JsonModulesPluginParser.json +0 -16
@@ -34,9 +34,18 @@ const RETURNS_TRUE = () => true;
34
34
 
35
35
  const CIRCULAR = Symbol("circular target");
36
36
 
37
+ /**
38
+ * @typedef {object} RestoreProvidedDataExports
39
+ * @property {ExportInfoName} name
40
+ * @property {ExportInfo["provided"]} provided
41
+ * @property {ExportInfo["canMangleProvide"]} canMangleProvide
42
+ * @property {ExportInfo["terminalBinding"]} terminalBinding
43
+ * @property {RestoreProvidedData | undefined} exportsInfo
44
+ */
45
+
37
46
  class RestoreProvidedData {
38
47
  /**
39
- * @param {TODO[]} exports exports
48
+ * @param {RestoreProvidedDataExports[]} exports exports
40
49
  * @param {ExportInfo["provided"]} otherProvided other provided
41
50
  * @param {ExportInfo["canMangleProvide"]} otherCanMangleProvide other can mangle provide
42
51
  * @param {ExportInfo["terminalBinding"]} otherTerminalBinding other terminal binding
@@ -78,7 +87,7 @@ makeSerializable(
78
87
  "RestoreProvidedData"
79
88
  );
80
89
 
81
- /** @typedef {Map<string, ExportInfo>} Exports */
90
+ /** @typedef {Map<ExportInfoName, ExportInfo>} Exports */
82
91
  /** @typedef {string | string[] | false} UsedName */
83
92
 
84
93
  class ExportsInfo {
@@ -131,6 +140,7 @@ class ExportsInfo {
131
140
  this._sortExports();
132
141
  }
133
142
  if (this._redirectTo !== undefined) {
143
+ /** @type {Exports} */
134
144
  const map = new Map(
135
145
  Array.from(this._redirectTo.orderedExports, item => [item.name, item])
136
146
  );
@@ -160,6 +170,7 @@ class ExportsInfo {
160
170
  */
161
171
  _sortExportsMap(exports) {
162
172
  if (exports.size > 1) {
173
+ /** @type {string[]} */
163
174
  const namesInOrder = [];
164
175
  for (const entry of exports.values()) {
165
176
  namesInOrder.push(entry.name);
@@ -229,7 +240,7 @@ class ExportsInfo {
229
240
  }
230
241
 
231
242
  /**
232
- * @param {string} name export name
243
+ * @param {ExportInfoName} name export name
233
244
  * @returns {ExportInfo} export info for this name
234
245
  */
235
246
  getOwnExportInfo(name) {
@@ -242,7 +253,7 @@ class ExportsInfo {
242
253
  }
243
254
 
244
255
  /**
245
- * @param {string} name export name
256
+ * @param {ExportInfoName} name export name
246
257
  * @returns {ExportInfo} export info for this name
247
258
  */
248
259
  getExportInfo(name) {
@@ -257,7 +268,7 @@ class ExportsInfo {
257
268
  }
258
269
 
259
270
  /**
260
- * @param {string} name export name
271
+ * @param {ExportInfoName} name export name
261
272
  * @returns {ExportInfo} export info for this name
262
273
  */
263
274
  getReadOnlyExportInfo(name) {
@@ -269,7 +280,7 @@ class ExportsInfo {
269
280
  }
270
281
 
271
282
  /**
272
- * @param {string[]} name export name
283
+ * @param {ExportInfoName[]} name export name
273
284
  * @returns {ExportInfo | undefined} export info for this name
274
285
  */
275
286
  getReadOnlyExportInfoRecursive(name) {
@@ -280,7 +291,7 @@ class ExportsInfo {
280
291
  }
281
292
 
282
293
  /**
283
- * @param {string[]=} name the export name
294
+ * @param {ExportInfoName[]=} name the export name
284
295
  * @returns {ExportsInfo | undefined} the nested exports info
285
296
  */
286
297
  getNestedExportsInfo(name) {
@@ -327,7 +338,8 @@ class ExportsInfo {
327
338
  if (targetKey) {
328
339
  exportInfo.setTarget(
329
340
  targetKey,
330
- /** @type {ModuleGraphConnection} */ (targetModule),
341
+ /** @type {ModuleGraphConnection} */
342
+ (targetModule),
331
343
  [exportInfo.name],
332
344
  -1
333
345
  );
@@ -552,6 +564,7 @@ class ExportsInfo {
552
564
  return true;
553
565
  }
554
566
  }
567
+ /** @type {string[]} */
555
568
  const array = [];
556
569
  if (!this._exportsAreOrdered) this._sortExports();
557
570
  for (const exportInfo of this._exports.values()) {
@@ -604,7 +617,7 @@ class ExportsInfo {
604
617
  }
605
618
 
606
619
  /**
607
- * @param {string | string[]} name the name of the export
620
+ * @param {ExportInfoName | ExportInfoName[]} name the name of the export
608
621
  * @returns {boolean | undefined | null} if the export is provided
609
622
  */
610
623
  isExportProvided(name) {
@@ -665,7 +678,7 @@ class ExportsInfo {
665
678
  }
666
679
 
667
680
  /**
668
- * @param {string | string[]} name export name
681
+ * @param {ExportInfoName | ExportInfoName[]} name export name
669
682
  * @param {RuntimeSpec} runtime check usage for this runtime only
670
683
  * @returns {UsageStateType} usage status
671
684
  */
@@ -683,7 +696,7 @@ class ExportsInfo {
683
696
  }
684
697
 
685
698
  /**
686
- * @param {string | string[]} name the export name
699
+ * @param {ExportInfoName | ExportInfoName[]} name the export name
687
700
  * @param {RuntimeSpec} runtime check usage for this runtime only
688
701
  * @returns {UsedName} the used name
689
702
  */
@@ -698,7 +711,7 @@ class ExportsInfo {
698
711
  const x = info.getUsedName(name[0], runtime);
699
712
  if (x === false) return false;
700
713
  const arr =
701
- /** @type {string[]} */
714
+ /** @type {ExportInfoName[]} */
702
715
  (x === name[0] && name.length === 1 ? name : [x]);
703
716
  if (name.length === 1) {
704
717
  return arr;
@@ -755,6 +768,7 @@ class ExportsInfo {
755
768
  const otherProvided = this._otherExportsInfo.provided;
756
769
  const otherCanMangleProvide = this._otherExportsInfo.canMangleProvide;
757
770
  const otherTerminalBinding = this._otherExportsInfo.terminalBinding;
771
+ /** @type {RestoreProvidedDataExports[]} */
758
772
  const exports = [];
759
773
  for (const exportInfo of this.orderedExports) {
760
774
  if (
@@ -827,19 +841,24 @@ class ExportsInfo {
827
841
  /** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */
828
842
 
829
843
  /** @typedef {{ connection: ModuleGraphConnection, export: string[], priority: number }} TargetItem */
844
+
830
845
  /** @typedef {Map<Dependency | undefined, TargetItem>} Target */
831
846
 
847
+ /** @typedef {string} ExportInfoName */
848
+ /** @typedef {string | null} ExportInfoUsedName */
849
+ /** @typedef {boolean | null} ExportInfoProvided */
850
+
832
851
  class ExportInfo {
833
852
  /**
834
- * @param {string} name the original name of the export
853
+ * @param {ExportInfoName} name the original name of the export
835
854
  * @param {ExportInfo=} initFrom init values from this ExportInfo
836
855
  */
837
856
  constructor(name, initFrom) {
838
- /** @type {string} */
857
+ /** @type {ExportInfoName} */
839
858
  this.name = name;
840
859
  /**
841
860
  * @private
842
- * @type {string | null}
861
+ * @type {ExportInfoUsedName}
843
862
  */
844
863
  this._usedName = initFrom ? initFrom._usedName : null;
845
864
  /**
@@ -867,7 +886,7 @@ class ExportInfo {
867
886
  * false: it is not provided
868
887
  * null: only the runtime knows if it is provided
869
888
  * undefined: it was not determined if it is provided
870
- * @type {boolean | null | undefined}
889
+ * @type {ExportInfoProvided | undefined}
871
890
  */
872
891
  this.provided = initFrom ? initFrom.provided : undefined;
873
892
  /**
@@ -28,6 +28,7 @@ const propertyAccess = require("./util/propertyAccess");
28
28
  const { register } = require("./util/serialization");
29
29
 
30
30
  /** @typedef {import("webpack-sources").Source} Source */
31
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
31
32
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
32
33
  /** @typedef {import("./Chunk")} Chunk */
33
34
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
@@ -58,7 +59,6 @@ const { register } = require("./util/serialization");
58
59
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
59
60
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
60
61
  /** @typedef {import("./util/Hash")} Hash */
61
- /** @typedef {typeof import("./util/Hash")} HashConstructor */
62
62
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
63
63
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
64
64
 
@@ -215,9 +215,10 @@ const getSourceForImportExternal = (
215
215
  };
216
216
 
217
217
  /**
218
- * @param {string} key key
219
- * @param {TODO | undefined} value value
220
- * @returns {undefined | string} replaced value
218
+ * @template {{ [key: string]: string }} T
219
+ * @param {keyof T} key key
220
+ * @param {T[keyof T]} value value
221
+ * @returns {undefined | T[keyof T]} replaced value
221
222
  */
222
223
  const importAssertionReplacer = (key, value) => {
223
224
  if (key === "_isLegacyAssert") {
@@ -235,7 +236,7 @@ class ModuleExternalInitFragment extends InitFragment {
235
236
  * @param {string} request import source
236
237
  * @param {string=} ident recomputed ident
237
238
  * @param {ImportDependencyMeta=} dependencyMeta the dependency meta
238
- * @param {string | HashConstructor=} hashFunction the hash function to use
239
+ * @param {HashFunction=} hashFunction the hash function to use
239
240
  */
240
241
  constructor(
241
242
  request,
@@ -10,6 +10,8 @@ const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
10
10
  /** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
11
11
  /** @typedef {import("./Compiler")} Compiler */
12
12
 
13
+ const PLUGIN_NAME = "ExternalsPlugin";
14
+
13
15
  class ExternalsPlugin {
14
16
  /**
15
17
  * @param {string | undefined} type default external type
@@ -26,7 +28,7 @@ class ExternalsPlugin {
26
28
  * @returns {void}
27
29
  */
28
30
  apply(compiler) {
29
- compiler.hooks.compile.tap("ExternalsPlugin", ({ normalModuleFactory }) => {
31
+ compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
30
32
  new ExternalModuleFactoryPlugin(this.type, this.externals).apply(
31
33
  normalModuleFactory
32
34
  );
@@ -24,7 +24,7 @@ const processAsyncTree = require("./util/processAsyncTree");
24
24
  /** @typedef {import("./logging/Logger").Logger} Logger */
25
25
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
26
26
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
27
- /** @typedef {typeof import("./util/Hash")} Hash */
27
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
28
28
  /** @typedef {import("./util/fs").IStats} IStats */
29
29
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
30
30
  /** @typedef {import("./util/fs").PathLike} PathLike */
@@ -1058,7 +1058,7 @@ class FileSystemInfo {
1058
1058
  * @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
1059
1059
  * @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
1060
1060
  * @param {Logger=} options.logger logger used to log invalid snapshots
1061
- * @param {string | Hash=} options.hashFunction the hash function to use
1061
+ * @param {HashFunction=} options.hashFunction the hash function to use
1062
1062
  */
1063
1063
  constructor(
1064
1064
  fs,
@@ -369,7 +369,8 @@ class FlagDependencyExportsPlugin {
369
369
  (module, callback) => {
370
370
  if (
371
371
  typeof (
372
- /** @type {BuildInfo} */ (module.buildInfo).hash
372
+ /** @type {BuildInfo} */
373
+ (module.buildInfo).hash
373
374
  ) !== "string"
374
375
  ) {
375
376
  // not cacheable
@@ -22,6 +22,8 @@ const validate = createSchemaValidation(
22
22
  }
23
23
  );
24
24
 
25
+ const PLUGIN_NAME = "IgnorePlugin";
26
+
25
27
  class IgnorePlugin {
26
28
  /**
27
29
  * @param {IgnorePluginOptions} options IgnorePlugin options
@@ -69,8 +71,8 @@ class IgnorePlugin {
69
71
  * @returns {void}
70
72
  */
71
73
  apply(compiler) {
72
- compiler.hooks.normalModuleFactory.tap("IgnorePlugin", nmf => {
73
- nmf.hooks.beforeResolve.tap("IgnorePlugin", resolveData => {
74
+ compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, nmf => {
75
+ nmf.hooks.beforeResolve.tap(PLUGIN_NAME, resolveData => {
74
76
  const result = this.checkIgnore(resolveData);
75
77
 
76
78
  if (
@@ -88,8 +90,8 @@ class IgnorePlugin {
88
90
  return result;
89
91
  });
90
92
  });
91
- compiler.hooks.contextModuleFactory.tap("IgnorePlugin", cmf => {
92
- cmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
93
+ compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
94
+ cmf.hooks.beforeResolve.tap(PLUGIN_NAME, this.checkIgnore);
93
95
  });
94
96
  }
95
97
  }
@@ -8,6 +8,8 @@
8
8
  /** @typedef {import("../declarations/WebpackOptions").IgnoreWarningsNormalized} IgnoreWarningsNormalized */
9
9
  /** @typedef {import("./Compiler")} Compiler */
10
10
 
11
+ const PLUGIN_NAME = "IgnoreWarningsPlugin";
12
+
11
13
  class IgnoreWarningsPlugin {
12
14
  /**
13
15
  * @param {IgnoreWarningsNormalized} ignoreWarnings conditions to ignore warnings
@@ -22,8 +24,8 @@ class IgnoreWarningsPlugin {
22
24
  * @returns {void}
23
25
  */
24
26
  apply(compiler) {
25
- compiler.hooks.compilation.tap("IgnoreWarningsPlugin", compilation => {
26
- compilation.hooks.processWarnings.tap("IgnoreWarningsPlugin", warnings =>
27
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
28
+ compilation.hooks.processWarnings.tap(PLUGIN_NAME, warnings =>
27
29
  warnings.filter(
28
30
  warning =>
29
31
  !this._ignoreWarnings.some(ignore => ignore(warning, compilation))
@@ -19,8 +19,8 @@ const { dirname, mkdirp } = require("./util/fs");
19
19
  /**
20
20
  * @typedef {object} ManifestModuleData
21
21
  * @property {string | number} id
22
- * @property {BuildMeta} buildMeta
23
- * @property {boolean | string[] | undefined} exports
22
+ * @property {BuildMeta=} buildMeta
23
+ * @property {boolean | string[]=} exports
24
24
  */
25
25
 
26
26
  /**
@@ -33,6 +33,8 @@ const { dirname, mkdirp } = require("./util/fs");
33
33
  * @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
34
34
  */
35
35
 
36
+ const PLUGIN_NAME = "LibManifestPlugin";
37
+
36
38
  class LibManifestPlugin {
37
39
  /**
38
40
  * @param {LibManifestPluginOptions} options the options
@@ -48,10 +50,7 @@ class LibManifestPlugin {
48
50
  */
49
51
  apply(compiler) {
50
52
  compiler.hooks.emit.tapAsync(
51
- {
52
- name: "LibManifestPlugin",
53
- stage: 110
54
- },
53
+ { name: PLUGIN_NAME, stage: 110 },
55
54
  (compilation, callback) => {
56
55
  const moduleGraph = compilation.moduleGraph;
57
56
  // store used paths to detect issue and output an error. #18200
@@ -28,6 +28,8 @@ const validate = createSchemaValidation(
28
28
  }
29
29
  );
30
30
 
31
+ const PLUGIN_NAME = "LoaderOptionsPlugin";
32
+
31
33
  class LoaderOptionsPlugin {
32
34
  /**
33
35
  * @param {LoaderOptionsPluginOptions & MatchObject} options options object
@@ -55,9 +57,9 @@ class LoaderOptionsPlugin {
55
57
  */
56
58
  apply(compiler) {
57
59
  const options = this.options;
58
- compiler.hooks.compilation.tap("LoaderOptionsPlugin", compilation => {
60
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
59
61
  NormalModule.getCompilationHooks(compilation).loader.tap(
60
- "LoaderOptionsPlugin",
62
+ PLUGIN_NAME,
61
63
  (context, module) => {
62
64
  const resource = module.resource;
63
65
  if (!resource) return;
@@ -9,6 +9,8 @@ const NormalModule = require("./NormalModule");
9
9
 
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
 
12
+ const PLUGIN_NAME = "LoaderTargetPlugin";
13
+
12
14
  class LoaderTargetPlugin {
13
15
  /**
14
16
  * @param {string} target the target
@@ -23,9 +25,9 @@ class LoaderTargetPlugin {
23
25
  * @returns {void}
24
26
  */
25
27
  apply(compiler) {
26
- compiler.hooks.compilation.tap("LoaderTargetPlugin", compilation => {
28
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
27
29
  NormalModule.getCompilationHooks(compilation).loader.tap(
28
- "LoaderTargetPlugin",
30
+ PLUGIN_NAME,
29
31
  loaderContext => {
30
32
  loaderContext.target = this.target;
31
33
  }
package/lib/Module.js CHANGED
@@ -28,6 +28,7 @@ const makeSerializable = require("./util/makeSerializable");
28
28
  /** @typedef {import("./ConcatenationScope")} ConcatenationScope */
29
29
  /** @typedef {import("./Dependency")} Dependency */
30
30
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
31
+ /** @typedef {import("./DependencyTemplate").CssData} CssData */
31
32
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
32
33
  /** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
33
34
  /** @typedef {import("./FileSystemInfo")} FileSystemInfo */
@@ -120,19 +121,25 @@ const makeSerializable = require("./util/makeSerializable");
120
121
  * @typedef {object} KnownBuildInfo
121
122
  * @property {boolean=} cacheable
122
123
  * @property {boolean=} parsed
123
- * @property {string=} moduleArgument
124
- * @property {string=} exportsArgument
125
124
  * @property {boolean=} strict
126
- * @property {string=} moduleConcatenationBailout
127
- * @property {LazySet<string>=} fileDependencies
128
- * @property {LazySet<string>=} contextDependencies
129
- * @property {LazySet<string>=} missingDependencies
130
- * @property {LazySet<string>=} buildDependencies
131
- * @property {ValueCacheVersions=} valueDependencies
132
- * @property {TODO=} hash
133
- * @property {Record<string, Source>=} assets
134
- * @property {Map<string, AssetInfo | undefined>=} assetsInfo
135
- * @property {(Snapshot | null)=} snapshot
125
+ * @property {string=} moduleArgument using in AMD
126
+ * @property {string=} exportsArgument using in AMD
127
+ * @property {string=} moduleConcatenationBailout using in CommonJs
128
+ * @property {boolean=} needCreateRequire using in APIPlugin
129
+ * @property {string=} resourceIntegrity using in HttpUriPlugin
130
+ * @property {LazySet<string>=} fileDependencies using in NormalModule
131
+ * @property {LazySet<string>=} contextDependencies using in NormalModule
132
+ * @property {LazySet<string>=} missingDependencies using in NormalModule
133
+ * @property {LazySet<string>=} buildDependencies using in NormalModule
134
+ * @property {ValueCacheVersions=} valueDependencies using in NormalModule
135
+ * @property {Record<string, Source>=} assets using in NormalModule
136
+ * @property {string=} hash using in NormalModule
137
+ * @property {(Snapshot | null)=} snapshot using in ContextModule
138
+ * @property {string=} fullContentHash for assets modules
139
+ * @property {string=} filename for assets modules
140
+ * @property {Map<string, AssetInfo | undefined>=} assetsInfo for assets modules
141
+ * @property {boolean=} dataUrl for assets modules
142
+ * @property {CssData=} cssData for css modules
136
143
  */
137
144
 
138
145
  /** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */
@@ -10,10 +10,11 @@ const { DEFAULTS } = require("./config/defaults");
10
10
  const createHash = require("./util/createHash");
11
11
  const memoize = require("./util/memoize");
12
12
 
13
+ /** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
14
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
13
15
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
14
16
  /** @typedef {import("./Module")} Module */
15
17
  /** @typedef {import("./RequestShortener")} RequestShortener */
16
- /** @typedef {typeof import("./util/Hash")} Hash */
17
18
 
18
19
  /** @typedef {string | RegExp | (string | RegExp)[]} Matcher */
19
20
  /** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
@@ -76,7 +77,7 @@ const getBefore = (strFn, token) => () => {
76
77
  /**
77
78
  * Returns a function that returns a hash of the string
78
79
  * @param {ReturnStringCallback} strFn the function to get the string
79
- * @param {string | Hash=} hashFunction the hash function to use
80
+ * @param {HashFunction=} hashFunction the hash function to use
80
81
  * @returns {ReturnStringCallback} a function that returns the hash of the string
81
82
  */
82
83
  const getHash =
@@ -117,10 +118,13 @@ const lazyObject = obj => {
117
118
 
118
119
  const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
119
120
 
121
+ /** @typedef {((context: TODO) => string)} ModuleFilenameTemplateFunction */
122
+ /** @typedef {string | ModuleFilenameTemplateFunction} ModuleFilenameTemplate */
123
+
120
124
  /**
121
125
  * @param {Module | string} module the module
122
- * @param {{ namespace?: string, moduleFilenameTemplate?: string | TODO }} options options
123
- * @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: string | Hash }} contextInfo context info
126
+ * @param {{ namespace?: string, moduleFilenameTemplate?: ModuleFilenameTemplate }} options options
127
+ * @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: HashFunction }} contextInfo context info
124
128
  * @returns {string} the filename
125
129
  */
126
130
  ModuleFilenameHelpers.createFilename = (
@@ -149,6 +149,8 @@ const printExportsInfoToSource = (
149
149
  /** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */
150
150
  const caches = new WeakMap();
151
151
 
152
+ const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
153
+
152
154
  class ModuleInfoHeaderPlugin {
153
155
  /**
154
156
  * @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
@@ -163,11 +165,11 @@ class ModuleInfoHeaderPlugin {
163
165
  */
164
166
  apply(compiler) {
165
167
  const { _verbose: verbose } = this;
166
- compiler.hooks.compilation.tap("ModuleInfoHeaderPlugin", compilation => {
168
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
167
169
  const javascriptHooks =
168
170
  JavascriptModulesPlugin.getCompilationHooks(compilation);
169
171
  javascriptHooks.renderModulePackage.tap(
170
- "ModuleInfoHeaderPlugin",
172
+ PLUGIN_NAME,
171
173
  (
172
174
  moduleSource,
173
175
  module,
@@ -246,16 +248,13 @@ class ModuleInfoHeaderPlugin {
246
248
  return cachedSource;
247
249
  }
248
250
  );
249
- javascriptHooks.chunkHash.tap(
250
- "ModuleInfoHeaderPlugin",
251
- (_chunk, hash) => {
252
- hash.update("ModuleInfoHeaderPlugin");
253
- hash.update("1");
254
- }
255
- );
251
+ javascriptHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
252
+ hash.update(PLUGIN_NAME);
253
+ hash.update("1");
254
+ });
256
255
  const cssHooks = CssModulesPlugin.getCompilationHooks(compilation);
257
256
  cssHooks.renderModulePackage.tap(
258
- "ModuleInfoHeaderPlugin",
257
+ PLUGIN_NAME,
259
258
  (moduleSource, module, { runtimeTemplate }) => {
260
259
  const { requestShortener } = runtimeTemplate;
261
260
  let cacheEntry;
@@ -291,8 +290,8 @@ class ModuleInfoHeaderPlugin {
291
290
  return cachedSource;
292
291
  }
293
292
  );
294
- cssHooks.chunkHash.tap("ModuleInfoHeaderPlugin", (_chunk, hash) => {
295
- hash.update("ModuleInfoHeaderPlugin");
293
+ cssHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
294
+ hash.update(PLUGIN_NAME);
296
295
  hash.update("1");
297
296
  });
298
297
  });
@@ -44,6 +44,8 @@ const ArrayQueue = require("./util/ArrayQueue");
44
44
  * @property {number=} parallelism how many Compilers are allows to run at the same time in parallel
45
45
  */
46
46
 
47
+ const CLASS_NAME = "MultiCompiler";
48
+
47
49
  module.exports = class MultiCompiler {
48
50
  /**
49
51
  * @param {Compiler[] | Record<string, Compiler>} compilers child compilers
@@ -92,7 +94,7 @@ module.exports = class MultiCompiler {
92
94
  const compilerIndex = index;
93
95
  let compilerDone = false;
94
96
  // eslint-disable-next-line no-loop-func
95
- compiler.hooks.done.tap("MultiCompiler", stats => {
97
+ compiler.hooks.done.tap(CLASS_NAME, stats => {
96
98
  if (!compilerDone) {
97
99
  compilerDone = true;
98
100
  doneCompilers++;
@@ -105,7 +107,7 @@ module.exports = class MultiCompiler {
105
107
  }
106
108
  });
107
109
  // eslint-disable-next-line no-loop-func
108
- compiler.hooks.invalid.tap("MultiCompiler", () => {
110
+ compiler.hooks.invalid.tap(CLASS_NAME, () => {
109
111
  if (compilerDone) {
110
112
  compilerDone = false;
111
113
  doneCompilers--;
@@ -122,7 +124,7 @@ module.exports = class MultiCompiler {
122
124
  * @param {WebpackError} warning warning
123
125
  */
124
126
  const addWarning = (compiler, warning) => {
125
- compiler.hooks.thisCompilation.tap("MultiCompiler", compilation => {
127
+ compiler.hooks.thisCompilation.tap(CLASS_NAME, compilation => {
126
128
  compilation.warnings.push(warning);
127
129
  });
128
130
  };
@@ -7,6 +7,8 @@
7
7
 
8
8
  /** @typedef {import("./Compiler")} Compiler */
9
9
 
10
+ const PLUGIN_NAME = "NoEmitOnErrorsPlugin";
11
+
10
12
  class NoEmitOnErrorsPlugin {
11
13
  /**
12
14
  * Apply the plugin
@@ -14,11 +16,11 @@ class NoEmitOnErrorsPlugin {
14
16
  * @returns {void}
15
17
  */
16
18
  apply(compiler) {
17
- compiler.hooks.shouldEmit.tap("NoEmitOnErrorsPlugin", compilation => {
19
+ compiler.hooks.shouldEmit.tap(PLUGIN_NAME, compilation => {
18
20
  if (compilation.getStats().hasErrors()) return false;
19
21
  });
20
- compiler.hooks.compilation.tap("NoEmitOnErrorsPlugin", compilation => {
21
- compilation.hooks.shouldRecord.tap("NoEmitOnErrorsPlugin", () => {
22
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
23
+ compilation.hooks.shouldRecord.tap(PLUGIN_NAME, () => {
22
24
  if (compilation.getStats().hasErrors()) return false;
23
25
  });
24
26
  });