@rspack/core 0.0.7 → 0.0.9
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.
- package/dist/compilation.d.ts +64 -0
- package/dist/compilation.d.ts.map +1 -0
- package/dist/compilation.js +148 -0
- package/dist/compilation.js.map +1 -0
- package/dist/compiler.d.ts +52 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +383 -0
- package/dist/compiler.js.map +1 -0
- package/dist/config/RspackOptions.d.ts +36 -0
- package/dist/config/RspackOptions.d.ts.map +1 -0
- package/{lib/config/define.js → dist/config/RspackOptions.js} +1 -0
- package/dist/config/RspackOptions.js.map +1 -0
- package/dist/config/browserslistTargetHandler.d.ts +20 -0
- package/dist/config/browserslistTargetHandler.d.ts.map +1 -0
- package/dist/config/browserslistTargetHandler.js +320 -0
- package/dist/config/browserslistTargetHandler.js.map +1 -0
- package/dist/config/builtins.d.ts +15 -0
- package/dist/config/builtins.d.ts.map +1 -0
- package/dist/config/builtins.js +49 -0
- package/dist/config/builtins.js.map +1 -0
- package/{lib → dist}/config/context.d.ts +1 -0
- package/dist/config/context.d.ts.map +1 -0
- package/{lib → dist}/config/context.js +1 -0
- package/dist/config/context.js.map +1 -0
- package/dist/config/defaults.d.ts +4 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +57 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/devServer.d.ts +21 -0
- package/dist/config/devServer.d.ts.map +1 -0
- package/{lib/config/builtins.js → dist/config/devServer.js} +1 -0
- package/dist/config/devServer.js.map +1 -0
- package/dist/config/devtool.d.ts +5 -0
- package/dist/config/devtool.d.ts.map +1 -0
- package/dist/config/devtool.js +13 -0
- package/dist/config/devtool.js.map +1 -0
- package/dist/config/entry.d.ts +8 -0
- package/dist/config/entry.d.ts.map +1 -0
- package/dist/config/entry.js +39 -0
- package/dist/config/entry.js.map +1 -0
- package/dist/config/external.d.ts +5 -0
- package/dist/config/external.d.ts.map +1 -0
- package/{lib → dist}/config/external.js +1 -0
- package/dist/config/external.js.map +1 -0
- package/dist/config/index.d.ts +57 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +55 -0
- package/dist/config/index.js.map +1 -0
- package/{lib → dist}/config/mode.d.ts +1 -0
- package/dist/config/mode.d.ts.map +1 -0
- package/{lib → dist}/config/mode.js +1 -0
- package/dist/config/mode.js.map +1 -0
- package/{lib → dist}/config/module.d.ts +22 -7
- package/dist/config/module.d.ts.map +1 -0
- package/{lib → dist}/config/module.js +29 -21
- package/dist/config/module.js.map +1 -0
- package/{lib → dist}/config/output.d.ts +6 -0
- package/dist/config/output.d.ts.map +1 -0
- package/dist/config/output.js +10 -0
- package/dist/config/output.js.map +1 -0
- package/dist/config/plugin.d.ts +6 -0
- package/dist/config/plugin.d.ts.map +1 -0
- package/{lib → dist}/config/plugin.js +1 -0
- package/dist/config/plugin.js.map +1 -0
- package/dist/config/resolve.d.ts +22 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +33 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/stats.d.ts +21 -0
- package/dist/config/stats.d.ts.map +1 -0
- package/dist/config/stats.js +17 -0
- package/dist/config/stats.js.map +1 -0
- package/dist/config/target.d.ts +7 -0
- package/dist/config/target.d.ts.map +1 -0
- package/dist/config/target.js +21 -0
- package/dist/config/target.js.map +1 -0
- package/dist/config/watch.d.ts +8 -0
- package/dist/config/watch.d.ts.map +1 -0
- package/dist/config/watch.js +16 -0
- package/dist/config/watch.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/Logger.d.ts +43 -0
- package/dist/logging/Logger.d.ts.map +1 -0
- package/dist/logging/Logger.js +136 -0
- package/dist/logging/Logger.js.map +1 -0
- package/dist/logging/createConsoleLogger.d.ts +7 -0
- package/dist/logging/createConsoleLogger.d.ts.map +1 -0
- package/dist/logging/createConsoleLogger.js +227 -0
- package/dist/logging/createConsoleLogger.js.map +1 -0
- package/dist/logging/runtime.d.ts +14 -0
- package/dist/logging/runtime.d.ts.map +1 -0
- package/dist/logging/runtime.js +42 -0
- package/dist/logging/runtime.js.map +1 -0
- package/dist/logging/truncateArgs.d.ts +8 -0
- package/dist/logging/truncateArgs.d.ts.map +1 -0
- package/dist/logging/truncateArgs.js +81 -0
- package/dist/logging/truncateArgs.js.map +1 -0
- package/dist/node/NodeTargetPlugin.d.ts +5 -0
- package/dist/node/NodeTargetPlugin.d.ts.map +1 -0
- package/dist/node/NodeTargetPlugin.js +70 -0
- package/dist/node/NodeTargetPlugin.js.map +1 -0
- package/dist/node/nodeConsole.d.ts +22 -0
- package/dist/node/nodeConsole.d.ts.map +1 -0
- package/dist/node/nodeConsole.js +121 -0
- package/dist/node/nodeConsole.js.map +1 -0
- package/dist/rspack.d.ts +8 -0
- package/dist/rspack.d.ts.map +1 -0
- package/dist/rspack.js +59 -0
- package/dist/rspack.js.map +1 -0
- package/dist/rspackOptionsApply.d.ts +6 -0
- package/dist/rspackOptionsApply.d.ts.map +1 -0
- package/dist/rspackOptionsApply.js +25 -0
- package/dist/rspackOptionsApply.js.map +1 -0
- package/dist/stats.d.ts +21 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +870 -0
- package/dist/stats.js.map +1 -0
- package/dist/utils/createHash.d.ts +7 -0
- package/dist/utils/createHash.d.ts.map +1 -0
- package/dist/utils/createHash.js +166 -0
- package/dist/utils/createHash.js.map +1 -0
- package/dist/utils/createSource.d.ts +6 -0
- package/dist/utils/createSource.d.ts.map +1 -0
- package/dist/utils/createSource.js +48 -0
- package/dist/utils/createSource.js.map +1 -0
- package/dist/utils/hash/BatchedHash.d.ts +16 -0
- package/dist/utils/hash/BatchedHash.d.ts.map +1 -0
- package/dist/utils/hash/BatchedHash.js +61 -0
- package/dist/utils/hash/BatchedHash.js.map +1 -0
- package/dist/utils/hash/index.d.ts +19 -0
- package/dist/utils/hash/index.d.ts.map +1 -0
- package/dist/utils/hash/index.js +28 -0
- package/dist/utils/hash/index.js.map +1 -0
- package/dist/utils/hash/md4.d.ts +3 -0
- package/dist/utils/hash/md4.d.ts.map +1 -0
- package/dist/utils/hash/md4.js +13 -0
- package/dist/utils/hash/md4.js.map +1 -0
- package/dist/utils/hash/wasm-hash.d.ts +7 -0
- package/dist/utils/hash/wasm-hash.d.ts.map +1 -0
- package/dist/utils/hash/wasm-hash.js +162 -0
- package/dist/utils/hash/wasm-hash.js.map +1 -0
- package/dist/utils/hash/xxhash64.d.ts +3 -0
- package/dist/utils/hash/xxhash64.d.ts.map +1 -0
- package/dist/utils/hash/xxhash64.js +13 -0
- package/dist/utils/hash/xxhash64.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/memoize.d.ts +2 -0
- package/dist/utils/memoize.d.ts.map +1 -0
- package/dist/utils/memoize.js +22 -0
- package/dist/utils/memoize.js.map +1 -0
- package/dist/web/polyfillBuiltins.d.ts +5 -0
- package/dist/web/polyfillBuiltins.d.ts.map +1 -0
- package/dist/web/polyfillBuiltins.js +43 -0
- package/dist/web/polyfillBuiltins.js.map +1 -0
- package/package.json +28 -23
- package/CHANGELOG.md +0 -51
- package/bin.js +0 -1
- package/example/basic.ts +0 -71
- package/example/react-example/index.html +0 -12
- package/example/react-example/package.json +0 -17
- package/example/react-example/rspack.config.json +0 -13
- package/example/react-example/src/app.jsx +0 -44
- package/example/react-example/src/base.css +0 -9
- package/example/react-example/src/button.jsx +0 -3
- package/example/react-example/src/dark.svg +0 -1
- package/example/react-example/src/data.json +0 -5
- package/example/react-example/src/file.jpg +0 -0
- package/example/react-example/src/file.png +0 -0
- package/example/react-example/src/file.svg +0 -1
- package/example/react-example/src/foo.css +0 -3
- package/example/react-example/src/index.html +0 -32
- package/example/react-example/src/index.js +0 -1
- package/example/react-example/src/light.svg +0 -48
- package/example/react-example/src/logo.svg +0 -18
- package/example/react-with-sass.ts +0 -28
- package/lib/bin/index.d.ts +0 -1
- package/lib/bin/index.js +0 -32
- package/lib/build.d.ts +0 -1
- package/lib/build.js +0 -12
- package/lib/config/builtins.d.ts +0 -3
- package/lib/config/define.d.ts +0 -2
- package/lib/config/dev.d.ts +0 -17
- package/lib/config/dev.js +0 -17
- package/lib/config/entry.d.ts +0 -2
- package/lib/config/entry.js +0 -2
- package/lib/config/external.d.ts +0 -2
- package/lib/config/index.d.ts +0 -45
- package/lib/config/index.js +0 -37
- package/lib/config/output.js +0 -14
- package/lib/config/plugin.d.ts +0 -5
- package/lib/config/resolve.d.ts +0 -6
- package/lib/config/resolve.js +0 -2
- package/lib/config/target.d.ts +0 -5
- package/lib/config/target.js +0 -13
- package/lib/index.d.ts +0 -39
- package/lib/index.js +0 -154
- package/lib/server/index.d.ts +0 -0
- package/lib/server/index.js +0 -0
- package/src/bin/index.ts +0 -36
- package/src/build.ts +0 -8
- package/src/config/builtins.ts +0 -5
- package/src/config/context.ts +0 -3
- package/src/config/define.ts +0 -3
- package/src/config/dev.ts +0 -32
- package/src/config/entry.ts +0 -3
- package/src/config/external.ts +0 -3
- package/src/config/index.ts +0 -80
- package/src/config/mode.ts +0 -2
- package/src/config/module.ts +0 -240
- package/src/config/output.ts +0 -29
- package/src/config/plugin.ts +0 -6
- package/src/config/resolve.ts +0 -6
- package/src/config/target.ts +0 -28
- package/src/index.ts +0 -140
- package/src/server/index.ts +0 -0
- package/tests/config.test.ts +0 -40
- package/tsconfig.json +0 -14
package/dist/stats.js
ADDED
|
@@ -0,0 +1,870 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Stats_statsJson;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.normalizeStatsPreset = exports.optionsOrFallback = exports.Stats = void 0;
|
|
16
|
+
const Logger_1 = require("./logging/Logger");
|
|
17
|
+
class Stats {
|
|
18
|
+
constructor(statsJson) {
|
|
19
|
+
// remove this when support delegate compilation to rust side
|
|
20
|
+
_Stats_statsJson.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _Stats_statsJson, {
|
|
22
|
+
...statsJson,
|
|
23
|
+
entrypoints: statsJson.entrypoints.reduce((acc, cur) => {
|
|
24
|
+
acc[cur.name] = cur;
|
|
25
|
+
return acc;
|
|
26
|
+
}, {})
|
|
27
|
+
}, "f");
|
|
28
|
+
}
|
|
29
|
+
hasErrors() {
|
|
30
|
+
return __classPrivateFieldGet(this, _Stats_statsJson, "f").errorsCount > 0;
|
|
31
|
+
}
|
|
32
|
+
hasWarnings() {
|
|
33
|
+
return __classPrivateFieldGet(this, _Stats_statsJson, "f").warningsCount > 0;
|
|
34
|
+
}
|
|
35
|
+
toJson(opts, forToString) {
|
|
36
|
+
const options = normalizeStatsPreset(opts);
|
|
37
|
+
const all = options.all;
|
|
38
|
+
const optionOrLocalFallback = (v, def) => v !== undefined ? v : all !== undefined ? all : def;
|
|
39
|
+
const showAssets = optionOrLocalFallback(options.assets, true);
|
|
40
|
+
const showChunks = optionOrLocalFallback(options.chunks, !forToString);
|
|
41
|
+
const showModules = optionOrLocalFallback(options.modules, true);
|
|
42
|
+
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true);
|
|
43
|
+
const showErrors = optionOrLocalFallback(options.errors, true);
|
|
44
|
+
const showErrorsCount = optionOrLocalFallback(options.errorsCount, true);
|
|
45
|
+
const showWarninigs = optionOrLocalFallback(options.warnings, true);
|
|
46
|
+
const showWarningsCount = optionOrLocalFallback(options.warningsCount, true);
|
|
47
|
+
let obj = {};
|
|
48
|
+
if (showAssets) {
|
|
49
|
+
obj.assets = __classPrivateFieldGet(this, _Stats_statsJson, "f").assets;
|
|
50
|
+
}
|
|
51
|
+
if (showChunks) {
|
|
52
|
+
obj.chunks = __classPrivateFieldGet(this, _Stats_statsJson, "f").chunks;
|
|
53
|
+
}
|
|
54
|
+
if (showModules) {
|
|
55
|
+
obj.modules = __classPrivateFieldGet(this, _Stats_statsJson, "f").modules;
|
|
56
|
+
}
|
|
57
|
+
if (showEntrypoints) {
|
|
58
|
+
obj.entrypoints = __classPrivateFieldGet(this, _Stats_statsJson, "f").entrypoints;
|
|
59
|
+
}
|
|
60
|
+
if (showErrors) {
|
|
61
|
+
obj.errors = __classPrivateFieldGet(this, _Stats_statsJson, "f").errors;
|
|
62
|
+
}
|
|
63
|
+
if (showErrorsCount) {
|
|
64
|
+
obj.errorsCount = __classPrivateFieldGet(this, _Stats_statsJson, "f").errorsCount;
|
|
65
|
+
}
|
|
66
|
+
if (showWarninigs) {
|
|
67
|
+
obj.warnings = __classPrivateFieldGet(this, _Stats_statsJson, "f").warnings;
|
|
68
|
+
}
|
|
69
|
+
if (showWarningsCount) {
|
|
70
|
+
obj.warningsCount = __classPrivateFieldGet(this, _Stats_statsJson, "f").warningsCount;
|
|
71
|
+
}
|
|
72
|
+
if (obj.modules && forToString) {
|
|
73
|
+
obj.filteredModules = obj.modules.length - 15;
|
|
74
|
+
obj.modules = obj.modules.slice(0, 15);
|
|
75
|
+
}
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
toString(opts) {
|
|
79
|
+
const options = normalizeStatsPreset(opts);
|
|
80
|
+
const useColors = (0, exports.optionsOrFallback)(options.colors, false);
|
|
81
|
+
const obj = this.toJson(options, true);
|
|
82
|
+
return Stats.jsonToString(obj, useColors);
|
|
83
|
+
}
|
|
84
|
+
static jsonToString(obj, useColors) {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
const buf = [];
|
|
87
|
+
const defaultColors = {
|
|
88
|
+
bold: "\u001b[1m",
|
|
89
|
+
yellow: "\u001b[1m\u001b[33m",
|
|
90
|
+
red: "\u001b[1m\u001b[31m",
|
|
91
|
+
green: "\u001b[1m\u001b[32m",
|
|
92
|
+
cyan: "\u001b[1m\u001b[36m",
|
|
93
|
+
magenta: "\u001b[1m\u001b[35m"
|
|
94
|
+
};
|
|
95
|
+
const colors = Object.keys(defaultColors).reduce((obj, color) => {
|
|
96
|
+
obj[color] = str => {
|
|
97
|
+
if (useColors) {
|
|
98
|
+
buf.push(useColors === true || useColors[color] === undefined
|
|
99
|
+
? defaultColors[color]
|
|
100
|
+
: useColors[color]);
|
|
101
|
+
}
|
|
102
|
+
buf.push(str);
|
|
103
|
+
if (useColors) {
|
|
104
|
+
buf.push("\u001b[39m\u001b[22m");
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return obj;
|
|
108
|
+
}, {
|
|
109
|
+
normal: str => buf.push(str)
|
|
110
|
+
});
|
|
111
|
+
const coloredTime = time => {
|
|
112
|
+
let times = [800, 400, 200, 100];
|
|
113
|
+
if (obj.time) {
|
|
114
|
+
times = [obj.time / 2, obj.time / 4, obj.time / 8, obj.time / 16];
|
|
115
|
+
}
|
|
116
|
+
if (time < times[3])
|
|
117
|
+
colors.normal(`${time}ms`);
|
|
118
|
+
else if (time < times[2])
|
|
119
|
+
colors.bold(`${time}ms`);
|
|
120
|
+
else if (time < times[1])
|
|
121
|
+
colors.green(`${time}ms`);
|
|
122
|
+
else if (time < times[0])
|
|
123
|
+
colors.yellow(`${time}ms`);
|
|
124
|
+
else
|
|
125
|
+
colors.red(`${time}ms`);
|
|
126
|
+
};
|
|
127
|
+
const newline = () => buf.push("\n");
|
|
128
|
+
const getText = (arr, row, col) => {
|
|
129
|
+
return arr[row][col].value;
|
|
130
|
+
};
|
|
131
|
+
const table = (array, align, splitter) => {
|
|
132
|
+
const rows = array.length;
|
|
133
|
+
const cols = array[0].length;
|
|
134
|
+
const colSizes = new Array(cols);
|
|
135
|
+
for (let col = 0; col < cols; col++) {
|
|
136
|
+
colSizes[col] = 0;
|
|
137
|
+
}
|
|
138
|
+
for (let row = 0; row < rows; row++) {
|
|
139
|
+
for (let col = 0; col < cols; col++) {
|
|
140
|
+
const value = `${getText(array, row, col)}`;
|
|
141
|
+
if (value.length > colSizes[col]) {
|
|
142
|
+
colSizes[col] = value.length;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (let row = 0; row < rows; row++) {
|
|
147
|
+
for (let col = 0; col < cols; col++) {
|
|
148
|
+
const format = array[row][col].color;
|
|
149
|
+
const value = `${getText(array, row, col)}`;
|
|
150
|
+
let l = value.length;
|
|
151
|
+
if (align[col] === "l") {
|
|
152
|
+
format(value);
|
|
153
|
+
}
|
|
154
|
+
for (; l < colSizes[col] && col !== cols - 1; l++) {
|
|
155
|
+
colors.normal(" ");
|
|
156
|
+
}
|
|
157
|
+
if (align[col] === "r") {
|
|
158
|
+
format(value);
|
|
159
|
+
}
|
|
160
|
+
if (col + 1 < cols && colSizes[col] !== 0) {
|
|
161
|
+
colors.normal(splitter || " ");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
newline();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const getAssetColor = (asset, defaultColor) => {
|
|
168
|
+
if (asset.isOverSizeLimit) {
|
|
169
|
+
return colors.yellow;
|
|
170
|
+
}
|
|
171
|
+
return defaultColor;
|
|
172
|
+
};
|
|
173
|
+
if (obj.hash) {
|
|
174
|
+
colors.normal("Hash: ");
|
|
175
|
+
colors.bold(obj.hash);
|
|
176
|
+
newline();
|
|
177
|
+
}
|
|
178
|
+
if (obj.version) {
|
|
179
|
+
colors.normal("Version: webpack ");
|
|
180
|
+
colors.bold(obj.version);
|
|
181
|
+
newline();
|
|
182
|
+
}
|
|
183
|
+
if (typeof obj.time === "number") {
|
|
184
|
+
colors.normal("Time: ");
|
|
185
|
+
colors.bold(obj.time);
|
|
186
|
+
colors.normal("ms");
|
|
187
|
+
newline();
|
|
188
|
+
}
|
|
189
|
+
if (typeof obj.builtAt === "number") {
|
|
190
|
+
const builtAtDate = new Date(obj.builtAt);
|
|
191
|
+
let timeZone = undefined;
|
|
192
|
+
try {
|
|
193
|
+
builtAtDate.toLocaleTimeString();
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
// Force UTC if runtime timezone is unsupported
|
|
197
|
+
timeZone = "UTC";
|
|
198
|
+
}
|
|
199
|
+
colors.normal("Built at: ");
|
|
200
|
+
colors.normal(builtAtDate.toLocaleDateString(undefined, {
|
|
201
|
+
day: "2-digit",
|
|
202
|
+
month: "2-digit",
|
|
203
|
+
year: "numeric",
|
|
204
|
+
timeZone
|
|
205
|
+
}));
|
|
206
|
+
colors.normal(" ");
|
|
207
|
+
colors.bold(builtAtDate.toLocaleTimeString(undefined, { timeZone }));
|
|
208
|
+
newline();
|
|
209
|
+
}
|
|
210
|
+
if (obj.env) {
|
|
211
|
+
colors.normal("Environment (--env): ");
|
|
212
|
+
colors.bold(JSON.stringify(obj.env, null, 2));
|
|
213
|
+
newline();
|
|
214
|
+
}
|
|
215
|
+
if (obj.publicPath) {
|
|
216
|
+
colors.normal("PublicPath: ");
|
|
217
|
+
colors.bold(obj.publicPath);
|
|
218
|
+
newline();
|
|
219
|
+
}
|
|
220
|
+
if (obj.assets && obj.assets.length > 0) {
|
|
221
|
+
const t = [
|
|
222
|
+
[
|
|
223
|
+
{
|
|
224
|
+
value: "Asset",
|
|
225
|
+
color: colors.bold
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
value: "Size",
|
|
229
|
+
color: colors.bold
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
value: "Chunks",
|
|
233
|
+
color: colors.bold
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
value: "",
|
|
237
|
+
color: colors.bold
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
value: "",
|
|
241
|
+
color: colors.bold
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
value: "Chunk Names",
|
|
245
|
+
color: colors.bold
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
];
|
|
249
|
+
for (const asset of obj.assets) {
|
|
250
|
+
t.push([
|
|
251
|
+
{
|
|
252
|
+
value: asset.name,
|
|
253
|
+
color: getAssetColor(asset, colors.green)
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
value: SizeFormatHelpers.formatSize(asset.size),
|
|
257
|
+
color: getAssetColor(asset, colors.normal)
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
value: asset.chunks.join(", "),
|
|
261
|
+
color: colors.bold
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
value: [
|
|
265
|
+
asset.emitted && "[emitted]",
|
|
266
|
+
((_a = asset.info) === null || _a === void 0 ? void 0 : _a.immutable) && "[immutable]",
|
|
267
|
+
((_b = asset.info) === null || _b === void 0 ? void 0 : _b.development) && "[dev]",
|
|
268
|
+
((_c = asset.info) === null || _c === void 0 ? void 0 : _c.hotModuleReplacement) && "[hmr]"
|
|
269
|
+
]
|
|
270
|
+
.filter(Boolean)
|
|
271
|
+
.join(" "),
|
|
272
|
+
color: colors.green
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
value: asset.isOverSizeLimit ? "[big]" : "",
|
|
276
|
+
color: getAssetColor(asset, colors.normal)
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
value: asset.chunkNames.join(", "),
|
|
280
|
+
color: colors.normal
|
|
281
|
+
}
|
|
282
|
+
]);
|
|
283
|
+
}
|
|
284
|
+
table(t, "rrrlll");
|
|
285
|
+
}
|
|
286
|
+
if (obj.filteredAssets > 0) {
|
|
287
|
+
colors.normal(" ");
|
|
288
|
+
if (obj.assets.length > 0)
|
|
289
|
+
colors.normal("+ ");
|
|
290
|
+
colors.normal(obj.filteredAssets);
|
|
291
|
+
if (obj.assets.length > 0)
|
|
292
|
+
colors.normal(" hidden");
|
|
293
|
+
colors.normal(obj.filteredAssets !== 1 ? " assets" : " asset");
|
|
294
|
+
newline();
|
|
295
|
+
}
|
|
296
|
+
const processChunkGroups = (namedGroups, prefix) => {
|
|
297
|
+
for (const name of Object.keys(namedGroups)) {
|
|
298
|
+
const cg = namedGroups[name];
|
|
299
|
+
colors.normal(`${prefix} `);
|
|
300
|
+
colors.bold(name);
|
|
301
|
+
if (cg.isOverSizeLimit) {
|
|
302
|
+
colors.normal(" ");
|
|
303
|
+
colors.yellow("[big]");
|
|
304
|
+
}
|
|
305
|
+
colors.normal(" =");
|
|
306
|
+
for (const asset of cg.assets) {
|
|
307
|
+
colors.normal(" ");
|
|
308
|
+
colors.green(asset.name);
|
|
309
|
+
}
|
|
310
|
+
// for (const name of Object.keys(cg.childAssets)) {
|
|
311
|
+
// const assets = cg.childAssets[name];
|
|
312
|
+
// if (assets && assets.length > 0) {
|
|
313
|
+
// colors.normal(" ");
|
|
314
|
+
// colors.magenta(`(${name}:`);
|
|
315
|
+
// for (const asset of assets) {
|
|
316
|
+
// colors.normal(" ");
|
|
317
|
+
// colors.green(asset);
|
|
318
|
+
// }
|
|
319
|
+
// colors.magenta(")");
|
|
320
|
+
// }
|
|
321
|
+
// }
|
|
322
|
+
newline();
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
if (obj.entrypoints) {
|
|
326
|
+
processChunkGroups(obj.entrypoints, "Entrypoint");
|
|
327
|
+
}
|
|
328
|
+
if (obj.namedChunkGroups) {
|
|
329
|
+
let outputChunkGroups = obj.namedChunkGroups;
|
|
330
|
+
if (obj.entrypoints) {
|
|
331
|
+
outputChunkGroups = Object.keys(outputChunkGroups)
|
|
332
|
+
.filter(name => !obj.entrypoints[name])
|
|
333
|
+
.reduce((result, name) => {
|
|
334
|
+
result[name] = obj.namedChunkGroups[name];
|
|
335
|
+
return result;
|
|
336
|
+
}, {});
|
|
337
|
+
}
|
|
338
|
+
processChunkGroups(outputChunkGroups, "Chunk Group");
|
|
339
|
+
}
|
|
340
|
+
const modulesByIdentifier = {};
|
|
341
|
+
if (obj.modules) {
|
|
342
|
+
for (const module of obj.modules) {
|
|
343
|
+
modulesByIdentifier[`$${module.identifier}`] = module;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
else if (obj.chunks) {
|
|
347
|
+
for (const chunk of obj.chunks) {
|
|
348
|
+
if (chunk.modules) {
|
|
349
|
+
for (const module of chunk.modules) {
|
|
350
|
+
modulesByIdentifier[`$${module.identifier}`] = module;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const processModuleAttributes = module => {
|
|
356
|
+
colors.normal(" ");
|
|
357
|
+
colors.normal(SizeFormatHelpers.formatSize(module.size));
|
|
358
|
+
if (module.chunks) {
|
|
359
|
+
for (const chunk of module.chunks) {
|
|
360
|
+
colors.normal(" {");
|
|
361
|
+
colors.yellow(chunk);
|
|
362
|
+
colors.normal("}");
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (typeof module.depth === "number") {
|
|
366
|
+
colors.normal(` [depth ${module.depth}]`);
|
|
367
|
+
}
|
|
368
|
+
if (module.cacheable === false) {
|
|
369
|
+
colors.red(" [not cacheable]");
|
|
370
|
+
}
|
|
371
|
+
if (module.optional) {
|
|
372
|
+
colors.yellow(" [optional]");
|
|
373
|
+
}
|
|
374
|
+
if (module.built) {
|
|
375
|
+
colors.green(" [built]");
|
|
376
|
+
}
|
|
377
|
+
if (module.assets && module.assets.length) {
|
|
378
|
+
colors.magenta(` [${module.assets.length} asset${module.assets.length === 1 ? "" : "s"}]`);
|
|
379
|
+
}
|
|
380
|
+
if (module.prefetched) {
|
|
381
|
+
colors.magenta(" [prefetched]");
|
|
382
|
+
}
|
|
383
|
+
if (module.failed)
|
|
384
|
+
colors.red(" [failed]");
|
|
385
|
+
if (module.warnings) {
|
|
386
|
+
colors.yellow(` [${module.warnings} warning${module.warnings === 1 ? "" : "s"}]`);
|
|
387
|
+
}
|
|
388
|
+
if (module.errors) {
|
|
389
|
+
colors.red(` [${module.errors} error${module.errors === 1 ? "" : "s"}]`);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const processModuleContent = (module, prefix) => {
|
|
393
|
+
if (Array.isArray(module.providedExports)) {
|
|
394
|
+
colors.normal(prefix);
|
|
395
|
+
if (module.providedExports.length === 0) {
|
|
396
|
+
colors.cyan("[no exports]");
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
|
|
400
|
+
}
|
|
401
|
+
newline();
|
|
402
|
+
}
|
|
403
|
+
if (module.usedExports !== undefined) {
|
|
404
|
+
if (module.usedExports !== true) {
|
|
405
|
+
colors.normal(prefix);
|
|
406
|
+
if (module.usedExports === null) {
|
|
407
|
+
colors.cyan("[used exports unknown]");
|
|
408
|
+
}
|
|
409
|
+
else if (module.usedExports === false) {
|
|
410
|
+
colors.cyan("[no exports used]");
|
|
411
|
+
}
|
|
412
|
+
else if (Array.isArray(module.usedExports) &&
|
|
413
|
+
module.usedExports.length === 0) {
|
|
414
|
+
colors.cyan("[no exports used]");
|
|
415
|
+
}
|
|
416
|
+
else if (Array.isArray(module.usedExports)) {
|
|
417
|
+
const providedExportsCount = Array.isArray(module.providedExports)
|
|
418
|
+
? module.providedExports.length
|
|
419
|
+
: null;
|
|
420
|
+
if (providedExportsCount !== null &&
|
|
421
|
+
providedExportsCount === module.usedExports.length) {
|
|
422
|
+
colors.cyan("[all exports used]");
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
colors.cyan(`[only some exports used: ${module.usedExports.join(", ")}]`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
newline();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (Array.isArray(module.optimizationBailout)) {
|
|
432
|
+
for (const item of module.optimizationBailout) {
|
|
433
|
+
colors.normal(prefix);
|
|
434
|
+
colors.yellow(item);
|
|
435
|
+
newline();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (module.reasons) {
|
|
439
|
+
for (const reason of module.reasons) {
|
|
440
|
+
colors.normal(prefix);
|
|
441
|
+
if (reason.type) {
|
|
442
|
+
colors.normal(reason.type);
|
|
443
|
+
colors.normal(" ");
|
|
444
|
+
}
|
|
445
|
+
if (reason.userRequest) {
|
|
446
|
+
colors.cyan(reason.userRequest);
|
|
447
|
+
colors.normal(" ");
|
|
448
|
+
}
|
|
449
|
+
if (reason.moduleId !== null) {
|
|
450
|
+
colors.normal("[");
|
|
451
|
+
colors.normal(reason.moduleId);
|
|
452
|
+
colors.normal("]");
|
|
453
|
+
}
|
|
454
|
+
if (reason.module && reason.module !== reason.moduleId) {
|
|
455
|
+
colors.normal(" ");
|
|
456
|
+
colors.magenta(reason.module);
|
|
457
|
+
}
|
|
458
|
+
if (reason.loc) {
|
|
459
|
+
colors.normal(" ");
|
|
460
|
+
colors.normal(reason.loc);
|
|
461
|
+
}
|
|
462
|
+
if (reason.explanation) {
|
|
463
|
+
colors.normal(" ");
|
|
464
|
+
colors.cyan(reason.explanation);
|
|
465
|
+
}
|
|
466
|
+
newline();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (module.profile) {
|
|
470
|
+
colors.normal(prefix);
|
|
471
|
+
let sum = 0;
|
|
472
|
+
if (module.issuerPath) {
|
|
473
|
+
for (const m of module.issuerPath) {
|
|
474
|
+
colors.normal("[");
|
|
475
|
+
colors.normal(m.id);
|
|
476
|
+
colors.normal("] ");
|
|
477
|
+
if (m.profile) {
|
|
478
|
+
const time = (m.profile.factory || 0) + (m.profile.building || 0);
|
|
479
|
+
coloredTime(time);
|
|
480
|
+
sum += time;
|
|
481
|
+
colors.normal(" ");
|
|
482
|
+
}
|
|
483
|
+
colors.normal("-> ");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
for (const key of Object.keys(module.profile)) {
|
|
487
|
+
colors.normal(`${key}:`);
|
|
488
|
+
const time = module.profile[key];
|
|
489
|
+
coloredTime(time);
|
|
490
|
+
colors.normal(" ");
|
|
491
|
+
sum += time;
|
|
492
|
+
}
|
|
493
|
+
colors.normal("= ");
|
|
494
|
+
coloredTime(sum);
|
|
495
|
+
newline();
|
|
496
|
+
}
|
|
497
|
+
if (module.modules) {
|
|
498
|
+
processModulesList(module, prefix + "| ");
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
const processModulesList = (obj, prefix) => {
|
|
502
|
+
if (obj.modules) {
|
|
503
|
+
let maxModuleId = 0;
|
|
504
|
+
for (const module of obj.modules) {
|
|
505
|
+
if (typeof module.id === "number") {
|
|
506
|
+
if (maxModuleId < module.id)
|
|
507
|
+
maxModuleId = module.id;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
let contentPrefix = prefix + " ";
|
|
511
|
+
if (maxModuleId >= 10)
|
|
512
|
+
contentPrefix += " ";
|
|
513
|
+
if (maxModuleId >= 100)
|
|
514
|
+
contentPrefix += " ";
|
|
515
|
+
if (maxModuleId >= 1000)
|
|
516
|
+
contentPrefix += " ";
|
|
517
|
+
for (const module of obj.modules) {
|
|
518
|
+
colors.normal(prefix);
|
|
519
|
+
const name = module.name || module.identifier;
|
|
520
|
+
if (typeof module.id === "string" || typeof module.id === "number") {
|
|
521
|
+
if (typeof module.id === "number") {
|
|
522
|
+
if (module.id < 1000 && maxModuleId >= 1000)
|
|
523
|
+
colors.normal(" ");
|
|
524
|
+
if (module.id < 100 && maxModuleId >= 100)
|
|
525
|
+
colors.normal(" ");
|
|
526
|
+
if (module.id < 10 && maxModuleId >= 10)
|
|
527
|
+
colors.normal(" ");
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
if (maxModuleId >= 1000)
|
|
531
|
+
colors.normal(" ");
|
|
532
|
+
if (maxModuleId >= 100)
|
|
533
|
+
colors.normal(" ");
|
|
534
|
+
if (maxModuleId >= 10)
|
|
535
|
+
colors.normal(" ");
|
|
536
|
+
}
|
|
537
|
+
if (name !== module.id) {
|
|
538
|
+
colors.normal("[");
|
|
539
|
+
colors.normal(module.id);
|
|
540
|
+
colors.normal("]");
|
|
541
|
+
colors.normal(" ");
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
colors.normal("[");
|
|
545
|
+
colors.bold(module.id);
|
|
546
|
+
colors.normal("]");
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (name !== module.id) {
|
|
550
|
+
colors.bold(name);
|
|
551
|
+
}
|
|
552
|
+
processModuleAttributes(module);
|
|
553
|
+
newline();
|
|
554
|
+
processModuleContent(module, contentPrefix);
|
|
555
|
+
}
|
|
556
|
+
if (obj.filteredModules > 0) {
|
|
557
|
+
colors.normal(prefix);
|
|
558
|
+
colors.normal(" ");
|
|
559
|
+
if (obj.modules.length > 0)
|
|
560
|
+
colors.normal(" + ");
|
|
561
|
+
colors.normal(obj.filteredModules);
|
|
562
|
+
if (obj.modules.length > 0)
|
|
563
|
+
colors.normal(" hidden");
|
|
564
|
+
colors.normal(obj.filteredModules !== 1 ? " modules" : " module");
|
|
565
|
+
newline();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
if (obj.chunks) {
|
|
570
|
+
for (const chunk of obj.chunks) {
|
|
571
|
+
colors.normal("chunk ");
|
|
572
|
+
if (chunk.id < 1000)
|
|
573
|
+
colors.normal(" ");
|
|
574
|
+
if (chunk.id < 100)
|
|
575
|
+
colors.normal(" ");
|
|
576
|
+
if (chunk.id < 10)
|
|
577
|
+
colors.normal(" ");
|
|
578
|
+
colors.normal("{");
|
|
579
|
+
colors.yellow(chunk.id);
|
|
580
|
+
colors.normal("} ");
|
|
581
|
+
colors.green(chunk.files.join(", "));
|
|
582
|
+
if (chunk.names && chunk.names.length > 0) {
|
|
583
|
+
colors.normal(" (");
|
|
584
|
+
colors.normal(chunk.names.join(", "));
|
|
585
|
+
colors.normal(")");
|
|
586
|
+
}
|
|
587
|
+
colors.normal(" ");
|
|
588
|
+
colors.normal(SizeFormatHelpers.formatSize(chunk.size));
|
|
589
|
+
// TODO: stats chunk relation
|
|
590
|
+
// for (const id of chunk.parents) {
|
|
591
|
+
// colors.normal(" <{");
|
|
592
|
+
// colors.yellow(id);
|
|
593
|
+
// colors.normal("}>");
|
|
594
|
+
// }
|
|
595
|
+
// for (const id of chunk.siblings) {
|
|
596
|
+
// colors.normal(" ={");
|
|
597
|
+
// colors.yellow(id);
|
|
598
|
+
// colors.normal("}=");
|
|
599
|
+
// }
|
|
600
|
+
// for (const id of chunk.children) {
|
|
601
|
+
// colors.normal(" >{");
|
|
602
|
+
// colors.yellow(id);
|
|
603
|
+
// colors.normal("}<");
|
|
604
|
+
// }
|
|
605
|
+
if (chunk.childrenByOrder) {
|
|
606
|
+
for (const name of Object.keys(chunk.childrenByOrder)) {
|
|
607
|
+
const children = chunk.childrenByOrder[name];
|
|
608
|
+
colors.normal(" ");
|
|
609
|
+
colors.magenta(`(${name}:`);
|
|
610
|
+
for (const id of children) {
|
|
611
|
+
colors.normal(" {");
|
|
612
|
+
colors.yellow(id);
|
|
613
|
+
colors.normal("}");
|
|
614
|
+
}
|
|
615
|
+
colors.magenta(")");
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (chunk.entry) {
|
|
619
|
+
colors.yellow(" [entry]");
|
|
620
|
+
}
|
|
621
|
+
else if (chunk.initial) {
|
|
622
|
+
colors.yellow(" [initial]");
|
|
623
|
+
}
|
|
624
|
+
if (chunk.rendered) {
|
|
625
|
+
colors.green(" [rendered]");
|
|
626
|
+
}
|
|
627
|
+
if (chunk.recorded) {
|
|
628
|
+
colors.green(" [recorded]");
|
|
629
|
+
}
|
|
630
|
+
if (chunk.reason) {
|
|
631
|
+
colors.yellow(` ${chunk.reason}`);
|
|
632
|
+
}
|
|
633
|
+
newline();
|
|
634
|
+
if (chunk.origins) {
|
|
635
|
+
for (const origin of chunk.origins) {
|
|
636
|
+
colors.normal(" > ");
|
|
637
|
+
if (origin.reasons && origin.reasons.length) {
|
|
638
|
+
colors.yellow(origin.reasons.join(" "));
|
|
639
|
+
colors.normal(" ");
|
|
640
|
+
}
|
|
641
|
+
if (origin.request) {
|
|
642
|
+
colors.normal(origin.request);
|
|
643
|
+
colors.normal(" ");
|
|
644
|
+
}
|
|
645
|
+
if (origin.module) {
|
|
646
|
+
colors.normal("[");
|
|
647
|
+
colors.normal(origin.moduleId);
|
|
648
|
+
colors.normal("] ");
|
|
649
|
+
const module = modulesByIdentifier[`$${origin.module}`];
|
|
650
|
+
if (module) {
|
|
651
|
+
colors.bold(module.name);
|
|
652
|
+
colors.normal(" ");
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
if (origin.loc) {
|
|
656
|
+
colors.normal(origin.loc);
|
|
657
|
+
}
|
|
658
|
+
newline();
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
processModulesList(chunk, " ");
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
processModulesList(obj, "");
|
|
665
|
+
if (obj.logging) {
|
|
666
|
+
for (const origin of Object.keys(obj.logging)) {
|
|
667
|
+
const logData = obj.logging[origin];
|
|
668
|
+
if (logData.entries.length > 0) {
|
|
669
|
+
newline();
|
|
670
|
+
if (logData.debug) {
|
|
671
|
+
colors.red("DEBUG ");
|
|
672
|
+
}
|
|
673
|
+
colors.bold("LOG from " + origin);
|
|
674
|
+
newline();
|
|
675
|
+
let indent = "";
|
|
676
|
+
for (const entry of logData.entries) {
|
|
677
|
+
let color = colors.normal;
|
|
678
|
+
let prefix = " ";
|
|
679
|
+
switch (entry.type) {
|
|
680
|
+
case Logger_1.LogType.clear:
|
|
681
|
+
colors.normal(`${indent}-------`);
|
|
682
|
+
newline();
|
|
683
|
+
continue;
|
|
684
|
+
case Logger_1.LogType.error:
|
|
685
|
+
color = colors.red;
|
|
686
|
+
prefix = "<e> ";
|
|
687
|
+
break;
|
|
688
|
+
case Logger_1.LogType.warn:
|
|
689
|
+
color = colors.yellow;
|
|
690
|
+
prefix = "<w> ";
|
|
691
|
+
break;
|
|
692
|
+
case Logger_1.LogType.info:
|
|
693
|
+
color = colors.green;
|
|
694
|
+
prefix = "<i> ";
|
|
695
|
+
break;
|
|
696
|
+
case Logger_1.LogType.log:
|
|
697
|
+
color = colors.bold;
|
|
698
|
+
break;
|
|
699
|
+
case Logger_1.LogType.trace:
|
|
700
|
+
case Logger_1.LogType.debug:
|
|
701
|
+
color = colors.normal;
|
|
702
|
+
break;
|
|
703
|
+
case Logger_1.LogType.status:
|
|
704
|
+
color = colors.magenta;
|
|
705
|
+
prefix = "<s> ";
|
|
706
|
+
break;
|
|
707
|
+
case Logger_1.LogType.profile:
|
|
708
|
+
color = colors.magenta;
|
|
709
|
+
prefix = "<p> ";
|
|
710
|
+
break;
|
|
711
|
+
case Logger_1.LogType.profileEnd:
|
|
712
|
+
color = colors.magenta;
|
|
713
|
+
prefix = "</p> ";
|
|
714
|
+
break;
|
|
715
|
+
case Logger_1.LogType.time:
|
|
716
|
+
color = colors.magenta;
|
|
717
|
+
prefix = "<t> ";
|
|
718
|
+
break;
|
|
719
|
+
case Logger_1.LogType.group:
|
|
720
|
+
color = colors.cyan;
|
|
721
|
+
prefix = "<-> ";
|
|
722
|
+
break;
|
|
723
|
+
case Logger_1.LogType.groupCollapsed:
|
|
724
|
+
color = colors.cyan;
|
|
725
|
+
prefix = "<+> ";
|
|
726
|
+
break;
|
|
727
|
+
case Logger_1.LogType.groupEnd:
|
|
728
|
+
if (indent.length >= 2)
|
|
729
|
+
indent = indent.slice(0, indent.length - 2);
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
if (entry.message) {
|
|
733
|
+
for (const line of entry.message.split("\n")) {
|
|
734
|
+
colors.normal(`${indent}${prefix}`);
|
|
735
|
+
color(line);
|
|
736
|
+
newline();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (entry.trace) {
|
|
740
|
+
for (const line of entry.trace) {
|
|
741
|
+
colors.normal(`${indent}| ${line}`);
|
|
742
|
+
newline();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
switch (entry.type) {
|
|
746
|
+
case Logger_1.LogType.group:
|
|
747
|
+
indent += " ";
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (logData.filteredEntries) {
|
|
752
|
+
colors.normal(`+ ${logData.filteredEntries} hidden lines`);
|
|
753
|
+
newline();
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
if (obj.warnings) {
|
|
759
|
+
for (const warning of obj.warnings) {
|
|
760
|
+
newline();
|
|
761
|
+
// formatted warning already have color.
|
|
762
|
+
colors.normal(formatError(warning));
|
|
763
|
+
newline();
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (obj.errors) {
|
|
767
|
+
for (const error of obj.errors) {
|
|
768
|
+
newline();
|
|
769
|
+
// formatted error already have color.
|
|
770
|
+
colors.normal(formatError(error));
|
|
771
|
+
newline();
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (obj.children) {
|
|
775
|
+
for (const child of obj.children) {
|
|
776
|
+
const childString = Stats.jsonToString(child, useColors);
|
|
777
|
+
if (childString) {
|
|
778
|
+
if (child.name) {
|
|
779
|
+
colors.normal("Child ");
|
|
780
|
+
colors.bold(child.name);
|
|
781
|
+
colors.normal(":");
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
colors.normal("Child");
|
|
785
|
+
}
|
|
786
|
+
newline();
|
|
787
|
+
buf.push(" ");
|
|
788
|
+
buf.push(childString.replace(/\n/g, "\n "));
|
|
789
|
+
newline();
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
if (obj.needAdditionalPass) {
|
|
794
|
+
colors.yellow("Compilation needs an additional pass and will compile again.");
|
|
795
|
+
}
|
|
796
|
+
while (buf[buf.length - 1] === "\n") {
|
|
797
|
+
buf.pop();
|
|
798
|
+
}
|
|
799
|
+
return buf.join("");
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
exports.Stats = Stats;
|
|
803
|
+
_Stats_statsJson = new WeakMap();
|
|
804
|
+
const SizeFormatHelpers = {
|
|
805
|
+
formatSize: size => {
|
|
806
|
+
if (typeof size !== "number" || Number.isNaN(size) === true) {
|
|
807
|
+
return "unknown size";
|
|
808
|
+
}
|
|
809
|
+
if (size <= 0) {
|
|
810
|
+
return "0 bytes";
|
|
811
|
+
}
|
|
812
|
+
const abbreviations = ["bytes", "KiB", "MiB", "GiB"];
|
|
813
|
+
const index = Math.floor(Math.log(size) / Math.log(1024));
|
|
814
|
+
return `${+(size / Math.pow(1024, index)).toPrecision(3)} ${abbreviations[index]}`;
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
const formatError = (e) => {
|
|
818
|
+
return e.formatted;
|
|
819
|
+
};
|
|
820
|
+
const optionsOrFallback = (...args) => {
|
|
821
|
+
let optionValues = [];
|
|
822
|
+
optionValues.push(...args);
|
|
823
|
+
return optionValues.find(optionValue => optionValue !== undefined);
|
|
824
|
+
};
|
|
825
|
+
exports.optionsOrFallback = optionsOrFallback;
|
|
826
|
+
function normalizeStatsPreset(options) {
|
|
827
|
+
if (typeof options === "boolean" || typeof options === "string")
|
|
828
|
+
return presetToOptions(options);
|
|
829
|
+
else if (!options)
|
|
830
|
+
return {};
|
|
831
|
+
else {
|
|
832
|
+
let obj = { ...presetToOptions(options.preset), ...options };
|
|
833
|
+
delete obj.preset;
|
|
834
|
+
return obj;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
exports.normalizeStatsPreset = normalizeStatsPreset;
|
|
838
|
+
function presetToOptions(name) {
|
|
839
|
+
const pn = (typeof name === "string" && name.toLowerCase()) || name;
|
|
840
|
+
switch (pn) {
|
|
841
|
+
case "none":
|
|
842
|
+
return {
|
|
843
|
+
all: false
|
|
844
|
+
};
|
|
845
|
+
case "verbose":
|
|
846
|
+
return {
|
|
847
|
+
all: true
|
|
848
|
+
};
|
|
849
|
+
case "errors-only":
|
|
850
|
+
return {
|
|
851
|
+
all: false,
|
|
852
|
+
errors: true,
|
|
853
|
+
errorsCount: true
|
|
854
|
+
// TODO: moduleTrace: true,
|
|
855
|
+
// TODO: logging: "error"
|
|
856
|
+
};
|
|
857
|
+
case "errors-warnings":
|
|
858
|
+
return {
|
|
859
|
+
all: false,
|
|
860
|
+
errors: true,
|
|
861
|
+
errorsCount: true,
|
|
862
|
+
warnings: true,
|
|
863
|
+
warningsCount: true
|
|
864
|
+
// TODO: logging: "warn"
|
|
865
|
+
};
|
|
866
|
+
default:
|
|
867
|
+
return {};
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
//# sourceMappingURL=stats.js.map
|