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
@@ -819,6 +819,16 @@ const ERROR_PRINTERS = {
819
819
  "error.filteredDetails": filteredDetails =>
820
820
  filteredDetails ? `+ ${filteredDetails} hidden lines` : undefined,
821
821
  "error.stack": stack => stack,
822
+ "error.cause": (cause, context, printer) =>
823
+ cause
824
+ ? indent(
825
+ `[cause]: ${
826
+ /** @type {string} */
827
+ (printer.print(`${context.type}.error`, cause, context))
828
+ }`,
829
+ " "
830
+ )
831
+ : undefined,
822
832
  "error.moduleTrace": moduleTrace => undefined,
823
833
  "error.separator!": () => "\n"
824
834
  };
@@ -925,6 +935,7 @@ const ITEM_NAMES = {
925
935
  "loggingEntry.children[]": logEntry =>
926
936
  `loggingEntry(${logEntry.type}).loggingEntry`,
927
937
  "error.moduleTrace[]": "moduleTraceItem",
938
+ "error.errors[]": "error",
928
939
  "moduleTraceItem.dependencies[]": "moduleTraceDependency"
929
940
  };
930
941
 
@@ -946,6 +957,8 @@ const ERROR_PREFERRED_ORDER = [
946
957
  "separator!",
947
958
  "stack",
948
959
  "separator!",
960
+ "cause",
961
+ "separator!",
949
962
  "missing",
950
963
  "separator!",
951
964
  "moduleTrace"
@@ -1388,28 +1401,6 @@ const SIMPLE_ELEMENT_JOINERS = {
1388
1401
  chunkGroupAsset: joinOneLine,
1389
1402
  chunkGroupChildGroup: joinOneLine,
1390
1403
  chunkGroupChild: joinOneLine,
1391
- // moduleReason: (items, { moduleReason }) => {
1392
- // let hasName = false;
1393
- // return joinOneLine(
1394
- // items.filter(item => {
1395
- // switch (item.element) {
1396
- // case "moduleId":
1397
- // if (moduleReason.moduleId === moduleReason.module && item.content)
1398
- // hasName = true;
1399
- // break;
1400
- // case "module":
1401
- // if (hasName) return false;
1402
- // break;
1403
- // case "resolvedModule":
1404
- // return (
1405
- // moduleReason.module !== moduleReason.resolvedModule &&
1406
- // item.content
1407
- // );
1408
- // }
1409
- // return true;
1410
- // })
1411
- // );
1412
- // },
1413
1404
  moduleReason: (items, { moduleReason }) => {
1414
1405
  let hasName = false;
1415
1406
  return joinExplicitNewLine(
@@ -1445,6 +1436,9 @@ const SIMPLE_ELEMENT_JOINERS = {
1445
1436
  chunkOrigin: items => `> ${joinOneLine(items)}`,
1446
1437
  "errors[].error": joinError(true),
1447
1438
  "warnings[].error": joinError(false),
1439
+ error: items => joinExplicitNewLine(items, ""),
1440
+ "error.errors[].error": items =>
1441
+ indent(`[errors]: ${joinExplicitNewLine(items, "")}`, " "),
1448
1442
  loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
1449
1443
  moduleTraceItem: items => ` @ ${joinOneLine(items)}`,
1450
1444
  moduleTraceDependency: joinOneLine
@@ -1585,6 +1579,8 @@ const createOrder = (array, preferredOrder) => {
1585
1579
  return array;
1586
1580
  };
1587
1581
 
1582
+ const PLUGIN_NAME = "DefaultStatsPrinterPlugin";
1583
+
1588
1584
  class DefaultStatsPrinterPlugin {
1589
1585
  /**
1590
1586
  * Apply the plugin
@@ -1592,332 +1588,301 @@ class DefaultStatsPrinterPlugin {
1592
1588
  * @returns {void}
1593
1589
  */
1594
1590
  apply(compiler) {
1595
- compiler.hooks.compilation.tap("DefaultStatsPrinterPlugin", compilation => {
1596
- compilation.hooks.statsPrinter.tap(
1597
- "DefaultStatsPrinterPlugin",
1598
- (stats, options) => {
1599
- // Put colors into context
1600
- stats.hooks.print
1601
- .for("compilation")
1602
- .tap("DefaultStatsPrinterPlugin", (compilation, context) => {
1603
- for (const color of Object.keys(AVAILABLE_COLORS)) {
1604
- const name =
1605
- /** @type {keyof KnownStatsPrinterColorFunctions} */
1606
- (color);
1607
- /** @type {string | undefined} */
1608
- let start;
1609
- if (options.colors) {
1610
- if (
1611
- typeof options.colors === "object" &&
1612
- typeof options.colors[name] === "string"
1613
- ) {
1614
- start = options.colors[name];
1615
- } else {
1616
- start = AVAILABLE_COLORS[name];
1617
- }
1618
- }
1619
- if (start) {
1620
- /** @type {ColorFunction} */
1621
- context[color] = str =>
1622
- `${start}${
1623
- typeof str === "string"
1624
- ? str.replace(
1625
- /((\u001B\[39m|\u001B\[22m|\u001B\[0m)+)/g,
1626
- `$1${start}`
1627
- )
1628
- : str
1629
- }\u001B[39m\u001B[22m`;
1591
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
1592
+ compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (stats, options) => {
1593
+ // Put colors into context
1594
+ stats.hooks.print
1595
+ .for("compilation")
1596
+ .tap(PLUGIN_NAME, (compilation, context) => {
1597
+ for (const color of Object.keys(AVAILABLE_COLORS)) {
1598
+ const name =
1599
+ /** @type {keyof KnownStatsPrinterColorFunctions} */
1600
+ (color);
1601
+ /** @type {string | undefined} */
1602
+ let start;
1603
+ if (options.colors) {
1604
+ if (
1605
+ typeof options.colors === "object" &&
1606
+ typeof options.colors[name] === "string"
1607
+ ) {
1608
+ start = options.colors[name];
1630
1609
  } else {
1631
- /**
1632
- * @param {string} str string
1633
- * @returns {string} str string
1634
- */
1635
- context[color] = str => str;
1610
+ start = AVAILABLE_COLORS[name];
1636
1611
  }
1637
1612
  }
1638
- for (const format of Object.keys(AVAILABLE_FORMATS)) {
1639
- context[format] =
1640
- /**
1641
- * @param {string | number} content content
1642
- * @param {...TODO} args args
1643
- * @returns {string} result
1644
- */
1645
- (content, ...args) =>
1646
- /** @type {TODO} */
1647
- (
1648
- AVAILABLE_FORMATS[
1649
- /** @type {keyof AvailableFormats} */
1650
- (format)
1651
- ]
1652
- )(
1653
- content,
1654
- /** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
1655
- (context),
1656
- ...args
1657
- );
1613
+ if (start) {
1614
+ /** @type {ColorFunction} */
1615
+ context[color] = str =>
1616
+ `${start}${
1617
+ typeof str === "string"
1618
+ ? str.replace(
1619
+ /((\u001B\[39m|\u001B\[22m|\u001B\[0m)+)/g,
1620
+ `$1${start}`
1621
+ )
1622
+ : str
1623
+ }\u001B[39m\u001B[22m`;
1624
+ } else {
1625
+ /**
1626
+ * @param {string} str string
1627
+ * @returns {string} str string
1628
+ */
1629
+ context[color] = str => str;
1658
1630
  }
1659
- context.timeReference = compilation.time;
1631
+ }
1632
+ for (const format of Object.keys(AVAILABLE_FORMATS)) {
1633
+ context[format] =
1634
+ /**
1635
+ * @param {string | number} content content
1636
+ * @param {...TODO} args args
1637
+ * @returns {string} result
1638
+ */
1639
+ (content, ...args) =>
1640
+ /** @type {TODO} */
1641
+ (
1642
+ AVAILABLE_FORMATS[
1643
+ /** @type {keyof AvailableFormats} */
1644
+ (format)
1645
+ ]
1646
+ )(
1647
+ content,
1648
+ /** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
1649
+ (context),
1650
+ ...args
1651
+ );
1652
+ }
1653
+ context.timeReference = compilation.time;
1654
+ });
1655
+
1656
+ for (const key of Object.keys(COMPILATION_SIMPLE_PRINTERS)) {
1657
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1658
+ /** @type {TODO} */
1659
+ (
1660
+ COMPILATION_SIMPLE_PRINTERS[
1661
+ /** @type {keyof CompilationSimplePrinters} */
1662
+ (key)
1663
+ ]
1664
+ )(
1665
+ obj,
1666
+ /** @type {DefineStatsPrinterContext<"compilation">} */
1667
+ (ctx),
1668
+ stats
1669
+ )
1670
+ );
1671
+ }
1672
+
1673
+ for (const key of Object.keys(ASSET_SIMPLE_PRINTERS)) {
1674
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1675
+ /** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */
1676
+ (
1677
+ ASSET_SIMPLE_PRINTERS[
1678
+ /** @type {keyof AssetSimplePrinters} */
1679
+ (key)
1680
+ ]
1681
+ )(
1682
+ obj,
1683
+ /** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */
1684
+ (ctx),
1685
+ stats
1686
+ )
1687
+ );
1688
+ }
1689
+
1690
+ for (const key of Object.keys(MODULE_SIMPLE_PRINTERS)) {
1691
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1692
+ /** @type {TODO} */
1693
+ (
1694
+ MODULE_SIMPLE_PRINTERS[
1695
+ /** @type {keyof ModuleSimplePrinters} */
1696
+ (key)
1697
+ ]
1698
+ )(
1699
+ obj,
1700
+ /** @type {DefineStatsPrinterContext<"module">} */
1701
+ (ctx),
1702
+ stats
1703
+ )
1704
+ );
1705
+ }
1706
+
1707
+ for (const key of Object.keys(MODULE_ISSUER_PRINTERS)) {
1708
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1709
+ /** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */
1710
+ (
1711
+ MODULE_ISSUER_PRINTERS[
1712
+ /** @type {keyof ModuleIssuerPrinters} */
1713
+ (key)
1714
+ ]
1715
+ )(
1716
+ obj,
1717
+ /** @type {DefineStatsPrinterContext<"moduleIssuer">} */
1718
+ (ctx),
1719
+ stats
1720
+ )
1721
+ );
1722
+ }
1723
+
1724
+ for (const key of Object.keys(MODULE_REASON_PRINTERS)) {
1725
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1726
+ /** @type {TODO} */
1727
+ (
1728
+ MODULE_REASON_PRINTERS[
1729
+ /** @type {keyof ModuleReasonsPrinters} */
1730
+ (key)
1731
+ ]
1732
+ )(
1733
+ obj,
1734
+ /** @type {DefineStatsPrinterContext<"moduleReason">} */
1735
+ (ctx),
1736
+ stats
1737
+ )
1738
+ );
1739
+ }
1740
+
1741
+ for (const key of Object.keys(MODULE_PROFILE_PRINTERS)) {
1742
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1743
+ /** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */
1744
+ (
1745
+ MODULE_PROFILE_PRINTERS[
1746
+ /** @type {keyof ModuleProfilePrinters} */
1747
+ (key)
1748
+ ]
1749
+ )(
1750
+ obj,
1751
+ /** @type {DefineStatsPrinterContext<"profile">} */
1752
+ (ctx),
1753
+ stats
1754
+ )
1755
+ );
1756
+ }
1757
+
1758
+ for (const key of Object.keys(CHUNK_GROUP_PRINTERS)) {
1759
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1760
+ /** @type {TODO} */
1761
+ (
1762
+ CHUNK_GROUP_PRINTERS[
1763
+ /** @type {keyof ChunkGroupPrinters} */
1764
+ (key)
1765
+ ]
1766
+ )(
1767
+ obj,
1768
+ /** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */
1769
+ (ctx),
1770
+ stats
1771
+ )
1772
+ );
1773
+ }
1774
+
1775
+ for (const key of Object.keys(CHUNK_PRINTERS)) {
1776
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1777
+ /** @type {TODO} */
1778
+ (CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])(
1779
+ obj,
1780
+ /** @type {DefineStatsPrinterContext<"chunk">} */
1781
+ (ctx),
1782
+ stats
1783
+ )
1784
+ );
1785
+ }
1786
+
1787
+ for (const key of Object.keys(ERROR_PRINTERS)) {
1788
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1789
+ /** @type {TODO} */
1790
+ (ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])(
1791
+ obj,
1792
+ /** @type {DefineStatsPrinterContext<"error">} */
1793
+ (ctx),
1794
+ stats
1795
+ )
1796
+ );
1797
+ }
1798
+
1799
+ for (const key of Object.keys(LOG_ENTRY_PRINTERS)) {
1800
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1801
+ /** @type {TODO} */
1802
+ (
1803
+ LOG_ENTRY_PRINTERS[
1804
+ /** @type {keyof LogEntryPrinters} */
1805
+ (key)
1806
+ ]
1807
+ )(
1808
+ obj,
1809
+ /** @type {DefineStatsPrinterContext<"logging">} */
1810
+ (ctx),
1811
+ stats
1812
+ )
1813
+ );
1814
+ }
1815
+
1816
+ for (const key of Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)) {
1817
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1818
+ /** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */
1819
+ (
1820
+ MODULE_TRACE_DEPENDENCY_PRINTERS[
1821
+ /** @type {keyof ModuleTraceDependencyPrinters} */
1822
+ (key)
1823
+ ]
1824
+ )(
1825
+ obj,
1826
+ /** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */
1827
+ (ctx),
1828
+ stats
1829
+ )
1830
+ );
1831
+ }
1832
+
1833
+ for (const key of Object.keys(MODULE_TRACE_ITEM_PRINTERS)) {
1834
+ stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1835
+ /** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */
1836
+ (
1837
+ MODULE_TRACE_ITEM_PRINTERS[
1838
+ /** @type {keyof ModuleTraceItemPrinters} */
1839
+ (key)
1840
+ ]
1841
+ )(
1842
+ obj,
1843
+ /** @type {DefineStatsPrinterContext<"moduleTraceItem">} */
1844
+ (ctx),
1845
+ stats
1846
+ )
1847
+ );
1848
+ }
1849
+
1850
+ for (const key of Object.keys(PREFERRED_ORDERS)) {
1851
+ const preferredOrder = PREFERRED_ORDERS[key];
1852
+ stats.hooks.sortElements
1853
+ .for(key)
1854
+ .tap(PLUGIN_NAME, (elements, context) => {
1855
+ createOrder(elements, preferredOrder);
1660
1856
  });
1857
+ }
1661
1858
 
1662
- for (const key of Object.keys(COMPILATION_SIMPLE_PRINTERS)) {
1663
- stats.hooks.print
1664
- .for(key)
1665
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1666
- /** @type {TODO} */
1667
- (
1668
- COMPILATION_SIMPLE_PRINTERS[
1669
- /** @type {keyof CompilationSimplePrinters} */
1670
- (key)
1671
- ]
1672
- )(
1673
- obj,
1674
- /** @type {DefineStatsPrinterContext<"compilation">} */
1675
- (ctx),
1676
- stats
1677
- )
1678
- );
1679
- }
1680
-
1681
- for (const key of Object.keys(ASSET_SIMPLE_PRINTERS)) {
1682
- stats.hooks.print
1683
- .for(key)
1684
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1685
- /** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */
1686
- (
1687
- ASSET_SIMPLE_PRINTERS[
1688
- /** @type {keyof AssetSimplePrinters} */
1689
- (key)
1690
- ]
1691
- )(
1692
- obj,
1693
- /** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */
1694
- (ctx),
1695
- stats
1696
- )
1697
- );
1698
- }
1699
-
1700
- for (const key of Object.keys(MODULE_SIMPLE_PRINTERS)) {
1701
- stats.hooks.print
1702
- .for(key)
1703
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1704
- /** @type {TODO} */
1705
- (
1706
- MODULE_SIMPLE_PRINTERS[
1707
- /** @type {keyof ModuleSimplePrinters} */
1708
- (key)
1709
- ]
1710
- )(
1711
- obj,
1712
- /** @type {DefineStatsPrinterContext<"module">} */
1713
- (ctx),
1714
- stats
1715
- )
1716
- );
1717
- }
1718
-
1719
- for (const key of Object.keys(MODULE_ISSUER_PRINTERS)) {
1720
- stats.hooks.print
1721
- .for(key)
1722
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1723
- /** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */
1724
- (
1725
- MODULE_ISSUER_PRINTERS[
1726
- /** @type {keyof ModuleIssuerPrinters} */
1727
- (key)
1728
- ]
1729
- )(
1730
- obj,
1731
- /** @type {DefineStatsPrinterContext<"moduleIssuer">} */
1732
- (ctx),
1733
- stats
1734
- )
1735
- );
1736
- }
1737
-
1738
- for (const key of Object.keys(MODULE_REASON_PRINTERS)) {
1739
- stats.hooks.print
1740
- .for(key)
1741
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1742
- /** @type {TODO} */
1743
- (
1744
- MODULE_REASON_PRINTERS[
1745
- /** @type {keyof ModuleReasonsPrinters} */
1746
- (key)
1747
- ]
1748
- )(
1749
- obj,
1750
- /** @type {DefineStatsPrinterContext<"moduleReason">} */
1751
- (ctx),
1752
- stats
1753
- )
1754
- );
1755
- }
1756
-
1757
- for (const key of Object.keys(MODULE_PROFILE_PRINTERS)) {
1758
- stats.hooks.print
1759
- .for(key)
1760
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1761
- /** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */
1762
- (
1763
- MODULE_PROFILE_PRINTERS[
1764
- /** @type {keyof ModuleProfilePrinters} */
1765
- (key)
1766
- ]
1767
- )(
1768
- obj,
1769
- /** @type {DefineStatsPrinterContext<"profile">} */
1770
- (ctx),
1771
- stats
1772
- )
1773
- );
1774
- }
1775
-
1776
- for (const key of Object.keys(CHUNK_GROUP_PRINTERS)) {
1777
- stats.hooks.print
1778
- .for(key)
1779
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1780
- /** @type {TODO} */
1781
- (
1782
- CHUNK_GROUP_PRINTERS[
1783
- /** @type {keyof ChunkGroupPrinters} */
1784
- (key)
1785
- ]
1786
- )(
1787
- obj,
1788
- /** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */
1789
- (ctx),
1790
- stats
1791
- )
1792
- );
1793
- }
1794
-
1795
- for (const key of Object.keys(CHUNK_PRINTERS)) {
1796
- stats.hooks.print
1797
- .for(key)
1798
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1799
- /** @type {TODO} */
1800
- (CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])(
1801
- obj,
1802
- /** @type {DefineStatsPrinterContext<"chunk">} */
1803
- (ctx),
1804
- stats
1805
- )
1806
- );
1807
- }
1808
-
1809
- for (const key of Object.keys(ERROR_PRINTERS)) {
1810
- stats.hooks.print
1811
- .for(key)
1812
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1813
- /** @type {TODO} */
1814
- (ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])(
1815
- obj,
1816
- /** @type {DefineStatsPrinterContext<"error">} */
1817
- (ctx),
1818
- stats
1819
- )
1820
- );
1821
- }
1822
-
1823
- for (const key of Object.keys(LOG_ENTRY_PRINTERS)) {
1824
- stats.hooks.print
1825
- .for(key)
1826
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1827
- /** @type {TODO} */
1828
- (
1829
- LOG_ENTRY_PRINTERS[
1830
- /** @type {keyof LogEntryPrinters} */
1831
- (key)
1832
- ]
1833
- )(
1834
- obj,
1835
- /** @type {DefineStatsPrinterContext<"logging">} */
1836
- (ctx),
1837
- stats
1838
- )
1839
- );
1840
- }
1841
-
1842
- for (const key of Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)) {
1843
- stats.hooks.print
1844
- .for(key)
1845
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1846
- /** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */
1847
- (
1848
- MODULE_TRACE_DEPENDENCY_PRINTERS[
1849
- /** @type {keyof ModuleTraceDependencyPrinters} */
1850
- (key)
1851
- ]
1852
- )(
1853
- obj,
1854
- /** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */
1855
- (ctx),
1856
- stats
1857
- )
1858
- );
1859
- }
1860
-
1861
- for (const key of Object.keys(MODULE_TRACE_ITEM_PRINTERS)) {
1862
- stats.hooks.print
1863
- .for(key)
1864
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
1865
- /** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */
1866
- (
1867
- MODULE_TRACE_ITEM_PRINTERS[
1868
- /** @type {keyof ModuleTraceItemPrinters} */
1869
- (key)
1870
- ]
1871
- )(
1872
- obj,
1873
- /** @type {DefineStatsPrinterContext<"moduleTraceItem">} */
1874
- (ctx),
1875
- stats
1876
- )
1877
- );
1878
- }
1879
-
1880
- for (const key of Object.keys(PREFERRED_ORDERS)) {
1881
- const preferredOrder = PREFERRED_ORDERS[key];
1882
- stats.hooks.sortElements
1883
- .for(key)
1884
- .tap("DefaultStatsPrinterPlugin", (elements, context) => {
1885
- createOrder(elements, preferredOrder);
1886
- });
1887
- }
1888
-
1889
- for (const key of Object.keys(ITEM_NAMES)) {
1890
- const itemName = ITEM_NAMES[key];
1891
- stats.hooks.getItemName
1892
- .for(key)
1893
- .tap(
1894
- "DefaultStatsPrinterPlugin",
1895
- typeof itemName === "string" ? () => itemName : itemName
1896
- );
1897
- }
1898
-
1899
- for (const key of Object.keys(SIMPLE_ITEMS_JOINER)) {
1900
- const joiner = SIMPLE_ITEMS_JOINER[key];
1901
- stats.hooks.printItems
1902
- .for(key)
1903
- .tap("DefaultStatsPrinterPlugin", joiner);
1904
- }
1905
-
1906
- for (const key of Object.keys(SIMPLE_ELEMENT_JOINERS)) {
1907
- const joiner = SIMPLE_ELEMENT_JOINERS[key];
1908
- stats.hooks.printElements
1909
- .for(key)
1910
- .tap("DefaultStatsPrinterPlugin", /** @type {TODO} */ (joiner));
1911
- }
1912
-
1913
- for (const key of Object.keys(RESULT_MODIFIER)) {
1914
- const modifier = RESULT_MODIFIER[key];
1915
- stats.hooks.result
1916
- .for(key)
1917
- .tap("DefaultStatsPrinterPlugin", modifier);
1918
- }
1859
+ for (const key of Object.keys(ITEM_NAMES)) {
1860
+ const itemName = ITEM_NAMES[key];
1861
+ stats.hooks.getItemName
1862
+ .for(key)
1863
+ .tap(
1864
+ PLUGIN_NAME,
1865
+ typeof itemName === "string" ? () => itemName : itemName
1866
+ );
1919
1867
  }
1920
- );
1868
+
1869
+ for (const key of Object.keys(SIMPLE_ITEMS_JOINER)) {
1870
+ const joiner = SIMPLE_ITEMS_JOINER[key];
1871
+ stats.hooks.printItems.for(key).tap(PLUGIN_NAME, joiner);
1872
+ }
1873
+
1874
+ for (const key of Object.keys(SIMPLE_ELEMENT_JOINERS)) {
1875
+ const joiner = SIMPLE_ELEMENT_JOINERS[key];
1876
+ stats.hooks.printElements
1877
+ .for(key)
1878
+ .tap(PLUGIN_NAME, /** @type {TODO} */ (joiner));
1879
+ }
1880
+
1881
+ for (const key of Object.keys(RESULT_MODIFIER)) {
1882
+ const modifier = RESULT_MODIFIER[key];
1883
+ stats.hooks.result.for(key).tap(PLUGIN_NAME, modifier);
1884
+ }
1885
+ });
1921
1886
  });
1922
1887
  }
1923
1888
  }