@rspack/core 1.0.9 → 1.0.11

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/dist/Dependency.d.ts +7 -6
  2. package/dist/Module.d.ts +19 -17
  3. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  4. package/dist/config/types.d.ts +545 -0
  5. package/dist/config/zod.d.ts +202 -1347
  6. package/dist/cssExtractHmr.js +224 -0
  7. package/dist/cssExtractLoader.js +277 -0
  8. package/dist/index.js +23347 -31
  9. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  10. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  11. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  12. package/package.json +8 -5
  13. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  14. package/compiled/json-parse-even-better-errors/index.js +0 -193
  15. package/compiled/json-parse-even-better-errors/package.json +0 -1
  16. package/compiled/neo-async/index.d.ts +0 -685
  17. package/compiled/neo-async/index.js +0 -9207
  18. package/compiled/neo-async/license +0 -22
  19. package/compiled/neo-async/package.json +0 -1
  20. package/compiled/zod-validation-error/index.d.ts +0 -41
  21. package/compiled/zod-validation-error/index.js +0 -335
  22. package/compiled/zod-validation-error/license +0 -9
  23. package/compiled/zod-validation-error/package.json +0 -1
  24. package/dist/Chunk.js +0 -118
  25. package/dist/ChunkGraph.js +0 -27
  26. package/dist/ChunkGroup.js +0 -76
  27. package/dist/Compilation.js +0 -854
  28. package/dist/Compiler.js +0 -920
  29. package/dist/ContextModuleFactory.js +0 -36
  30. package/dist/DependenciesBlock.js +0 -30
  31. package/dist/Dependency.js +0 -32
  32. package/dist/Entrypoint.js +0 -21
  33. package/dist/ErrorHelpers.js +0 -62
  34. package/dist/ExecuteModulePlugin.js +0 -46
  35. package/dist/FileSystem.js +0 -34
  36. package/dist/FileSystemInfo.js +0 -2
  37. package/dist/Module.js +0 -143
  38. package/dist/ModuleTypeConstants.js +0 -92
  39. package/dist/MultiCompiler.js +0 -440
  40. package/dist/MultiStats.js +0 -161
  41. package/dist/MultiWatching.js +0 -62
  42. package/dist/NormalModule.js +0 -97
  43. package/dist/NormalModuleFactory.js +0 -43
  44. package/dist/Resolver.js +0 -39
  45. package/dist/ResolverFactory.js +0 -61
  46. package/dist/RspackError.js +0 -21
  47. package/dist/RuleSetCompiler.js +0 -10
  48. package/dist/RuntimeGlobals.js +0 -357
  49. package/dist/RuntimeModule.js +0 -58
  50. package/dist/Stats.js +0 -161
  51. package/dist/Template.js +0 -206
  52. package/dist/Watching.js +0 -290
  53. package/dist/builtin-loader/index.js +0 -17
  54. package/dist/builtin-loader/lightningcss/index.js +0 -175
  55. package/dist/builtin-loader/swc/index.js +0 -5
  56. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  57. package/dist/builtin-loader/swc/react.js +0 -7
  58. package/dist/builtin-loader/swc/types.js +0 -2
  59. package/dist/builtin-plugin/APIPlugin.js +0 -6
  60. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  61. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  62. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  63. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  64. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  65. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  66. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  67. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  68. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  69. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  70. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  71. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  72. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  73. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  74. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  75. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  76. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  78. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  79. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  80. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  81. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  82. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  83. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  84. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  85. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  86. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  87. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  88. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  89. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  90. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  91. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  92. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  93. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  94. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  95. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  96. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  97. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  98. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  99. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  100. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  101. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  102. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  106. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  107. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  108. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  109. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  110. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  111. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  112. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  113. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  114. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  115. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  116. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  117. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  118. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  119. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  120. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  121. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  122. package/dist/builtin-plugin/base.js +0 -58
  123. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  124. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  125. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  126. package/dist/builtin-plugin/css-extract/index.js +0 -105
  127. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  128. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  129. package/dist/builtin-plugin/index.js +0 -84
  130. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  131. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  132. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  133. package/dist/config/adapter.js +0 -691
  134. package/dist/config/adapterRuleUse.js +0 -107
  135. package/dist/config/browserslistTargetHandler.js +0 -345
  136. package/dist/config/defaults.js +0 -876
  137. package/dist/config/index.js +0 -20
  138. package/dist/config/normalization.js +0 -299
  139. package/dist/config/target.js +0 -318
  140. package/dist/config/types.js +0 -3
  141. package/dist/config/zod.js +0 -1028
  142. package/dist/container/ContainerPlugin.js +0 -50
  143. package/dist/container/ContainerReferencePlugin.js +0 -49
  144. package/dist/container/ModuleFederationPlugin.js +0 -137
  145. package/dist/container/ModuleFederationPluginV1.js +0 -63
  146. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  147. package/dist/container/options.js +0 -48
  148. package/dist/error/ConcurrentCompilationError.js +0 -20
  149. package/dist/exports.js +0 -183
  150. package/dist/lib/AbstractMethodError.js +0 -51
  151. package/dist/lib/Cache.js +0 -111
  152. package/dist/lib/CacheFacade.js +0 -321
  153. package/dist/lib/Dependency.js +0 -11
  154. package/dist/lib/EntryOptionPlugin.js +0 -89
  155. package/dist/lib/EnvironmentPlugin.js +0 -57
  156. package/dist/lib/HookWebpackError.js +0 -83
  157. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  158. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  159. package/dist/lib/LoaderTargetPlugin.js +0 -37
  160. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  161. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  162. package/dist/lib/WebpackError.js +0 -20
  163. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  164. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  165. package/dist/lib/cache/mergeEtags.js +0 -74
  166. package/dist/lib/formatLocation.js +0 -64
  167. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  168. package/dist/loader-runner/index.js +0 -735
  169. package/dist/loader-runner/loadLoader.js +0 -64
  170. package/dist/logging/Logger.js +0 -143
  171. package/dist/logging/createConsoleLogger.js +0 -176
  172. package/dist/logging/runtime.js +0 -37
  173. package/dist/logging/truncateArgs.js +0 -81
  174. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  175. package/dist/node/NodeTemplatePlugin.js +0 -26
  176. package/dist/node/NodeWatchFileSystem.js +0 -144
  177. package/dist/node/nodeConsole.js +0 -146
  178. package/dist/rspack.js +0 -123
  179. package/dist/rspackOptionsApply.js +0 -274
  180. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  181. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  182. package/dist/sharing/SharePlugin.js +0 -66
  183. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  184. package/dist/sharing/utils.js +0 -8
  185. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  186. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  187. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  188. package/dist/stats/StatsFactory.js +0 -167
  189. package/dist/stats/StatsPrinter.js +0 -142
  190. package/dist/stats/statsFactoryUtils.js +0 -341
  191. package/dist/util/ArrayQueue.js +0 -108
  192. package/dist/util/AssetInfo.js +0 -39
  193. package/dist/util/IterableHelpers.js +0 -35
  194. package/dist/util/MergeCaller.js +0 -24
  195. package/dist/util/SizeFormatHelpers.js +0 -24
  196. package/dist/util/SplitChunkSize.js +0 -18
  197. package/dist/util/assertNotNil.js +0 -9
  198. package/dist/util/assetCondition.js +0 -2
  199. package/dist/util/bindingVersionCheck.js +0 -124
  200. package/dist/util/cleverMerge.js +0 -504
  201. package/dist/util/comparators.js +0 -108
  202. package/dist/util/createHash.js +0 -161
  203. package/dist/util/createReadonlyMap.js +0 -29
  204. package/dist/util/fake.js +0 -28
  205. package/dist/util/fs.js +0 -120
  206. package/dist/util/hash/BatchedHash.js +0 -69
  207. package/dist/util/hash/index.js +0 -39
  208. package/dist/util/hash/md4.js +0 -27
  209. package/dist/util/hash/wasm-hash.js +0 -167
  210. package/dist/util/hash/xxhash64.js +0 -27
  211. package/dist/util/identifier.js +0 -330
  212. package/dist/util/index.js +0 -123
  213. package/dist/util/memoize.js +0 -61
  214. package/dist/util/scheme.js +0 -57
  215. package/dist/util/smartGrouping.js +0 -148
  216. package/dist/util/source.js +0 -42
  217. package/dist/util/validate.js +0 -77
  218. package/dist/util/webpack.js +0 -27
  219. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
