@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,1173 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.DefaultStatsFactoryPlugin = void 0;
27
- /**
28
- * The following code is modified based on
29
- * https://github.com/webpack/webpack/tree/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/stats
30
- *
31
- * MIT Licensed
32
- * Author Tobias Koppers @sokra
33
- * Copyright (c) JS Foundation and other contributors
34
- * https://github.com/webpack/webpack/blob/main/LICENSE
35
- */
36
- const util = __importStar(require("node:util"));
37
- const Logger_1 = require("../logging/Logger");
38
- const comparators_1 = require("../util/comparators");
39
- const identifier_1 = require("../util/identifier");
40
- const statsFactoryUtils_1 = require("./statsFactoryUtils");
41
- const compareIds = comparators_1.compareIds;
42
- const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
43
- const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
44
- const ITEM_NAMES = {
45
- "compilation.children[]": "compilation",
46
- "compilation.modules[]": "module",
47
- "compilation.entrypoints[]": "chunkGroup",
48
- "compilation.namedChunkGroups[]": "chunkGroup",
49
- "compilation.errors[]": "error",
50
- "compilation.warnings[]": "warning",
51
- "chunk.modules[]": "module",
52
- "chunk.rootModules[]": "module",
53
- "chunk.origins[]": "chunkOrigin",
54
- "compilation.chunks[]": "chunk",
55
- "compilation.assets[]": "asset",
56
- "asset.related[]": "asset",
57
- "module.issuerPath[]": "moduleIssuer",
58
- "module.reasons[]": "moduleReason",
59
- "module.modules[]": "module",
60
- "module.children[]": "module",
61
- "moduleTrace[]": "moduleTraceItem"
62
- // "moduleTraceItem.dependencies[]": "moduleTraceDependency"
63
- };
64
- const MERGER = {
65
- "compilation.entrypoints": statsFactoryUtils_1.mergeToObject,
66
- "compilation.namedChunkGroups": statsFactoryUtils_1.mergeToObject
67
- };
68
- const ASSETS_GROUPERS = {
69
- _: (groupConfigs, _context, options) => {
70
- const groupByFlag = (name, exclude) => {
71
- groupConfigs.push({
72
- getKeys: (asset) => {
73
- return asset[name] ? ["1"] : undefined;
74
- },
75
- getOptions: () => {
76
- return {
77
- groupChildren: !exclude,
78
- force: exclude
79
- };
80
- },
81
- createGroup: (key, children, assets) => {
82
- return exclude
83
- ? {
84
- type: "assets by status",
85
- [name]: !!key,
86
- filteredChildren: assets.length,
87
- ...(0, statsFactoryUtils_1.assetGroup)(children)
88
- }
89
- : {
90
- type: "assets by status",
91
- [name]: !!key,
92
- children,
93
- ...(0, statsFactoryUtils_1.assetGroup)(children)
94
- };
95
- }
96
- });
97
- };
98
- const { groupAssetsByEmitStatus, groupAssetsByPath, groupAssetsByExtension } = options;
99
- if (groupAssetsByEmitStatus) {
100
- groupByFlag("emitted");
101
- // groupByFlag("comparedForEmit");
102
- // groupByFlag("isOverSizeLimit");
103
- }
104
- if (groupAssetsByEmitStatus || !options.cachedAssets) {
105
- groupByFlag("cached", !options.cachedAssets);
106
- }
107
- if (groupAssetsByPath || groupAssetsByExtension) {
108
- groupConfigs.push({
109
- getKeys: asset => {
110
- const extensionMatch = groupAssetsByExtension && GROUP_EXTENSION_REGEXP.exec(asset.name);
111
- const extension = extensionMatch ? extensionMatch[1] : "";
112
- const pathMatch = groupAssetsByPath && GROUP_PATH_REGEXP.exec(asset.name);
113
- const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
114
- const keys = [];
115
- if (groupAssetsByPath) {
116
- keys.push(".");
117
- if (extension)
118
- keys.push(path.length
119
- ? `${path.join("/")}/*${extension}`
120
- : `*${extension}`);
121
- while (path.length > 0) {
122
- keys.push(`${path.join("/")}/`);
123
- path.pop();
124
- }
125
- }
126
- else {
127
- if (extension)
128
- keys.push(`*${extension}`);
129
- }
130
- return keys;
131
- },
132
- createGroup: (key, children) => {
133
- return {
134
- type: groupAssetsByPath ? "assets by path" : "assets by extension",
135
- name: key,
136
- children,
137
- ...(0, statsFactoryUtils_1.assetGroup)(children)
138
- };
139
- }
140
- });
141
- }
142
- },
143
- groupAssetsByInfo: groupConfigs => {
144
- const groupByAssetInfoFlag = (name) => {
145
- groupConfigs.push({
146
- getKeys: asset => {
147
- return asset.info?.[name] ? ["1"] : undefined;
148
- },
149
- createGroup: (key, children) => {
150
- return {
151
- type: "assets by info",
152
- info: {
153
- [name]: !!key
154
- },
155
- children,
156
- ...(0, statsFactoryUtils_1.assetGroup)(children)
157
- };
158
- }
159
- });
160
- };
161
- groupByAssetInfoFlag("immutable");
162
- groupByAssetInfoFlag("development");
163
- groupByAssetInfoFlag("hotModuleReplacement");
164
- },
165
- groupAssetsByChunk: groupConfigs => {
166
- const groupByNames = (name) => {
167
- groupConfigs.push({
168
- getKeys: asset => {
169
- return asset[name];
170
- },
171
- createGroup: (key, children) => {
172
- return {
173
- type: "assets by chunk",
174
- [name]: [key],
175
- children,
176
- ...(0, statsFactoryUtils_1.assetGroup)(children)
177
- };
178
- }
179
- });
180
- };
181
- groupByNames("chunkNames");
182
- groupByNames("auxiliaryChunkNames");
183
- groupByNames("chunkIdHints");
184
- groupByNames("auxiliaryChunkIdHints");
185
- },
186
- excludeAssets: (groupConfigs, _context, { excludeAssets }) => {
187
- groupConfigs.push({
188
- getKeys: asset => {
189
- const ident = asset.name;
190
- const excluded = excludeAssets.some(fn => fn(ident, asset));
191
- if (excluded)
192
- return ["excluded"];
193
- },
194
- getOptions: () => ({
195
- groupChildren: false,
196
- force: true
197
- }),
198
- createGroup: (_key, children, assets) => ({
199
- type: "hidden assets",
200
- filteredChildren: assets.length,
201
- ...(0, statsFactoryUtils_1.assetGroup)(children)
202
- })
203
- });
204
- }
205
- };
206
- const MODULES_GROUPERS = (type) => ({
207
- _: (groupConfigs, _context, options) => {
208
- const groupByFlag = (name, type, exclude) => {
209
- groupConfigs.push({
210
- getKeys: module => {
211
- return module[name] ? ["1"] : undefined;
212
- },
213
- getOptions: () => {
214
- return {
215
- groupChildren: !exclude,
216
- force: exclude
217
- };
218
- },
219
- createGroup: (key, children, modules) => {
220
- return {
221
- type,
222
- [name]: !!key,
223
- ...(exclude ? { filteredChildren: modules.length } : { children }),
224
- ...(0, statsFactoryUtils_1.moduleGroup)(children)
225
- };
226
- }
227
- });
228
- };
229
- const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType, groupModulesByPath, groupModulesByExtension } = options;
230
- if (groupModulesByAttributes) {
231
- groupByFlag("errors", "modules with errors");
232
- groupByFlag("warnings", "modules with warnings");
233
- groupByFlag("assets", "modules with assets");
234
- groupByFlag("optional", "optional modules");
235
- }
236
- if (groupModulesByCacheStatus) {
237
- groupByFlag("cacheable", "cacheable modules");
238
- groupByFlag("built", "built modules");
239
- groupByFlag("codeGenerated", "code generated modules");
240
- }
241
- if (groupModulesByCacheStatus || !options.cachedModules) {
242
- groupByFlag("cached", "cached modules", !options.cachedModules);
243
- }
244
- if (groupModulesByAttributes || !options.orphanModules) {
245
- groupByFlag("orphan", "orphan modules", !options.orphanModules);
246
- }
247
- if (groupModulesByAttributes || !options.dependentModules) {
248
- groupByFlag("dependent", "dependent modules", !options.dependentModules);
249
- }
250
- if (groupModulesByType || !options.runtimeModules) {
251
- groupConfigs.push({
252
- getKeys: (module) => {
253
- const moduleType = module.moduleType;
254
- if (!moduleType)
255
- return;
256
- if (groupModulesByType) {
257
- return [moduleType.split("/", 1)[0]];
258
- }
259
- if (moduleType === "runtime") {
260
- return ["runtime"];
261
- }
262
- },
263
- getOptions: key => {
264
- const exclude = key === "runtime" && !options.runtimeModules;
265
- return {
266
- groupChildren: !exclude,
267
- force: exclude
268
- };
269
- },
270
- createGroup: (key, children, modules) => {
271
- const exclude = key === "runtime" && !options.runtimeModules;
272
- return {
273
- type: `${key} modules`,
274
- moduleType: key,
275
- ...(exclude ? { filteredChildren: modules.length } : { children }),
276
- ...(0, statsFactoryUtils_1.moduleGroup)(children)
277
- };
278
- }
279
- });
280
- }
281
- // not support groupModulesByLayer
282
- if (groupModulesByPath || groupModulesByExtension) {
283
- groupConfigs.push({
284
- getKeys: module => {
285
- if (!module.name)
286
- return;
287
- const resource = (0, identifier_1.parseResource)(module.name.split("!").pop()).path;
288
- const dataUrl = /^data:[^,;]+/.exec(resource);
289
- if (dataUrl)
290
- return [dataUrl[0]];
291
- const extensionMatch = groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
292
- const extension = extensionMatch ? extensionMatch[1] : "";
293
- const pathMatch = groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
294
- const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
295
- const keys = [];
296
- if (groupModulesByPath) {
297
- if (extension)
298
- keys.push(path.length
299
- ? `${path.join("/")}/*${extension}`
300
- : `*${extension}`);
301
- while (path.length > 0) {
302
- keys.push(`${path.join("/")}/`);
303
- path.pop();
304
- }
305
- }
306
- else {
307
- if (extension)
308
- keys.push(`*${extension}`);
309
- }
310
- return keys;
311
- },
312
- createGroup: (key, children, _modules) => {
313
- const isDataUrl = key.startsWith("data:");
314
- return {
315
- type: isDataUrl
316
- ? "modules by mime type"
317
- : groupModulesByPath
318
- ? "modules by path"
319
- : "modules by extension",
320
- name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
321
- children,
322
- ...(0, statsFactoryUtils_1.moduleGroup)(children)
323
- };
324
- }
325
- });
326
- }
327
- },
328
- excludeModules: (groupConfigs, _context, { excludeModules }) => {
329
- groupConfigs.push({
330
- getKeys: module => {
331
- const name = module.name;
332
- if (name) {
333
- const excluded = excludeModules.some(fn => fn(name, module, type));
334
- if (excluded)
335
- return ["1"];
336
- }
337
- },
338
- getOptions: () => ({
339
- groupChildren: false,
340
- force: true
341
- }),
342
- createGroup: (_key, children, _modules) => ({
343
- type: "hidden modules",
344
- filteredChildren: children.length,
345
- ...(0, statsFactoryUtils_1.moduleGroup)(children)
346
- })
347
- });
348
- }
349
- });
350
- const RESULT_GROUPERS = {
351
- "compilation.assets": ASSETS_GROUPERS,
352
- "asset.related": ASSETS_GROUPERS,
353
- "compilation.modules": MODULES_GROUPERS("module"),
354
- "chunk.modules": MODULES_GROUPERS("chunk"),
355
- "chunk.rootModules": MODULES_GROUPERS("root-of-chunk"),
356
- "module.modules": MODULES_GROUPERS("nested")
357
- };
358
- const ASSET_SORTERS = {
359
- assetsSort: (comparators, _context, { assetsSort }) => {
360
- comparators.push((0, statsFactoryUtils_1.sortByField)(assetsSort));
361
- },
362
- _: (comparators) => {
363
- comparators.push((0, comparators_1.compareSelect)((a) => a.name, compareIds));
364
- }
365
- };
366
- const RESULT_SORTERS = {
367
- "compilation.chunks": {
368
- chunksSort: (comparators, _context, { chunksSort }) => {
369
- comparators.push((0, statsFactoryUtils_1.sortByField)(chunksSort));
370
- }
371
- },
372
- "compilation.modules": {
373
- modulesSort: (comparators, _context, { modulesSort }) => {
374
- comparators.push((0, statsFactoryUtils_1.sortByField)(modulesSort));
375
- }
376
- },
377
- "chunk.modules": {
378
- chunkModulesSort: (comparators, _context, { chunkModulesSort }) => {
379
- comparators.push((0, statsFactoryUtils_1.sortByField)(chunkModulesSort));
380
- }
381
- },
382
- "module.modules": {
383
- nestedModulesSort: (comparators, _context, { nestedModulesSort }) => {
384
- comparators.push((0, statsFactoryUtils_1.sortByField)(nestedModulesSort));
385
- }
386
- },
387
- "compilation.assets": ASSET_SORTERS,
388
- "asset.related": ASSET_SORTERS
389
- };
390
- const MODULES_SORTER = {
391
- _: comparators => {
392
- comparators.push((0, comparators_1.compareSelect)((m) => m.commonAttributes.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.commonAttributes.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.commonAttributes.moduleDescriptor?.identifier, compareIds));
393
- }
394
- };
395
- const SORTERS = {
396
- "compilation.chunks": {
397
- _: comparators => {
398
- comparators.push((0, comparators_1.compareSelect)((c) => c.id, compareIds));
399
- }
400
- },
401
- "compilation.modules": MODULES_SORTER,
402
- "chunk.rootModules": MODULES_SORTER,
403
- "chunk.modules": MODULES_SORTER,
404
- "module.modules": MODULES_SORTER,
405
- "module.reasons": {
406
- _: comparators => {
407
- comparators.push((0, comparators_1.compareSelect)((x) => x.moduleIdentifier, compareIds));
408
- comparators.push((0, comparators_1.compareSelect)((x) => x.resolvedModuleIdentifier, compareIds));
409
- comparators.push((0, comparators_1.compareSelect)((x) => x.dependency, (0, comparators_1.compareSelect)((x) => x.type, compareIds)
410
- // concatComparators(
411
- // compareSelect(
412
- // /**
413
- // * @param {Dependency} x dependency
414
- // * @returns {DependencyLocation} location
415
- // */
416
- // x => x.loc,
417
- // compareLocations
418
- // ),
419
- // compareSelect(x => x.type, compareIds)
420
- // )
421
- ));
422
- }
423
- },
424
- "chunk.origins": {
425
- _: comparators => {
426
- comparators.push((0, comparators_1.compareSelect)((origin) => origin.moduleId, compareIds), (0, comparators_1.compareSelect)((origin) => origin.loc, compareIds), (0, comparators_1.compareSelect)((origin) => origin.request, compareIds));
427
- }
428
- }
429
- };
430
- const EXTRACT_ERROR = {
431
- _: (object, error) => {
432
- object.message = error.message;
433
- if (error.chunkName) {
434
- object.chunkName = error.chunkName;
435
- }
436
- if (error.chunkEntry) {
437
- object.chunkEntry = error.chunkEntry;
438
- }
439
- if (error.chunkInitial) {
440
- object.chunkInitial = error.chunkInitial;
441
- }
442
- if (error.file) {
443
- object.file = error.file;
444
- }
445
- if (error.moduleDescriptor) {
446
- object.moduleIdentifier = error.moduleDescriptor.identifier;
447
- object.moduleName = error.moduleDescriptor.name;
448
- }
449
- if ("loc" in error) {
450
- object.loc = error.loc;
451
- }
452
- },
453
- ids: (object, error) => {
454
- if (error.chunkId) {
455
- object.chunkId = error.chunkId;
456
- }
457
- if (error.moduleDescriptor) {
458
- object.moduleId = error.moduleDescriptor.id;
459
- }
460
- },
461
- moduleTrace: (object, error, context, _, factory) => {
462
- const { type } = context;
463
- object.moduleTrace = factory.create(`${type}.moduleTrace`, error.moduleTrace, context);
464
- },
465
- errorDetails: (object, error) => {
466
- object.details = error.details;
467
- },
468
- errorStack: (object, error) => {
469
- object.stack = error.stack;
470
- }
471
- };
472
- const SIMPLE_EXTRACTORS = {
473
- compilation: {
474
- _: (object, compilation, context, options) => {
475
- const statsCompilation = context.getStatsCompilation(compilation);
476
- if (!context.makePathsRelative) {
477
- context.makePathsRelative = identifier_1.makePathsRelative.bindContextCache(compilation.compiler.context, compilation.compiler.root);
478
- }
479
- if (!context.cachedGetErrors) {
480
- context.cachedGetErrors = _compilation => {
481
- return statsCompilation.errors;
482
- };
483
- }
484
- if (!context.cachedGetWarnings) {
485
- context.cachedGetWarnings = _compilation => {
486
- const warnings = statsCompilation.warnings;
487
- return compilation.hooks.processWarnings.call(warnings);
488
- };
489
- }
490
- if (compilation.name) {
491
- object.name = compilation.name;
492
- }
493
- // TODO: support compilation.needAdditionalPass
494
- const logging = options.logging;
495
- const loggingDebug = options.loggingDebug;
496
- const loggingTrace = options.loggingTrace;
497
- if (logging || (loggingDebug && loggingDebug.length > 0)) {
498
- let collapsedGroups = false;
499
- let acceptedTypes;
500
- if (logging === "verbose" ||
501
- (loggingDebug && loggingDebug.length > 0)) {
502
- acceptedTypes = (0, Logger_1.getLogTypesBitFlag)([
503
- Logger_1.LogType.error,
504
- Logger_1.LogType.warn,
505
- Logger_1.LogType.info,
506
- Logger_1.LogType.log,
507
- Logger_1.LogType.group,
508
- Logger_1.LogType.groupEnd,
509
- Logger_1.LogType.groupCollapsed,
510
- Logger_1.LogType.profile,
511
- Logger_1.LogType.profileEnd,
512
- Logger_1.LogType.time,
513
- Logger_1.LogType.status,
514
- Logger_1.LogType.clear,
515
- Logger_1.LogType.cache
516
- ]);
517
- collapsedGroups = true;
518
- }
519
- else if (logging === "log" || logging === true) {
520
- acceptedTypes = (0, Logger_1.getLogTypesBitFlag)([
521
- Logger_1.LogType.error,
522
- Logger_1.LogType.warn,
523
- Logger_1.LogType.info,
524
- Logger_1.LogType.log,
525
- Logger_1.LogType.group,
526
- Logger_1.LogType.groupEnd,
527
- Logger_1.LogType.groupCollapsed,
528
- Logger_1.LogType.clear
529
- ]);
530
- }
531
- else if (logging === "info") {
532
- acceptedTypes = (0, Logger_1.getLogTypesBitFlag)([
533
- Logger_1.LogType.error,
534
- Logger_1.LogType.warn,
535
- Logger_1.LogType.info
536
- ]);
537
- }
538
- else if (logging === "warn") {
539
- acceptedTypes = (0, Logger_1.getLogTypesBitFlag)([Logger_1.LogType.error, Logger_1.LogType.warn]);
540
- }
541
- else if (logging === "error") {
542
- acceptedTypes = (0, Logger_1.getLogTypesBitFlag)([Logger_1.LogType.error]);
543
- }
544
- else {
545
- acceptedTypes = (0, Logger_1.getLogTypesBitFlag)([]);
546
- }
547
- object.logging = {};
548
- const compilationLogging = compilation.logging;
549
- for (const { name, ...rest } of context
550
- .getInner(compilation)
551
- .getLogging(acceptedTypes)) {
552
- const value = compilationLogging.get(name);
553
- const entry = {
554
- type: rest.type,
555
- trace: rest.trace,
556
- args: rest.args ?? []
557
- };
558
- if (value) {
559
- value.push(entry);
560
- }
561
- else {
562
- compilationLogging.set(name, [entry]);
563
- }
564
- }
565
- let depthInCollapsedGroup = 0;
566
- for (const [origin, logEntries] of compilationLogging) {
567
- const debugMode = loggingDebug.some(fn => fn(origin));
568
- if (logging === false && !debugMode)
569
- continue;
570
- const groupStack = [];
571
- const rootList = [];
572
- let currentList = rootList;
573
- let processedLogEntries = 0;
574
- for (const entry of logEntries) {
575
- let type = entry.type;
576
- const typeBitFlag = (0, Logger_1.getLogTypeBitFlag)(type);
577
- if (!debugMode && (acceptedTypes & typeBitFlag) !== typeBitFlag)
578
- continue;
579
- // Expand groups in verbose and debug modes
580
- if (type === Logger_1.LogType.groupCollapsed &&
581
- (debugMode || collapsedGroups))
582
- type = Logger_1.LogType.group;
583
- if (depthInCollapsedGroup === 0) {
584
- processedLogEntries++;
585
- }
586
- if (type === Logger_1.LogType.groupEnd) {
587
- groupStack.pop();
588
- if (groupStack.length > 0) {
589
- currentList = groupStack[groupStack.length - 1].children;
590
- }
591
- else {
592
- currentList = rootList;
593
- }
594
- if (depthInCollapsedGroup > 0)
595
- depthInCollapsedGroup--;
596
- continue;
597
- }
598
- const message = entry.args && entry.args.length > 0
599
- ? util.format(entry.args[0], ...entry.args.slice(1))
600
- : "";
601
- const newEntry = {
602
- type,
603
- message,
604
- trace: loggingTrace ? entry.trace : undefined,
605
- children: type === Logger_1.LogType.group || type === Logger_1.LogType.groupCollapsed
606
- ? []
607
- : undefined
608
- };
609
- currentList.push(newEntry);
610
- if (newEntry.children) {
611
- groupStack.push(newEntry);
612
- currentList = newEntry.children;
613
- if (depthInCollapsedGroup > 0) {
614
- depthInCollapsedGroup++;
615
- }
616
- else if (type === Logger_1.LogType.groupCollapsed) {
617
- depthInCollapsedGroup = 1;
618
- }
619
- }
620
- }
621
- object.logging[origin] = {
622
- entries: rootList,
623
- filteredEntries: logEntries.length - processedLogEntries,
624
- debug: debugMode
625
- };
626
- }
627
- }
628
- },
629
- hash: (object, compilation, context) => {
630
- const statsCompilation = context.getStatsCompilation(compilation);
631
- object.hash = statsCompilation.hash;
632
- },
633
- version: object => {
634
- const { version, webpackVersion } = require("../../package.json");
635
- object.version = webpackVersion;
636
- object.rspackVersion = version;
637
- },
638
- env: (object, _compilation, _context, { _env }) => {
639
- object.env = _env;
640
- },
641
- timings: (object, compilation) => {
642
- object.time = compilation.endTime - compilation.startTime;
643
- },
644
- builtAt: (object, compilation) => {
645
- object.builtAt = compilation.endTime;
646
- },
647
- publicPath: (object, compilation) => {
648
- object.publicPath = compilation.getPath(compilation.outputOptions.publicPath || "");
649
- },
650
- outputPath: (object, compilation) => {
651
- object.outputPath = compilation.outputOptions.path;
652
- },
653
- assets: (object, compilation, context, options, factory) => {
654
- const { type, getStatsCompilation } = context;
655
- const statsCompilation = getStatsCompilation(compilation);
656
- const compilationAssets = statsCompilation.assets;
657
- const assetsByChunkName = statsCompilation.assetsByChunkName;
658
- const assetMap = new Map();
659
- const assets = new Set();
660
- for (const asset of compilationAssets) {
661
- const item = {
662
- ...asset,
663
- type: "asset",
664
- related: []
665
- };
666
- assets.add(item);
667
- assetMap.set(asset.name, item);
668
- }
669
- for (const item of assetMap.values()) {
670
- const related = item.info.related;
671
- if (!related)
672
- continue;
673
- for (const { name: type, value: relatedEntry } of related) {
674
- const deps = Array.isArray(relatedEntry)
675
- ? relatedEntry
676
- : [relatedEntry];
677
- for (const dep of deps) {
678
- const depItem = assetMap.get(dep);
679
- if (!depItem)
680
- continue;
681
- assets.delete(depItem);
682
- depItem.type = type;
683
- item.related = item.related || [];
684
- item.related.push(depItem);
685
- }
686
- }
687
- }
688
- object.assetsByChunkName = assetsByChunkName.reduce((acc, cur) => {
689
- acc[cur.name] = cur.files;
690
- return acc;
691
- }, {});
692
- const groupedAssets = factory.create(`${type}.assets`, Array.from(assets), {
693
- ...context
694
- // compilationFileToChunks
695
- // compilationAuxiliaryFileToChunks
696
- });
697
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace ?? Number.POSITIVE_INFINITY);
698
- object.assets = limited.children;
699
- object.filteredAssets = limited.filteredChildren;
700
- },
701
- chunks: (object, compilation, context, options, factory) => {
702
- const { type, getStatsCompilation } = context;
703
- const statsCompilation = getStatsCompilation(compilation);
704
- const chunks = statsCompilation.chunks;
705
- object.chunks = factory.create(`${type}.chunks`, chunks, context);
706
- },
707
- modules: (object, compilation, context, options, factory) => {
708
- const { type, getStatsCompilation } = context;
709
- const statsCompilation = getStatsCompilation(compilation);
710
- const array = statsCompilation.modules;
711
- const groupedModules = factory.create(`${type}.modules`, array, context);
712
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedModules, options.modulesSpace);
713
- object.modules = limited.children;
714
- object.filteredModules = limited.filteredChildren;
715
- },
716
- entrypoints: (object, compilation, context, { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
717
- const { type, getStatsCompilation } = context;
718
- const statsCompilation = getStatsCompilation(compilation);
719
- const array = statsCompilation.entrypoints.map(entrypoint => ({
720
- name: entrypoint.name,
721
- chunkGroup: entrypoint
722
- }));
723
- const chunks = Array.from(compilation.chunks).reduce((res, chunk) => {
724
- res[chunk.id] = chunk;
725
- return res;
726
- }, {});
727
- if (entrypoints === "auto" && !chunkGroups) {
728
- if (array.length > 5)
729
- return;
730
- if (!chunkGroupChildren &&
731
- array.every(({ chunkGroup }) => {
732
- if (chunkGroup.chunks.length !== 1)
733
- return false;
734
- const chunk = chunks[chunkGroup.chunks[0]];
735
- return (chunk &&
736
- chunk.files.size === 1 &&
737
- (!chunkGroupAuxiliary || chunk.auxiliaryFiles.size === 0));
738
- })) {
739
- return;
740
- }
741
- }
742
- object.entrypoints = factory.create(`${type}.entrypoints`, array, context);
743
- },
744
- chunkGroups: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
745
- const { type, getStatsCompilation } = context;
746
- const statsCompilation = getStatsCompilation(compilation);
747
- const namedChunkGroups = statsCompilation.namedChunkGroups.map(cg => ({
748
- name: cg.name,
749
- chunkGroup: cg
750
- }));
751
- object.namedChunkGroups = factory.create(`${type}.namedChunkGroups`, namedChunkGroups, context);
752
- },
753
- errors: (object, compilation, context, options, factory) => {
754
- const { type, cachedGetErrors } = context;
755
- const rawErrors = cachedGetErrors(compilation);
756
- const factorizedErrors = factory.create(`${type}.errors`, cachedGetErrors(compilation), context);
757
- let filtered = 0;
758
- if (options.errorDetails === "auto" && rawErrors.length >= 3) {
759
- filtered = rawErrors
760
- .map(e => typeof e !== "string" && e.details)
761
- .filter(Boolean).length;
762
- }
763
- if (options.errorDetails === true ||
764
- !Number.isFinite(options.errorsSpace)) {
765
- object.errors = factorizedErrors;
766
- if (filtered)
767
- object.filteredErrorDetailsCount = filtered;
768
- return;
769
- }
770
- const { errors, filtered: filteredBySpace } = (0, statsFactoryUtils_1.errorsSpaceLimit)(factorizedErrors, options.errorsSpace);
771
- object.filteredErrorDetailsCount = filtered + filteredBySpace;
772
- object.errors = errors;
773
- },
774
- errorsCount: (object, compilation, { cachedGetErrors }) => {
775
- object.errorsCount = (0, statsFactoryUtils_1.countWithChildren)(compilation, c => cachedGetErrors(c));
776
- },
777
- warnings: (object, compilation, context, options, factory) => {
778
- const { type, cachedGetWarnings } = context;
779
- const rawWarnings = factory.create(`${type}.warnings`, cachedGetWarnings(compilation), context);
780
- let filtered = 0;
781
- if (options.errorDetails === "auto") {
782
- filtered = cachedGetWarnings(compilation)
783
- .map(e => typeof e !== "string" && e.details)
784
- .filter(Boolean).length;
785
- }
786
- if (options.errorDetails === true ||
787
- !Number.isFinite(options.warningsSpace)) {
788
- object.warnings = rawWarnings;
789
- if (filtered)
790
- object.filteredWarningDetailsCount = filtered;
791
- return;
792
- }
793
- const { errors: warnings, filtered: filteredBySpace } = (0, statsFactoryUtils_1.errorsSpaceLimit)(rawWarnings, options.warningsSpace);
794
- object.filteredWarningDetailsCount = filtered + filteredBySpace;
795
- object.warnings = warnings;
796
- },
797
- warningsCount: (object, compilation, context) => {
798
- const { cachedGetWarnings } = context;
799
- object.warningsCount = (0, statsFactoryUtils_1.countWithChildren)(compilation, c => {
800
- return cachedGetWarnings(c);
801
- });
802
- },
803
- children: (object, compilation, context, _options, factory) => {
804
- const { type } = context;
805
- object.children = factory.create(`${type}.children`, compilation.children, context);
806
- }
807
- },
808
- asset: {
809
- _: (object, asset, context, options, factory) => {
810
- object.type = asset.type;
811
- object.name = asset.name;
812
- object.size = asset.size;
813
- object.emitted = asset.emitted;
814
- object.info = {
815
- ...asset.info,
816
- related: Object.fromEntries(asset.info.related.map(i => [i.name, i.value]))
817
- };
818
- // - comparedForEmit
819
- const cached = !object.emitted;
820
- object.cached = cached;
821
- if (!cached || options.cachedAssets) {
822
- Object.assign(object, factory.create(`${context.type}$visible`, asset, context));
823
- }
824
- }
825
- },
826
- asset$visible: {
827
- _: (object, asset) => {
828
- object.chunkNames = asset.chunkNames;
829
- object.chunkIdHints = asset.chunkIdHints.filter(Boolean);
830
- object.auxiliaryChunkNames = asset.auxiliaryChunkNames;
831
- object.auxiliaryChunkIdHints =
832
- asset.auxiliaryChunkIdHints.filter(Boolean);
833
- },
834
- relatedAssets: (object, asset, context, _options, factory) => {
835
- const { type } = context;
836
- object.related = factory.create(`${type.slice(0, -8)}.related`, asset.related, context);
837
- object.filteredRelated = asset.related
838
- ? asset.related.length - object.related.length
839
- : undefined;
840
- },
841
- ids: (object, asset) => {
842
- object.chunks = asset.chunks;
843
- object.auxiliaryChunks = asset.auxiliaryChunks;
844
- },
845
- performance: (object, asset) => {
846
- object.isOverSizeLimit = asset.info.isOverSizeLimit;
847
- }
848
- },
849
- chunkGroup: {
850
- _: (object, { name, chunkGroup }, _context, { chunkGroupMaxAssets }) => {
851
- object.name = name;
852
- object.chunks = chunkGroup.chunks;
853
- object.assets = chunkGroup.assets;
854
- object.filteredAssets =
855
- chunkGroup.assets.length <= chunkGroupMaxAssets
856
- ? 0
857
- : chunkGroup.assets.length;
858
- object.assetsSize = chunkGroup.assetsSize;
859
- object.auxiliaryAssets = chunkGroup.auxiliaryAssets;
860
- object.auxiliaryAssetsSize = chunkGroup.auxiliaryAssetsSize;
861
- object.children = chunkGroup.children;
862
- object.childAssets = chunkGroup.childAssets;
863
- },
864
- performance: (object, { chunkGroup }) => {
865
- object.isOverSizeLimit = chunkGroup.isOverSizeLimit;
866
- }
867
- },
868
- module: {
869
- _: (object, module, context, options, factory) => {
870
- const { type } = context;
871
- const { commonAttributes } = module;
872
- object.type = commonAttributes.type;
873
- object.moduleType = commonAttributes.moduleType;
874
- object.layer = commonAttributes.layer;
875
- object.size = commonAttributes.size;
876
- const sizes = commonAttributes.sizes.map(({ sourceType, size }) => [
877
- sourceType,
878
- size
879
- ]);
880
- sizes.sort((a, b) => -compareIds(a, b));
881
- object.sizes = Object.fromEntries(sizes);
882
- object.built = commonAttributes.built;
883
- object.codeGenerated = commonAttributes.codeGenerated;
884
- object.buildTimeExecuted = commonAttributes.buildTimeExecuted;
885
- object.cached = commonAttributes.cached;
886
- if (commonAttributes.built ||
887
- commonAttributes.codeGenerated ||
888
- options.cachedModules) {
889
- Object.assign(object, factory.create(`${type}$visible`, module, context));
890
- }
891
- }
892
- },
893
- module$visible: {
894
- _: (object, module, context, _options, factory) => {
895
- const { type } = context;
896
- const { commonAttributes } = module;
897
- if (commonAttributes.moduleDescriptor) {
898
- object.identifier = commonAttributes.moduleDescriptor.identifier;
899
- object.name = commonAttributes.moduleDescriptor.name;
900
- }
901
- object.nameForCondition = commonAttributes.nameForCondition;
902
- object.index = commonAttributes.preOrderIndex;
903
- object.preOrderIndex = commonAttributes.preOrderIndex;
904
- object.index2 = commonAttributes.postOrderIndex;
905
- object.postOrderIndex = commonAttributes.postOrderIndex;
906
- object.cacheable = commonAttributes.cacheable;
907
- object.optional = commonAttributes.optional;
908
- object.orphan = commonAttributes.orphan;
909
- object.dependent = module.dependent;
910
- object.issuer = module.issuerDescriptor?.identifier;
911
- object.issuerName = module.issuerDescriptor?.name;
912
- object.issuerPath =
913
- module.issuerDescriptor &&
914
- factory.create(`${type.slice(0, -8)}.issuerPath`, module.issuerPath, context);
915
- object.failed = commonAttributes.failed;
916
- object.errors = commonAttributes.errors;
917
- object.warnings = commonAttributes.warnings;
918
- const profile = commonAttributes.profile;
919
- if (profile) {
920
- object.profile = factory.create(`${type}.profile`, profile, context);
921
- }
922
- },
923
- ids: (object, module) => {
924
- const { commonAttributes } = module;
925
- if (commonAttributes.moduleDescriptor) {
926
- object.id = commonAttributes.moduleDescriptor.id;
927
- }
928
- object.issuerId = module.issuerDescriptor?.id;
929
- object.chunks = commonAttributes.chunks;
930
- },
931
- moduleAssets: (object, module) => {
932
- object.assets = module.commonAttributes.assets;
933
- },
934
- reasons: (object, module, context, options, factory) => {
935
- const { type } = context;
936
- const groupsReasons = factory.create(`${type.slice(0, -8)}.reasons`, module.commonAttributes.reasons, context);
937
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupsReasons, options.reasonsSpace);
938
- object.reasons = limited.children;
939
- object.filteredReasons = limited.filteredChildren;
940
- },
941
- source: (object, module) => {
942
- const { commonAttributes } = module;
943
- object.source = commonAttributes.source;
944
- },
945
- usedExports: (object, module) => {
946
- if (typeof module.usedExports === "string") {
947
- if (module.usedExports === "null") {
948
- object.usedExports = null;
949
- }
950
- else {
951
- object.usedExports = module.usedExports === "true";
952
- }
953
- }
954
- else if (Array.isArray(module.usedExports)) {
955
- object.usedExports = module.usedExports;
956
- }
957
- else {
958
- object.usedExports = null;
959
- }
960
- },
961
- providedExports: (object, module) => {
962
- const { commonAttributes } = module;
963
- if (Array.isArray(commonAttributes.providedExports)) {
964
- object.providedExports = commonAttributes.providedExports;
965
- }
966
- else {
967
- object.providedExports = null;
968
- }
969
- },
970
- optimizationBailout: (object, module) => {
971
- object.optimizationBailout =
972
- module.commonAttributes.optimizationBailout || null;
973
- },
974
- depth: (object, module) => {
975
- object.depth = module.commonAttributes.depth;
976
- },
977
- nestedModules: (object, module, context, options, factory) => {
978
- const { type } = context;
979
- const innerModules =
980
- /** @type {Module & { modules?: Module[] }} */ module.modules;
981
- if (Array.isArray(innerModules) && innerModules.length > 0) {
982
- const groupedModules = factory.create(`${type.slice(0, -8)}.modules`, innerModules, context);
983
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedModules, options.nestedModulesSpace);
984
- object.modules = limited.children;
985
- object.filteredModules = limited.filteredChildren;
986
- }
987
- }
988
- },
989
- profile: {
990
- _: (object, profile) => {
991
- const factory = (0, statsFactoryUtils_1.resolveStatsMillisecond)(profile.factory);
992
- const building = (0, statsFactoryUtils_1.resolveStatsMillisecond)(profile.building);
993
- const statsProfile = {
994
- total: factory + building,
995
- resolving: factory,
996
- building
997
- };
998
- Object.assign(object, statsProfile);
999
- }
1000
- },
1001
- moduleIssuer: {
1002
- _: (object, module, _context, _options, _factory) => {
1003
- if (module.moduleDescriptor) {
1004
- object.identifier = module.moduleDescriptor.identifier;
1005
- object.name = module.moduleDescriptor.name;
1006
- // - profile
1007
- }
1008
- },
1009
- ids: (object, module) => {
1010
- object.id = module.moduleDescriptor.id;
1011
- }
1012
- },
1013
- moduleReason: {
1014
- _: (object, reason) => {
1015
- if (reason.moduleDescriptor) {
1016
- object.moduleIdentifier = reason.moduleDescriptor.identifier;
1017
- object.moduleName = reason.moduleDescriptor.name;
1018
- }
1019
- object.type = reason.type;
1020
- object.userRequest = reason.userRequest;
1021
- if (reason.resolvedModuleDescriptor) {
1022
- object.resolvedModuleIdentifier =
1023
- reason.resolvedModuleDescriptor.identifier;
1024
- object.resolvedModule = reason.resolvedModuleDescriptor.name;
1025
- }
1026
- // - explanation
1027
- // - active
1028
- // - loc
1029
- },
1030
- ids: (object, reason) => {
1031
- object.moduleId = reason.moduleDescriptor
1032
- ? reason.moduleDescriptor.id
1033
- : null;
1034
- object.resolvedModuleId = reason.resolvedModuleDescriptor
1035
- ? reason.resolvedModuleDescriptor.id
1036
- : null;
1037
- }
1038
- },
1039
- chunk: {
1040
- _: (object, chunk) => {
1041
- object.type = chunk.type;
1042
- object.rendered = chunk.rendered;
1043
- object.initial = chunk.initial;
1044
- object.entry = chunk.entry;
1045
- object.reason = chunk.reason;
1046
- object.size = chunk.size;
1047
- object.sizes = Object.fromEntries(chunk.sizes.map(({ sourceType, size }) => [sourceType, size]));
1048
- object.names = chunk.names;
1049
- object.idHints = chunk.idHints;
1050
- object.runtime = chunk.runtime;
1051
- object.files = chunk.files;
1052
- object.auxiliaryFiles = chunk.auxiliaryFiles;
1053
- object.hash = chunk.hash;
1054
- object.childrenByOrder = chunk.childrenByOrder;
1055
- },
1056
- ids: (object, chunk) => {
1057
- object.id = chunk.id;
1058
- },
1059
- chunkRelations: (object, chunk) => {
1060
- object.siblings = chunk.siblings;
1061
- object.parents = chunk.parents;
1062
- object.children = chunk.children;
1063
- },
1064
- chunkModules: (object, chunk, context, options, factory) => {
1065
- const { type } = context;
1066
- const groupedModules = factory.create(`${type}.modules`, chunk.modules, context);
1067
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedModules, options.chunkModulesSpace);
1068
- object.modules = limited.children;
1069
- object.filteredModules = limited.filteredChildren;
1070
- },
1071
- chunkOrigins: (object, chunk, context, _options, factory) => {
1072
- const { type } = context;
1073
- object.origins = factory.create(`${type}.origins`, chunk.origins, context);
1074
- }
1075
- },
1076
- chunkOrigin: {
1077
- _: (object, origin, _context) => {
1078
- const { moduleDescriptor, loc, request } = origin;
1079
- const statsChunkOrigin = {
1080
- module: moduleDescriptor ? moduleDescriptor.identifier : "",
1081
- moduleIdentifier: moduleDescriptor ? moduleDescriptor.identifier : "",
1082
- moduleName: moduleDescriptor ? moduleDescriptor.name : "",
1083
- loc,
1084
- request
1085
- };
1086
- Object.assign(object, statsChunkOrigin);
1087
- },
1088
- ids: (object, origin) => {
1089
- object.moduleId = origin.moduleDescriptor?.id;
1090
- }
1091
- },
1092
- error: EXTRACT_ERROR,
1093
- warning: EXTRACT_ERROR,
1094
- moduleTraceItem: {
1095
- _: (object, { origin, module }, _context, { requestShortener }, _factory) => {
1096
- if (origin.moduleDescriptor) {
1097
- object.originIdentifier = origin.moduleDescriptor.identifier;
1098
- object.originName = origin.moduleDescriptor.name;
1099
- }
1100
- if (module.moduleDescriptor) {
1101
- object.moduleIdentifier = module.moduleDescriptor.identifier;
1102
- object.moduleName = module.moduleDescriptor.name;
1103
- }
1104
- },
1105
- ids: (object, { origin, module }) => {
1106
- object.originId = origin.moduleDescriptor.id;
1107
- object.moduleId = module.moduleDescriptor.id;
1108
- }
1109
- }
1110
- // - moduleTraceDependency
1111
- };
1112
- const FILTER = {
1113
- "module.reasons": {
1114
- "!orphanModules": reason => {
1115
- if (reason.moduleChunks === 0) {
1116
- return false;
1117
- }
1118
- }
1119
- }
1120
- };
1121
- const FILTER_RESULTS = {
1122
- // Deprecated: "compilation.warnings": {}
1123
- // Keep this object to retain this phase.
1124
- };
1125
- class DefaultStatsFactoryPlugin {
1126
- apply(compiler) {
1127
- compiler.hooks.compilation.tap("DefaultStatsFactoryPlugin", compilation => {
1128
- compilation.hooks.statsFactory.tap("DefaultStatsFactoryPlugin", (stats, options) => {
1129
- (0, statsFactoryUtils_1.iterateConfig)(SIMPLE_EXTRACTORS, options, (hookFor, fn) => {
1130
- stats.hooks.extract
1131
- .for(hookFor)
1132
- .tap("DefaultStatsFactoryPlugin", (obj, data, ctx) => fn(obj, data, ctx, options, stats));
1133
- });
1134
- (0, statsFactoryUtils_1.iterateConfig)(FILTER, options, (hookFor, fn) => {
1135
- stats.hooks.filter
1136
- .for(hookFor)
1137
- .tap("DefaultStatsFactoryPlugin", (item, ctx, idx, i) => fn(item, ctx, options, idx, i));
1138
- });
1139
- (0, statsFactoryUtils_1.iterateConfig)(FILTER_RESULTS, options, (hookFor, fn) => {
1140
- stats.hooks.filterResults
1141
- .for(hookFor)
1142
- .tap("DefaultStatsFactoryPlugin", (item, ctx, idx, i) => fn(item, ctx, options, idx, i));
1143
- });
1144
- (0, statsFactoryUtils_1.iterateConfig)(SORTERS, options, (hookFor, fn) => {
1145
- stats.hooks.sort
1146
- .for(hookFor)
1147
- .tap("DefaultStatsFactoryPlugin", (comparators, ctx) => fn(comparators, ctx, options));
1148
- });
1149
- (0, statsFactoryUtils_1.iterateConfig)(RESULT_SORTERS, options, (hookFor, fn) => {
1150
- stats.hooks.sortResults
1151
- .for(hookFor)
1152
- .tap("DefaultStatsFactoryPlugin", (comparators, ctx) => fn(comparators, ctx, options));
1153
- });
1154
- (0, statsFactoryUtils_1.iterateConfig)(RESULT_GROUPERS, options, (hookFor, fn) => {
1155
- stats.hooks.groupResults
1156
- .for(hookFor)
1157
- .tap("DefaultStatsFactoryPlugin", (groupConfigs, ctx) => fn(groupConfigs, ctx, options));
1158
- });
1159
- for (const key of Object.keys(ITEM_NAMES)) {
1160
- const itemName = ITEM_NAMES[key];
1161
- stats.hooks.getItemName
1162
- .for(key)
1163
- .tap("DefaultStatsFactoryPlugin", () => itemName);
1164
- }
1165
- for (const key of Object.keys(MERGER)) {
1166
- const merger = MERGER[key];
1167
- stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
1168
- }
1169
- });
1170
- });
1171
- }
1172
- }
1173
- exports.DefaultStatsFactoryPlugin = DefaultStatsFactoryPlugin;