@@ -1,1069 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/tree/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/stats
5
- *
6
- * MIT Licensed
7
- * Author Tobias Koppers @sokra
8
- * Copyright (c) JS Foundation and other contributors
9
- * https://github.com/webpack/webpack/blob/main/LICENSE
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DefaultStatsPrinterPlugin = void 0;
13
- const SizeFormatHelpers_1 = require("../util/SizeFormatHelpers");
14
- const comparators_1 = require("../util/comparators");
15
- const DATA_URI_CONTENT_LENGTH = 16;
16
- const plural = (n, singular, plural) => n === 1 ? singular : plural;
17
- const printSizes = (sizes, { formatSize = (n) => `${n}` }) => {
18
- const keys = Object.keys(sizes);
19
- if (keys.length > 1) {
20
- return keys.map(key => `${formatSize(sizes[key])} (${key})`).join(" ");
21
- }
22
- if (keys.length === 1) {
23
- return formatSize(sizes[keys[0]]);
24
- }
25
- };
26
- const getResourceName = (resource) => {
27
- const dataUrl = /^data:[^,]+,/.exec(resource);
28
- if (!dataUrl)
29
- return resource;
30
- const len = dataUrl[0].length + DATA_URI_CONTENT_LENGTH;
31
- if (resource.length < len)
32
- return resource;
33
- return `${resource.slice(0, Math.min(resource.length - /* '..'.length */ 2, len))}..`;
34
- };
35
- const getModuleName = (name) => {
36
- const matchResourceMatch = /^([^!]+)!=!/.exec(name);
37
- const n = matchResourceMatch
38
- ? matchResourceMatch[0] +
39
- getResourceName(name.slice(matchResourceMatch[0].length))
40
- : name;
41
- const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(n) || [];
42
- return [prefix, getResourceName(resource)];
43
- };
44
- const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
45
- const twoDigit = (n) => (n >= 10 ? `${n}` : `0${n}`);
46
- const isValidId = (id) => {
47
- return typeof id === "number" || id;
48
- };
49
- const moreCount = (list, count) => {
50
- return list && list.length > 0 ? `+ ${count}` : `${count}`;
51
- };
52
- const SIMPLE_PRINTERS = {
53
- "compilation.summary!": (_, { type, bold, green, red, yellow, formatDateTime, formatTime, compilation: { name, hash, rspackVersion, time, builtAt, errorsCount, warningsCount } }) => {
54
- const root = type === "compilation.summary!";
55
- const warningsMessage = warningsCount && warningsCount > 0
56
- ? yellow(`${warningsCount} ${plural(warningsCount, "warning", "warnings")}`)
57
- : "";
58
- const errorsMessage = errorsCount && errorsCount > 0
59
- ? red(`${errorsCount} ${plural(errorsCount, "error", "errors")}`)
60
- : "";
61
- const timeMessage = root && time ? ` in ${formatTime(time)}` : "";
62
- const hashMessage = hash ? ` (${hash})` : "";
63
- const builtAtMessage = root && builtAt ? `${formatDateTime(builtAt)}: ` : "";
64
- const versionMessage = root && rspackVersion ? `Rspack ${rspackVersion}` : "";
65
- const nameMessage = root && name
66
- ? bold(name)
67
- : name
68
- ? `Child ${bold(name)}`
69
- : root
70
- ? ""
71
- : "Child";
72
- const subjectMessage = nameMessage && versionMessage
73
- ? `${nameMessage} (${versionMessage})`
74
- : versionMessage || nameMessage || "Rspack";
75
- let statusMessage;
76
- if (errorsMessage && warningsMessage) {
77
- statusMessage = `compiled with ${errorsMessage} and ${warningsMessage}`;
78
- }
79
- else if (errorsMessage) {
80
- statusMessage = `compiled with ${errorsMessage}`;
81
- }
82
- else if (warningsMessage) {
83
- statusMessage = `compiled with ${warningsMessage}`;
84
- }
85
- else if (errorsCount === 0 && warningsCount === 0) {
86
- statusMessage = `compiled ${green("successfully")}`;
87
- }
88
- else {
89
- statusMessage = "compiled";
90
- }
91
- if (builtAtMessage ||
92
- versionMessage ||
93
- errorsMessage ||
94
- warningsMessage ||
95
- (errorsCount === 0 && warningsCount === 0) ||
96
- timeMessage ||
97
- hashMessage)
98
- return `${builtAtMessage}${subjectMessage} ${statusMessage}${timeMessage}${hashMessage}`;
99
- },
100
- "compilation.filteredWarningDetailsCount": count => count
101
- ? `${count} ${plural(count, "warning has", "warnings have")} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`
102
- : undefined,
103
- "compilation.filteredErrorDetailsCount": (count, { yellow }) => count
104
- ? yellow(`${count} ${plural(count, "error has", "errors have")} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`)
105
- : undefined,
106
- "compilation.env": (env, { bold }) => env
107
- ? `Environment (--env): ${bold(JSON.stringify(env, null, 2))}`
108
- : undefined,
109
- "compilation.publicPath": (publicPath, { bold }) => `PublicPath: ${bold(publicPath || "(none)")}`,
110
- "compilation.entrypoints": (entrypoints, context, printer) => Array.isArray(entrypoints)
111
- ? undefined
112
- : printer.print(context.type, Object.values(entrypoints), {
113
- ...context,
114
- chunkGroupKind: "Entrypoint"
115
- }),
116
- "compilation.namedChunkGroups": (namedChunkGroups, context, printer) => {
117
- if (!Array.isArray(namedChunkGroups)) {
118
- const { compilation: { entrypoints } } = context;
119
- let chunkGroups = Object.values(namedChunkGroups);
120
- if (entrypoints) {
121
- chunkGroups = chunkGroups.filter(group => !Object.prototype.hasOwnProperty.call(entrypoints, group.name));
122
- }
123
- return printer.print(context.type, chunkGroups, {
124
- ...context,
125
- chunkGroupKind: "Chunk Group"
126
- });
127
- }
128
- },
129
- "compilation.assetsByChunkName": () => "",
130
- "compilation.filteredModules": (filteredModules, { compilation: { modules } }) => filteredModules > 0
131
- ? `${moreCount(modules, filteredModules)} ${plural(filteredModules, "module", "modules")}`
132
- : undefined,
133
- "compilation.filteredAssets": (filteredAssets, { compilation: { assets } }) => filteredAssets > 0
134
- ? `${moreCount(assets, filteredAssets)} ${plural(filteredAssets, "asset", "assets")}`
135
- : undefined,
136
- "compilation.logging": (logging, context, printer) => Array.isArray(logging)
137
- ? undefined
138
- : printer.print(context.type, Object.entries(logging).map(([name, value]) => ({
139
- ...value,
140
- name
141
- })), context),
142
- "compilation.warningsInChildren!": (_, { yellow, compilation }) => {
143
- if (!compilation.children &&
144
- compilation.warningsCount &&
145
- compilation.warningsCount > 0 &&
146
- compilation.warnings) {
147
- const childWarnings = compilation.warningsCount - compilation.warnings.length;
148
- if (childWarnings > 0) {
149
- return yellow(`${childWarnings} ${plural(childWarnings, "WARNING", "WARNINGS")} in child compilations${compilation.children
150
- ? ""
151
- : " (Use 'stats.children: true' resp. '--stats-children' for more details)"}`);
152
- }
153
- }
154
- },
155
- "compilation.errorsInChildren!": (_, { red, compilation }) => {
156
- if (!compilation.children &&
157
- compilation.errorsCount &&
158
- compilation.errorsCount > 0 &&
159
- compilation.errors) {
160
- const childErrors = compilation.errorsCount - compilation.errors.length;
161
- if (childErrors > 0) {
162
- return red(`${childErrors} ${plural(childErrors, "ERROR", "ERRORS")} in child compilations${compilation.children
163
- ? ""
164
- : " (Use 'stats.children: true' resp. '--stats-children' for more details)"}`);
165
- }
166
- }
167
- },
168
- "asset.type": type => type,
169
- "asset.name": (name, { formatFilename, asset: { isOverSizeLimit } }) => formatFilename(name, isOverSizeLimit),
170
- "asset.size": (size, { asset: { isOverSizeLimit }, yellow, green, formatSize }) => (isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size)),
171
- "asset.emitted": (emitted, { green, formatFlag }) => emitted ? green(formatFlag("emitted")) : undefined,
172
- "asset.comparedForEmit": (comparedForEmit, { yellow, formatFlag }) => comparedForEmit ? yellow(formatFlag("compared for emit")) : undefined,
173
- "asset.cached": (cached, { green, formatFlag }) => cached ? green(formatFlag("cached")) : undefined,
174
- "asset.isOverSizeLimit": (isOverSizeLimit, { yellow, formatFlag }) => isOverSizeLimit ? yellow?.(formatFlag("big")) : undefined,
175
- "asset.info.immutable": (immutable, { green, formatFlag }) => immutable ? green(formatFlag("immutable")) : undefined,
176
- "asset.info.javascriptModule": (javascriptModule, { formatFlag }) => javascriptModule ? formatFlag("javascript module") : undefined,
177
- "asset.info.sourceFilename": (sourceFilename, { formatFlag }) => sourceFilename
178
- ? formatFlag(sourceFilename === true
179
- ? "from source file"
180
- : `from: ${sourceFilename}`)
181
- : undefined,
182
- "asset.info.development": (development, { green, formatFlag }) => development ? green(formatFlag("dev")) : undefined,
183
- "asset.info.hotModuleReplacement": (hotModuleReplacement, { green, formatFlag }) => (hotModuleReplacement ? green(formatFlag("hmr")) : undefined),
184
- "asset.separator!": () => "\n",
185
- "asset.filteredRelated": (filteredRelated, { asset: { related } }) => filteredRelated > 0
186
- ? `${moreCount(related, filteredRelated)} related ${plural(filteredRelated, "asset", "assets")}`
187
- : undefined,
188
- "asset.filteredChildren": (filteredChildren, { asset: { children } }) => filteredChildren > 0
189
- ? `${moreCount(children, filteredChildren)} ${plural(filteredChildren, "asset", "assets")}`
190
- : undefined,
191
- assetChunk: (id, { formatChunkId }) => formatChunkId(id),
192
- assetChunkName: name => name,
193
- assetChunkIdHint: name => name,
194
- "module.type": type => (type !== "module" ? type : undefined),
195
- "module.id": (id, { formatModuleId }) => isValidId(id) ? formatModuleId(id) : undefined,
196
- "module.name": (name, { bold }) => {
197
- const [prefix, resource] = getModuleName(name);
198
- return `${prefix || ""}${bold(resource || "")}`;
199
- },
200
- "module.identifier": identifier => undefined,
201
- "module.layer": (layer, { formatLayer }) => layer ? formatLayer(layer) : undefined,
202
- "module.sizes": printSizes,
203
- "module.chunks[]": (id, { formatChunkId }) => formatChunkId(id),
204
- "module.depth": (depth, { formatFlag }) => depth !== null ? formatFlag(`depth ${depth}`) : undefined,
205
- "module.cacheable": (cacheable, { formatFlag, red }) => cacheable === false ? red(formatFlag("not cacheable")) : undefined,
206
- "module.orphan": (orphan, { formatFlag, yellow }) => orphan ? yellow(formatFlag("orphan")) : undefined,
207
- "module.runtime": (runtime, { formatFlag, yellow }) => runtime ? yellow(formatFlag("runtime")) : undefined,
208
- "module.optional": (optional, { formatFlag, yellow }) => optional ? yellow(formatFlag("optional")) : undefined,
209
- "module.dependent": (dependent, { formatFlag, cyan }) => dependent ? cyan(formatFlag("dependent")) : undefined,
210
- "module.built": (built, { formatFlag, yellow }) => built ? yellow(formatFlag("built")) : undefined,
211
- "module.codeGenerated": (codeGenerated, { formatFlag, yellow }) => codeGenerated ? yellow(formatFlag("code generated")) : undefined,
212
- "module.buildTimeExecuted": (buildTimeExecuted, { formatFlag, green }) => buildTimeExecuted ? green(formatFlag("build time executed")) : undefined,
213
- "module.cached": (cached, { formatFlag, green }) => cached ? green(formatFlag("cached")) : undefined,
214
- "module.assets": (assets, { formatFlag, magenta }) => assets?.length
215
- ? magenta(formatFlag(`${assets.length} ${plural(assets.length, "asset", "assets")}`))
216
- : undefined,
217
- "module.warnings": (warnings, { formatFlag, yellow }) => warnings === true
218
- ? yellow(formatFlag("warnings"))
219
- : warnings
220
- ? yellow(formatFlag(`${warnings} ${plural(warnings, "warning", "warnings")}`))
221
- : undefined,
222
- "module.errors": (errors, { formatFlag, red }) => errors === true
223
- ? red(formatFlag("errors"))
224
- : errors
225
- ? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`))
226
- : undefined,
227
- "module.providedExports": (providedExports, { formatFlag, cyan }) => {
228
- if (Array.isArray(providedExports)) {
229
- if (providedExports.length === 0)
230
- return cyan(formatFlag("no exports"));
231
- return cyan(formatFlag(`exports: ${providedExports.join(", ")}`));
232
- }
233
- },
234
- "module.usedExports": (usedExports, { formatFlag, cyan, module }) => {
235
- if (usedExports !== true) {
236
- if (usedExports === null)
237
- return cyan(formatFlag("used exports unknown"));
238
- if (usedExports === false)
239
- return cyan(formatFlag("module unused"));
240
- if (Array.isArray(usedExports)) {
241
- if (usedExports.length === 0)
242
- return cyan(formatFlag("no exports used"));
243
- const providedExportsCount = Array.isArray(module.providedExports)
244
- ? module.providedExports.length
245
- : null;
246
- if (providedExportsCount !== null &&
247
- providedExportsCount === usedExports.length) {
248
- return cyan(formatFlag("all exports used"));
249
- }
250
- return cyan(formatFlag(`only some exports used: ${usedExports.join(", ")}`));
251
- }
252
- }
253
- },
254
- "module.optimizationBailout[]": (optimizationBailout, { yellow }) => yellow(optimizationBailout),
255
- "module.issuerPath": (issuerPath, { module }) => module.profile ? undefined : "",
256
- "module.profile": profile => undefined,
257
- "module.filteredModules": (filteredModules, { module: { modules } }) => filteredModules > 0
258
- ? `${moreCount(modules, filteredModules)} nested ${plural(filteredModules, "module", "modules")}`
259
- : undefined,
260
- "module.filteredReasons": (filteredReasons, { module: { reasons } }) => filteredReasons > 0
261
- ? `${moreCount(reasons, filteredReasons)} ${plural(filteredReasons, "reason", "reasons")}`
262
- : undefined,
263
- "module.filteredChildren": (filteredChildren, { module: { children } }) => filteredChildren > 0
264
- ? `${moreCount(children, filteredChildren)} ${plural(filteredChildren, "module", "modules")}`
265
- : undefined,
266
- "module.separator!": () => "\n",
267
- "moduleIssuer.id": (id, { formatModuleId }) => formatModuleId(id),
268
- "moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value),
269
- "moduleReason.type": type => type,
270
- "moduleReason.userRequest": (userRequest, { cyan }) => cyan(getResourceName(userRequest)),
271
- "moduleReason.moduleId": (moduleId, { formatModuleId }) => isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
272
- "moduleReason.module": (module, { magenta }) => magenta(module),
273
- "moduleReason.loc": loc => loc,
274
- "moduleReason.explanation": (explanation, { cyan }) => cyan(explanation),
275
- "moduleReason.active": (active, { formatFlag }) => active ? undefined : formatFlag("inactive"),
276
- "moduleReason.resolvedModule": (module, { magenta }) => magenta(module),
277
- "moduleReason.filteredChildren": (filteredChildren, { moduleReason: { children } }) => filteredChildren > 0
278
- ? `${moreCount(children, filteredChildren)} ${plural(filteredChildren, "reason", "reasons")}`
279
- : undefined,
280
- "module.profile.total": (value, { formatTime }) => formatTime(value),
281
- "module.profile.resolving": (value, { formatTime }) => `resolving: ${formatTime(value)}`,
282
- "module.profile.restoring": (value, { formatTime }) => `restoring: ${formatTime(value)}`,
283
- "module.profile.integration": (value, { formatTime }) => `integration: ${formatTime(value)}`,
284
- "module.profile.building": (value, { formatTime }) => `building: ${formatTime(value)}`,
285
- "module.profile.storing": (value, { formatTime }) => `storing: ${formatTime(value)}`,
286
- "module.profile.additionalResolving": (value, { formatTime }) => value ? `additional resolving: ${formatTime(value)}` : undefined,
287
- "module.profile.additionalIntegration": (value, { formatTime }) => value ? `additional integration: ${formatTime(value)}` : undefined,
288
- "chunkGroup.kind!": (_, { chunkGroupKind }) => chunkGroupKind,
289
- "chunkGroup.separator!": () => "\n",
290
- "chunkGroup.name": (name, { bold }) => bold(name),
291
- "chunkGroup.isOverSizeLimit": (isOverSizeLimit, { formatFlag, yellow }) => isOverSizeLimit ? yellow(formatFlag("big")) : undefined,
292
- "chunkGroup.assetsSize": (size, { formatSize }) => size ? formatSize(size) : undefined,
293
- "chunkGroup.auxiliaryAssetsSize": (size, { formatSize }) => size ? `(${formatSize(size)})` : undefined,
294
- "chunkGroup.filteredAssets": (n, { chunkGroup: { assets } }) => n > 0
295
- ? `${moreCount(assets, n)} ${plural(n, "asset", "assets")}`
296
- : undefined,
297
- "chunkGroup.filteredAuxiliaryAssets": (n, { chunkGroup: { auxiliaryAssets } }) => n > 0
298
- ? `${moreCount(auxiliaryAssets, n)} auxiliary ${plural(n, "asset", "assets")}`
299
- : undefined,
300
- "chunkGroup.is!": () => "=",
301
- "chunkGroupAsset.name": (asset, { green }) => green(asset),
302
- "chunkGroupAsset.size": (size, { formatSize, chunkGroup }) => (chunkGroup.assets && chunkGroup.assets.length > 1) ||
303
- (chunkGroup.auxiliaryAssets && chunkGroup.auxiliaryAssets.length > 0)
304
- ? formatSize(size)
305
- : undefined,
306
- "chunkGroup.children": (children, context, printer) => Array.isArray(children)
307
- ? undefined
308
- : printer.print(context.type, Object.keys(children).map(key => ({
309
- type: key,
310
- children: children[key]
311
- })), context),
312
- "chunkGroupChildGroup.type": type => `${type}:`,
313
- "chunkGroupChild.assets[]": (file, { formatFilename }) => formatFilename(file),
314
- "chunkGroupChild.chunks[]": (id, { formatChunkId }) => formatChunkId(id),
315
- "chunkGroupChild.name": name => (name ? `(name: ${name})` : undefined),
316
- "chunk.id": (id, { formatChunkId }) => formatChunkId(id),
317
- "chunk.files[]": (file, { formatFilename }) => formatFilename(file),
318
- "chunk.names[]": name => name,
319
- "chunk.idHints[]": name => name,
320
- "chunk.runtime[]": name => name,
321
- "chunk.sizes": (sizes, context) => printSizes(sizes, context),
322
- "chunk.parents[]": (parents, context) => context.formatChunkId(parents, "parent"),
323
- "chunk.siblings[]": (siblings, context) => context.formatChunkId(siblings, "sibling"),
324
- "chunk.children[]": (children, context) => context.formatChunkId(children, "child"),
325
- "chunk.childrenByOrder": (childrenByOrder, context, printer) => {
326
- if (Array.isArray(childrenByOrder)) {
327
- return undefined;
328
- }
329
- // need to sort to make it stable for ci
330
- const items = Object.keys(childrenByOrder).map(key => ({
331
- type: key,
332
- children: childrenByOrder[key]
333
- }));
334
- items.sort((a, b) => (0, comparators_1.compareIds)(a.type, b.type));
335
- return Array.isArray(childrenByOrder)
336
- ? undefined
337
- : printer.print(context.type, items, context);
338
- },
339
- "chunk.childrenByOrder[].type": type => `${type}:`,
340
- "chunk.childrenByOrder[].children[]": (id, { formatChunkId }) => isValidId(id) ? formatChunkId(id) : undefined,
341
- "chunk.entry": (entry, { formatFlag, yellow }) => entry ? yellow(formatFlag("entry")) : undefined,
342
- "chunk.initial": (initial, { formatFlag, yellow }) => initial ? yellow(formatFlag("initial")) : undefined,
343
- "chunk.rendered": (rendered, { formatFlag, green }) => rendered ? green(formatFlag("rendered")) : undefined,
344
- "chunk.recorded": (recorded, { formatFlag, green }) => recorded ? green(formatFlag("recorded")) : undefined,
345
- "chunk.reason": (reason, { yellow }) => (reason ? yellow(reason) : undefined),
346
- "chunk.filteredModules": (filteredModules, { chunk: { modules } }) => filteredModules > 0
347
- ? `${moreCount(modules, filteredModules)} chunk ${plural(filteredModules, "module", "modules")}`
348
- : undefined,
349
- "chunk.separator!": () => "\n",
350
- "chunkOrigin.request": request => request,
351
- "chunkOrigin.moduleId": (moduleId, { formatModuleId }) => isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
352
- "chunkOrigin.moduleName": (moduleName, { bold }) => bold(moduleName),
353
- "chunkOrigin.loc": loc => loc,
354
- // TODO: should align webpack error
355
- // "error.compilerPath": (compilerPath, { bold }) =>
356
- // compilerPath ? bold(`(${compilerPath})`) : undefined,
357
- // "error.chunkId": (chunkId, { formatChunkId }) =>
358
- // isValidId(chunkId) ? formatChunkId(chunkId) : undefined,
359
- // "error.chunkEntry": (chunkEntry, { formatFlag }) =>
360
- // chunkEntry ? formatFlag("entry") : undefined,
361
- // "error.chunkInitial": (chunkInitial, { formatFlag }) =>
362
- // chunkInitial ? formatFlag("initial") : undefined,
363
- "error.file": (file, { bold }) => bold(file),
364
- "error.moduleName": (moduleName, { bold }) => {
365
- return moduleName.includes("!")
366
- ? `${bold(moduleName.replace(/^(\s|\S)*!/, ""))} (${moduleName})`
367
- : `${bold(moduleName)}`;
368
- },
369
- "error.loc": (loc, { green }) => green(loc),
370
- "error.message": (message, { bold, formatError }) => message.includes("\u001b[") ? message : bold(formatError(message)),
371
- // "error.details": (details, { formatError }) => formatError(details),
372
- // "error.stack": stack => stack,
373
- "error.moduleTrace": moduleTrace => undefined,
374
- "error.separator!": () => "\n",
375
- "loggingEntry(error).loggingEntry.message": (message, { red }) => mapLines(message, x => `<e> ${red(x)}`),
376
- "loggingEntry(warn).loggingEntry.message": (message, { yellow }) => mapLines(message, x => `<w> ${yellow(x)}`),
377
- "loggingEntry(info).loggingEntry.message": (message, { green }) => mapLines(message, x => `<i> ${green(x)}`),
378
- "loggingEntry(log).loggingEntry.message": (message, { bold }) => mapLines(message, x => ` ${bold(x)}`),
379
- "loggingEntry(debug).loggingEntry.message": message => mapLines(message, x => ` ${x}`),
380
- "loggingEntry(trace).loggingEntry.message": message => mapLines(message, x => ` ${x}`),
381
- "loggingEntry(status).loggingEntry.message": (message, { magenta }) => mapLines(message, x => `<s> ${magenta(x)}`),
382
- "loggingEntry(profile).loggingEntry.message": (message, { magenta }) => mapLines(message, x => `<p> ${magenta(x)}`),
383
- "loggingEntry(profileEnd).loggingEntry.message": (message, { magenta }) => mapLines(message, x => `</p> ${magenta(x)}`),
384
- "loggingEntry(time).loggingEntry.message": (message, { magenta }) => mapLines(message, x => `<t> ${magenta(x)}`),
385
- "loggingEntry(cache).loggingEntry.message": (message, { magenta }) => mapLines(message, x => `<c> ${magenta(x)}`),
386
- "loggingEntry(group).loggingEntry.message": (message, { cyan }) => mapLines(message, x => `<-> ${cyan(x)}`),
387
- "loggingEntry(groupCollapsed).loggingEntry.message": (message, { cyan }) => mapLines(message, x => `<+> ${cyan(x)}`),
388
- "loggingEntry(clear).loggingEntry": () => " -------",
389
- "loggingEntry(groupCollapsed).loggingEntry.children": () => "",
390
- "loggingEntry.trace[]": trace => trace ? mapLines(trace, x => `| ${x}`) : undefined,
391
- "moduleTraceItem.originName": originName => originName,
392
- loggingGroup: loggingGroup => loggingGroup.entries.length === 0 ? "" : undefined,
393
- "loggingGroup.debug": (flag, { red }) => (flag ? red("DEBUG") : undefined),
394
- "loggingGroup.name": (name, { bold }) => bold(`LOG from ${name}`),
395
- "loggingGroup.separator!": () => "\n",
396
- "loggingGroup.filteredEntries": filteredEntries => filteredEntries > 0 ? `+ ${filteredEntries} hidden lines` : undefined,
397
- "moduleTraceDependency.loc": loc => loc
398
- };
399
- const ITEM_NAMES = {
400
- "compilation.assets[]": "asset",
401
- "compilation.modules[]": "module",
402
- "compilation.chunks[]": "chunk",
403
- "compilation.entrypoints[]": "chunkGroup",
404
- "compilation.namedChunkGroups[]": "chunkGroup",
405
- "compilation.errors[]": "error",
406
- "compilation.warnings[]": "error",
407
- "compilation.logging[]": "loggingGroup",
408
- "compilation.children[]": "compilation",
409
- "asset.related[]": "asset",
410
- "asset.children[]": "asset",
411
- "asset.chunks[]": "assetChunk",
412
- "asset.auxiliaryChunks[]": "assetChunk",
413
- "asset.chunkNames[]": "assetChunkName",
414
- "asset.chunkIdHints[]": "assetChunkIdHint",
415
- "asset.auxiliaryChunkNames[]": "assetChunkName",
416
- "asset.auxiliaryChunkIdHints[]": "assetChunkIdHint",
417
- "chunkGroup.assets[]": "chunkGroupAsset",
418
- "chunkGroup.auxiliaryAssets[]": "chunkGroupAsset",
419
- "chunkGroupChild.assets[]": "chunkGroupAsset",
420
- "chunkGroupChild.auxiliaryAssets[]": "chunkGroupAsset",
421
- "chunkGroup.children[]": "chunkGroupChildGroup",
422
- "chunkGroupChildGroup.children[]": "chunkGroupChild",
423
- "module.modules[]": "module",
424
- "module.children[]": "module",
425
- "module.reasons[]": "moduleReason",
426
- "moduleReason.children[]": "moduleReason",
427
- "module.issuerPath[]": "moduleIssuer",
428
- "chunk.origins[]": "chunkOrigin",
429
- "chunk.modules[]": "module",
430
- "loggingGroup.entries[]": (logEntry) => `loggingEntry(${logEntry.type}).loggingEntry`,
431
- "loggingEntry.children[]": (logEntry) => `loggingEntry(${logEntry.type}).loggingEntry`,
432
- "error.moduleTrace[]": "moduleTraceItem",
433
- "moduleTraceItem.dependencies[]": "moduleTraceDependency"
434
- };
435
- const ERROR_PREFERRED_ORDER = [
436
- "compilerPath",
437
- "chunkId",
438
- "chunkEntry",
439
- "chunkInitial",
440
- "file",
441
- "separator!",
442
- "moduleName",
443
- "loc",
444
- "separator!",
445
- "message",
446
- "separator!",
447
- "details",
448
- "separator!",
449
- "stack",
450
- "separator!",
451
- "missing",
452
- "separator!",
453
- "moduleTrace"
454
- ];
455
- const PREFERRED_ORDERS = {
456
- compilation: [
457
- "name",
458
- "hash",
459
- "rspackVersion",
460
- "time",
461
- "builtAt",
462
- "env",
463
- "publicPath",
464
- "assets",
465
- "filteredAssets",
466
- "entrypoints",
467
- "namedChunkGroups",
468
- "chunks",
469
- "modules",
470
- "filteredModules",
471
- "children",
472
- "logging",
473
- "warnings",
474
- "warningsInChildren!",
475
- "filteredWarningDetailsCount",
476
- "errors",
477
- "errorsInChildren!",
478
- "filteredErrorDetailsCount",
479
- "summary!",
480
- "needAdditionalPass"
481
- ],
482
- asset: [
483
- "type",
484
- "name",
485
- "size",
486
- "chunks",
487
- "auxiliaryChunks",
488
- "emitted",
489
- "comparedForEmit",
490
- "cached",
491
- "info",
492
- "isOverSizeLimit",
493
- "chunkNames",
494
- "auxiliaryChunkNames",
495
- "chunkIdHints",
496
- "auxiliaryChunkIdHints",
497
- "related",
498
- "filteredRelated",
499
- "children",
500
- "filteredChildren"
501
- ],
502
- "asset.info": [
503
- "immutable",
504
- "sourceFilename",
505
- "javascriptModule",
506
- "development",
507
- "hotModuleReplacement"
508
- ],
509
- chunkGroup: [
510
- "kind!",
511
- "name",
512
- "isOverSizeLimit",
513
- "assetsSize",
514
- "auxiliaryAssetsSize",
515
- "is!",
516
- "assets",
517
- "filteredAssets",
518
- "auxiliaryAssets",
519
- "filteredAuxiliaryAssets",
520
- "separator!",
521
- "children"
522
- ],
523
- chunkGroupAsset: ["name", "size"],
524
- chunkGroupChildGroup: ["type", "children"],
525
- chunkGroupChild: ["assets", "chunks", "name"],
526
- module: [
527
- "type",
528
- "name",
529
- "identifier",
530
- "id",
531
- "layer",
532
- "sizes",
533
- "chunks",
534
- "depth",
535
- "cacheable",
536
- "orphan",
537
- "runtime",
538
- "optional",
539
- "dependent",
540
- "built",
541
- "codeGenerated",
542
- "cached",
543
- "assets",
544
- "failed",
545
- "warnings",
546
- "errors",
547
- "children",
548
- "filteredChildren",
549
- "providedExports",
550
- "usedExports",
551
- "optimizationBailout",
552
- "reasons",
553
- "filteredReasons",
554
- "issuerPath",
555
- "profile",
556
- "modules",
557
- "filteredModules"
558
- ],
559
- moduleReason: [
560
- "active",
561
- "type",
562
- "userRequest",
563
- "moduleId",
564
- "module",
565
- "resolvedModule",
566
- "loc",
567
- "explanation",
568
- "children",
569
- "filteredChildren"
570
- ],
571
- "module.profile": [
572
- "total",
573
- "separator!",
574
- "resolving",
575
- "restoring",
576
- "integration",
577
- "building",
578
- "storing",
579
- "additionalResolving",
580
- "additionalIntegration"
581
- ],
582
- chunk: [
583
- "id",
584
- "runtime",
585
- "files",
586
- "names",
587
- "idHints",
588
- "sizes",
589
- "parents",
590
- "siblings",
591
- "children",
592
- "childrenByOrder",
593
- "entry",
594
- "initial",
595
- "rendered",
596
- "recorded",
597
- "reason",
598
- "separator!",
599
- "origins",
600
- "separator!",
601
- "modules",
602
- "separator!",
603
- "filteredModules"
604
- ],
605
- chunkOrigin: ["request", "moduleId", "moduleName", "loc"],
606
- error: ERROR_PREFERRED_ORDER,
607
- warning: ERROR_PREFERRED_ORDER,
608
- "chunk.childrenByOrder[]": ["type", "children"],
609
- loggingGroup: [
610
- "debug",
611
- "name",
612
- "separator!",
613
- "entries",
614
- "separator!",
615
- "filteredEntries"
616
- ],
617
- loggingEntry: ["message", "trace", "children"]
618
- };
619
- const itemsJoinOneLine = (items) => items.filter(Boolean).join(" ");
620
- const itemsJoinOneLineBrackets = (items) => items.length > 0 ? `(${items.filter(Boolean).join(" ")})` : undefined;
621
- const itemsJoinMoreSpacing = (items) => items.filter(Boolean).join("\n\n");
622
- const itemsJoinComma = (items) => items.filter(Boolean).join(", ");
623
- const itemsJoinCommaBrackets = (items) => items.length > 0 ? `(${items.filter(Boolean).join(", ")})` : undefined;
624
- const itemsJoinCommaBracketsWithName = (name) => (items) => items.length > 0
625
- ? `(${name}: ${items.filter(Boolean).join(", ")})`
626
- : undefined;
627
- const SIMPLE_ITEMS_JOINER = {
628
- "chunk.parents": itemsJoinOneLine,
629
- "chunk.siblings": itemsJoinOneLine,
630
- "chunk.children": itemsJoinOneLine,
631
- "chunk.names": itemsJoinCommaBrackets,
632
- "chunk.idHints": itemsJoinCommaBracketsWithName("id hint"),
633
- "chunk.runtime": itemsJoinCommaBracketsWithName("runtime"),
634
- "chunk.files": itemsJoinComma,
635
- "chunk.childrenByOrder": itemsJoinOneLine,
636
- "chunk.childrenByOrder[].children": itemsJoinOneLine,
637
- "chunkGroup.assets": itemsJoinOneLine,
638
- "chunkGroup.auxiliaryAssets": itemsJoinOneLineBrackets,
639
- "chunkGroupChildGroup.children": itemsJoinComma,
640
- "chunkGroupChild.assets": itemsJoinOneLine,
641
- "chunkGroupChild.auxiliaryAssets": itemsJoinOneLineBrackets,
642
- "asset.chunks": itemsJoinComma,
643
- "asset.auxiliaryChunks": itemsJoinCommaBrackets,
644
- "asset.chunkNames": itemsJoinCommaBracketsWithName("name"),
645
- "asset.auxiliaryChunkNames": itemsJoinCommaBracketsWithName("auxiliary name"),
646
- "asset.chunkIdHints": itemsJoinCommaBracketsWithName("id hint"),
647
- "asset.auxiliaryChunkIdHints": itemsJoinCommaBracketsWithName("auxiliary id hint"),
648
- "module.chunks": itemsJoinOneLine,
649
- "module.issuerPath": items => items
650
- .filter(Boolean)
651
- .map(item => `${item} ->`)
652
- .join(" "),
653
- "compilation.errors": itemsJoinMoreSpacing,
654
- "compilation.warnings": itemsJoinMoreSpacing,
655
- "compilation.logging": itemsJoinMoreSpacing,
656
- "compilation.children": items => indent(itemsJoinMoreSpacing(items), " "),
657
- "moduleTraceItem.dependencies": itemsJoinOneLine,
658
- "loggingEntry.children": items => indent(items.filter(Boolean).join("\n"), " ", false)
659
- };
660
- const joinOneLine = (items) => items
661
- .map(item => item.content)
662
- .filter(Boolean)
663
- .join(" ");
664
- const joinInBrackets = (items) => {
665
- const res = [];
666
- let mode = 0;
667
- for (const item of items) {
668
- if (item.element === "separator!") {
669
- switch (mode) {
670
- case 0:
671
- case 1:
672
- mode += 2;
673
- break;
674
- case 4:
675
- res.push(")");
676
- mode = 3;
677
- break;
678
- }
679
- }
680
- if (!item.content)
681
- continue;
682
- switch (mode) {
683
- case 0:
684
- mode = 1;
685
- break;
686
- case 1:
687
- res.push(" ");
688
- break;
689
- case 2:
690
- res.push("(");
691
- mode = 4;
692
- break;
693
- case 3:
694
- res.push(" (");
695
- mode = 4;
696
- break;
697
- case 4:
698
- res.push(", ");
699
- break;
700
- }
701
- res.push(item.content);
702
- }
703
- if (mode === 4)
704
- res.push(")");
705
- return res.join("");
706
- };
707
- const indent = (str, prefix, noPrefixInFirstLine) => {
708
- const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
709
- if (noPrefixInFirstLine)
710
- return rem;
711
- const ind = str[0] === "\n" ? "" : prefix;
712
- return ind + rem;
713
- };
714
- const joinExplicitNewLine = (items, indenter) => {
715
- let firstInLine = true;
716
- let first = true;
717
- return items
718
- .map(item => {
719
- if (!item || !item.content)
720
- return;
721
- let content = indent(item.content, first ? "" : indenter, !firstInLine);
722
- if (firstInLine) {
723
- content = content.replace(/^\n+/, "");
724
- }
725
- if (!content)
726
- return;
727
- first = false;
728
- const noJoiner = firstInLine || content.startsWith("\n");
729
- firstInLine = content.endsWith("\n");
730
- return noJoiner ? content : ` ${content}`;
731
- })
732
- .filter(Boolean)
733
- .join("")
734
- .trim();
735
- };
736
- const joinError = error => (items, { red, yellow }) => `${error ? red("ERROR") : yellow("WARNING")} in ${joinExplicitNewLine(items, "")}`;
737
- const SIMPLE_ELEMENT_JOINERS = {
738
- compilation: items => {
739
- const result = [];
740
- let lastNeedMore = false;
741
- for (const item of items) {
742
- if (!item.content)
743
- continue;
744
- const needMoreSpace = [
745
- "warnings",
746
- "filteredWarningDetailsCount",
747
- "errors",
748
- "filteredErrorDetailsCount",
749
- "logging"
750
- ].includes(item.element);
751
- if (result.length !== 0) {
752
- result.push(needMoreSpace || lastNeedMore ? "\n\n" : "\n");
753
- }
754
- result.push(item.content);
755
- lastNeedMore = needMoreSpace;
756
- }
757
- if (lastNeedMore)
758
- result.push("\n");
759
- return result.join("");
760
- },
761
- asset: items => joinExplicitNewLine(items.map(item => {
762
- if ((item.element === "related" || item.element === "children") &&
763
- item.content) {
764
- return {
765
- ...item,
766
- content: `\n${item.content}\n`
767
- };
768
- }
769
- return item;
770
- }), " "),
771
- "asset.info": joinOneLine,
772
- module: (items, { module }) => {
773
- let hasName = false;
774
- return joinExplicitNewLine(items.map(item => {
775
- switch (item.element) {
776
- case "id":
777
- if (module && module.id === module.name) {
778
- if (hasName)
779
- return false;
780
- if (item.content)
781
- hasName = true;
782
- }
783
- break;
784
- case "name":
785
- if (hasName)
786
- return false;
787
- if (item.content)
788
- hasName = true;
789
- break;
790
- case "providedExports":
791
- case "usedExports":
792
- case "optimizationBailout":
793
- case "reasons":
794
- case "issuerPath":
795
- case "profile":
796
- case "children":
797
- case "modules":
798
- if (item.content) {
799
- return {
800
- ...item,
801
- content: `\n${item.content}\n`
802
- };
803
- }
804
- break;
805
- }
806
- return item;
807
- }), " ");
808
- },
809
- chunk: items => {
810
- let hasEntry = false;
811
- return `chunk ${joinExplicitNewLine(items.filter(item => {
812
- switch (item.element) {
813
- case "entry":
814
- if (item.content)
815
- hasEntry = true;
816
- break;
817
- case "initial":
818
- if (hasEntry)
819
- return false;
820
- break;
821
- }
822
- return true;
823
- }), " ")}`;
824
- },
825
- "chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`,
826
- chunkGroup: items => joinExplicitNewLine(items, " "),
827
- chunkGroupAsset: joinOneLine,
828
- chunkGroupChildGroup: joinOneLine,
829
- chunkGroupChild: joinOneLine,
830
- moduleReason: (items, { moduleReason }) => {
831
- let hasName = false;
832
- return joinExplicitNewLine(items.map(item => {
833
- switch (item.element) {
834
- case "moduleId":
835
- if (moduleReason &&
836
- moduleReason.moduleId === moduleReason.module &&
837
- item.content)
838
- hasName = true;
839
- break;
840
- case "module":
841
- if (hasName)
842
- return false;
843
- break;
844
- case "resolvedModule":
845
- if (moduleReason &&
846
- moduleReason.module === moduleReason.resolvedModule)
847
- return false;
848
- break;
849
- case "children":
850
- if (item.content) {
851
- return {
852
- ...item,
853
- content: `\n${item.content}\n`
854
- };
855
- }
856
- break;
857
- }
858
- return item;
859
- }), " ");
860
- },
861
- "module.profile": joinInBrackets,
862
- moduleIssuer: joinOneLine,
863
- chunkOrigin: items => `> ${joinOneLine(items)}`,
864
- "errors[].error": joinError(true),
865
- "warnings[].error": joinError(false),
866
- loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
867
- moduleTraceItem: items => ` @ ${joinOneLine(items)}`,
868
- moduleTraceDependency: joinOneLine
869
- };
870
- const AVAILABLE_COLORS = {
871
- bold: "\u001b[1m",
872
- yellow: "\u001b[1m\u001b[33m",
873
- red: "\u001b[1m\u001b[31m",
874
- green: "\u001b[1m\u001b[32m",
875
- cyan: "\u001b[1m\u001b[36m",
876
- magenta: "\u001b[1m\u001b[35m"
877
- };
878
- const AVAILABLE_FORMATS = {
879
- formatChunkId: (id, { yellow }, direction) => {
880
- switch (direction) {
881
- case "parent":
882
- return `<{${yellow(id)}}>`;
883
- case "sibling":
884
- return `={${yellow(id)}}=`;
885
- case "child":
886
- return `>{${yellow(id)}}<`;
887
- default:
888
- return `{${yellow(id)}}`;
889
- }
890
- },
891
- formatModuleId: id => `[${id}]`,
892
- formatFilename: (filename, { green, yellow }, oversize) => (oversize ? yellow : green)(filename),
893
- formatFlag: (flag) => `[${flag}]`,
894
- formatLayer: layer => `(in ${layer})`,
895
- formatSize: SizeFormatHelpers_1.formatSize,
896
- formatDateTime: (dateTime, { bold }) => {
897
- const d = new Date(dateTime);
898
- const x = twoDigit;
899
- const date = `${d.getFullYear()}-${x(d.getMonth() + 1)}-${x(d.getDate())}`;
900
- const time = `${x(d.getHours())}:${x(d.getMinutes())}:${x(d.getSeconds())}`;
901
- return `${date} ${bold(time)}`;
902
- },
903
- formatTime: (time, { timeReference, bold, green, yellow, red }, boldQuantity) => {
904
- let unit = " ms";
905
- if (timeReference && time !== timeReference) {
906
- const times = [
907
- timeReference / 2,
908
- timeReference / 4,
909
- timeReference / 8,
910
- timeReference / 16
911
- ];
912
- if (time < times[3])
913
- return `${time}${unit}`;
914
- if (time < times[2])
915
- return bold(`${time}${unit}`);
916
- if (time < times[1])
917
- return green(`${time}${unit}`);
918
- if (time < times[0])
919
- return yellow(`${time}${unit}`);
920
- return red(`${time}${unit}`);
921
- }
922
- let timeStr = time.toString();
923
- if (time > 1000) {
924
- timeStr = `${(time / 1000).toFixed(2)}`;
925
- unit = " s";
926
- }
927
- return `${boldQuantity ? bold(timeStr) : timeStr}${unit}`;
928
- },
929
- formatError: (msg, { green, yellow, red }) => {
930
- let message = msg;
931
- if (message.includes("\u001b["))
932
- return message;
933
- const highlights = [
934
- { regExp: /(Did you mean .+)/g, format: green },
935
- {
936
- regExp: /(Set 'mode' option to 'development' or 'production')/g,
937
- format: green
938
- },
939
- { regExp: /(\(module has no exports\))/g, format: red },
940
- { regExp: /\(possible exports: (.+)\)/g, format: green },
941
- { regExp: /(?:^|\n)(.* doesn't exist)/g, format: red },
942
- { regExp: /('\w+' option has not been set)/g, format: red },
943
- {
944
- regExp: /(Emitted value instead of an instance of Error)/g,
945
- format: yellow
946
- },
947
- { regExp: /(Used? .+ instead)/gi, format: yellow },
948
- { regExp: /\b(deprecated|must|required)\b/g, format: yellow },
949
- {
950
- regExp: /\b(BREAKING CHANGE)\b/gi,
951
- format: red
952
- },
953
- {
954
- regExp: /\b(error|failed|unexpected|invalid|not found|not supported|not available|not possible|not implemented|doesn't support|conflict|conflicting|not existing|duplicate)\b/gi,
955
- format: red
956
- }
957
- ];
958
- for (const { regExp, format } of highlights) {
959
- message = message.replace(regExp, (match, content) => {
960
- return match.replace(content, format(content));
961
- });
962
- }
963
- return message;
964
- }
965
- };
966
- const RESULT_MODIFIER = {
967
- "module.modules": (result) => {
968
- return indent(result, "| ");
969
- }
970
- };
971
- const createOrder = (array, preferredOrder) => {
972
- const originalArray = array.slice();
973
- const set = new Set(array);
974
- const usedSet = new Set();
975
- array.length = 0;
976
- for (const element of preferredOrder) {
977
- if (element.endsWith("!") || set.has(element)) {
978
- array.push(element);
979
- usedSet.add(element);
980
- }
981
- }
982
- for (const element of originalArray) {
983
- if (!usedSet.has(element)) {
984
- array.push(element);
985
- }
986
- }
987
- return array;
988
- };
989
- class DefaultStatsPrinterPlugin {
990
- apply(compiler) {
991
- compiler.hooks.compilation.tap("DefaultStatsPrinterPlugin", compilation => {
992
- compilation.hooks.statsPrinter.tap("DefaultStatsPrinterPlugin", (stats, options) => {
993
- // Put colors into context
994
- stats.hooks.print.for("compilation").tap("DefaultStatsPrinterPlugin",
995
- // @ts-expect-error
996
- (compilation, context) => {
997
- for (const color of Object.keys(AVAILABLE_COLORS)) {
998
- let start;
999
- if (options.colors) {
1000
- if (typeof options.colors === "object" &&
1001
- typeof options.colors[color] === "string") {
1002
- start = options.colors[color];
1003
- }
1004
- else {
1005
- start =
1006
- AVAILABLE_COLORS[color];
1007
- }
1008
- }
1009
- if (start) {
1010
- context[color] = (str) => `${start}${typeof str === "string"
1011
- ? str.replace(/((\u001b\[39m|\u001b\[22m|\u001b\[0m)+)/g, `$1${start}`)
1012
- : str}\u001b[39m\u001b[22m`;
1013
- }
1014
- else {
1015
- context[color] = (str) => str;
1016
- }
1017
- }
1018
- for (const format of Object.keys(AVAILABLE_FORMATS)) {
1019
- // @ts-ignore
1020
- context[format] = (content, ...args) =>
1021
- // @ts-ignore
1022
- AVAILABLE_FORMATS[format](content, context, ...args);
1023
- }
1024
- context.timeReference = compilation.time;
1025
- });
1026
- for (const key of Object.keys(SIMPLE_PRINTERS)) {
1027
- stats.hooks.print
1028
- .for(key)
1029
- .tap("DefaultStatsPrinterPlugin", (obj, ctx) => SIMPLE_PRINTERS[key](obj, ctx, stats));
1030
- }
1031
- for (const key of Object.keys(PREFERRED_ORDERS)) {
1032
- const preferredOrder = PREFERRED_ORDERS[key];
1033
- stats.hooks.sortElements
1034
- .for(key)
1035
- .tap("DefaultStatsPrinterPlugin", elements => {
1036
- createOrder(elements, preferredOrder);
1037
- });
1038
- }
1039
- for (const key of Object.keys(ITEM_NAMES)) {
1040
- const itemName = ITEM_NAMES[key];
1041
- stats.hooks.getItemName
1042
- .for(key)
1043
- .tap("DefaultStatsPrinterPlugin", typeof itemName === "string" ? () => itemName : itemName);
1044
- }
1045
- for (const key of Object.keys(SIMPLE_ITEMS_JOINER)) {
1046
- const joiner = SIMPLE_ITEMS_JOINER[key];
1047
- stats.hooks.printItems
1048
- .for(key)
1049
- // @ts-expect-error
1050
- .tap("DefaultStatsPrinterPlugin", joiner);
1051
- }
1052
- for (const key of Object.keys(SIMPLE_ELEMENT_JOINERS)) {
1053
- const joiner = SIMPLE_ELEMENT_JOINERS[key];
1054
- stats.hooks.printElements
1055
- .for(key)
1056
- // @ts-expect-error
1057
- .tap("DefaultStatsPrinterPlugin", joiner);
1058
- }
1059
- for (const key of Object.keys(RESULT_MODIFIER)) {
1060
- const modifier = RESULT_MODIFIER[key];
1061
- stats.hooks.result
1062
- .for(key)
1063
- .tap("DefaultStatsPrinterPlugin", modifier);
1064
- }
1065
- });
1066
- });
1067
- }
1068
- }
1069
- exports.DefaultStatsPrinterPlugin = DefaultStatsPrinterPlugin;