@bymaksym/loadline 1.0.0 → 1.2.0
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/README.md +229 -43
- package/dist/cli/cli/args.js +79 -128
- package/dist/cli/cli/gates.js +80 -14
- package/dist/cli/cli/main.js +164 -33
- package/dist/cli/cli/memory.js +40 -4
- package/dist/cli/cli/{declared.js → read/declared.js} +1 -1
- package/dist/cli/cli/read/locate.js +214 -0
- package/dist/cli/cli/{read-build.js → read/read-build.js} +149 -84
- package/dist/cli/cli/read/read-config.js +120 -0
- package/dist/cli/cli/{html-report.js → render/html-report.js} +14 -10
- package/dist/cli/cli/render/render-agent.js +114 -0
- package/dist/cli/cli/render/render-asked.js +104 -0
- package/dist/cli/cli/render/render-badge.js +140 -0
- package/dist/cli/cli/{render-json.js → render/render-json.js} +18 -5
- package/dist/cli/cli/{render-markdown.js → render/render-markdown.js} +5 -5
- package/dist/cli/cli/{render-pr.js → render/render-pr.js} +33 -13
- package/dist/cli/cli/{render-sarif.js → render/render-sarif.js} +8 -3
- package/dist/cli/cli/{render-text.js → render/render-text.js} +118 -111
- package/dist/cli/cli/render/terminal.js +55 -0
- package/dist/cli/cli/report.js +68 -27
- package/dist/cli/cli/self-check.js +19 -23
- package/dist/cli/cli/since-last.js +2 -2
- package/dist/cli/cli/text/text-errors.js +124 -0
- package/dist/cli/cli/text/text.js +343 -0
- package/dist/cli/cli/text/usage.js +240 -0
- package/dist/cli/src/app/core/analysis/analysis.js +63 -23
- package/dist/cli/src/app/core/analysis/{barrels.js → graph/barrels.js} +1 -1
- package/dist/cli/src/app/core/analysis/{blast.js → graph/blast.js} +56 -17
- package/dist/cli/src/app/core/analysis/{cycles.js → graph/cycles.js} +1 -1
- package/dist/cli/src/app/core/analysis/{importers.js → graph/importers.js} +1 -1
- package/dist/cli/src/app/core/analysis/{insights.js → graph/insights.js} +10 -4
- package/dist/cli/src/app/core/analysis/invariant.js +1 -1
- package/dist/cli/src/app/core/analysis/metafile.types.js +7 -1
- package/dist/cli/src/app/core/analysis/{delivery.js → screens/delivery.js} +1 -1
- package/dist/cli/src/app/core/analysis/{entries.js → screens/entries.js} +50 -9
- package/dist/cli/src/app/core/analysis/screens/marks.js +32 -0
- package/dist/cli/src/app/core/analysis/screens/route-files.js +116 -0
- package/dist/cli/src/app/core/analysis/{sourcemap.js → sourcemap/sourcemap.js} +106 -7
- package/dist/cli/src/app/core/analysis/{split-drift.js → sourcemap/split-drift.js} +1 -1
- package/dist/cli/src/app/core/analysis/tool.js +83 -0
- package/dist/cli/src/app/core/assets/assets.js +134 -15
- package/dist/cli/src/app/core/baseline/baseline.js +0 -0
- package/dist/cli/src/app/core/{intake → build-text}/index-html.js +168 -13
- package/dist/cli/src/app/core/build-text/route-table.js +178 -0
- package/dist/cli/src/app/core/build-text/tool-marks.js +54 -0
- package/dist/cli/src/app/core/caching/caching.js +121 -43
- package/dist/cli/src/app/core/caching/from-analysis.js +20 -4
- package/dist/cli/src/app/core/config/config-text.js +90 -0
- package/dist/cli/src/app/core/config/config-values.js +358 -0
- package/dist/cli/src/app/core/config/loadline-config.js +81 -16
- package/dist/cli/src/app/core/config/merge-config.js +98 -0
- package/dist/cli/src/app/core/deps/deps.js +104 -16
- package/dist/cli/src/app/core/export/summary.js +29 -5
- package/dist/cli/src/app/core/findings/actions.js +3 -1
- package/dist/cli/src/app/core/findings/{boot-single.js → bundle/boot-single.js} +3 -3
- package/dist/cli/src/app/core/findings/{dupes.js → bundle/dupes.js} +8 -5
- package/dist/cli/src/app/core/findings/{graph.js → bundle/graph.js} +30 -18
- package/dist/cli/src/app/core/findings/{own-in-boot.js → bundle/own-in-boot.js} +9 -5
- package/dist/cli/src/app/core/findings/{requests.js → bundle/requests.js} +3 -3
- package/dist/cli/src/app/core/findings/{shipped.js → bundle/shipped.js} +28 -14
- package/dist/cli/src/app/core/findings/compose.js +6 -1
- package/dist/cli/src/app/core/findings/effort.js +2 -0
- package/dist/cli/src/app/core/findings/finding.types.js +1 -0
- package/dist/cli/src/app/core/findings/findings.js +48 -19
- package/dist/cli/src/app/core/findings/{assets.js → folder/assets.js} +38 -14
- package/dist/cli/src/app/core/findings/{caching.js → folder/caching.js} +16 -9
- package/dist/cli/src/app/core/findings/{page.js → folder/page.js} +6 -2
- package/dist/cli/src/app/core/findings/{scan.js → folder/scan.js} +25 -11
- package/dist/cli/src/app/core/findings/kind-names.js +163 -0
- package/dist/cli/src/app/core/findings/{deps.js → supplied/deps.js} +13 -8
- package/dist/cli/src/app/core/findings/supplied/forbidden.js +71 -0
- package/dist/cli/src/app/core/findings/{situation.js → supplied/situation.js} +2 -2
- package/dist/cli/src/app/core/findings/text/causes.js +39 -0
- package/dist/cli/src/app/core/findings/{finding-html.js → text/finding-html.js} +8 -1
- package/dist/cli/src/app/core/findings/{finding-text.js → text/finding-text.js} +208 -77
- package/dist/cli/src/app/core/findings/text/tool-advice.js +97 -0
- package/dist/cli/src/app/core/format/format.utils.js +158 -11
- package/dist/cli/src/app/core/format/ownership.js +93 -0
- package/dist/cli/src/app/core/i18n/en.js +76 -17
- package/dist/cli/src/app/core/i18n/es.js +82 -22
- package/dist/cli/src/app/core/intake/bundle-graph.js +281 -43
- package/dist/cli/src/app/core/intake/dist-files.js +82 -14
- package/dist/cli/src/app/core/intake/embedded.js +11 -1
- package/dist/cli/src/app/core/intake/unreached.js +139 -0
- package/dist/cli/src/app/core/intake/webpack-modules.js +185 -0
- package/dist/cli/src/app/core/intake/webpack-stats.js +298 -0
- package/dist/cli/src/app/core/project/project-context.js +16 -4
- package/dist/cli/src/app/core/project/project-name.js +36 -0
- package/dist/cli/src/app/core/scan/scan.js +58 -19
- package/dist/cli/src/app/core/scan/secrets.js +23 -3
- package/dist/cli/src/app/core/situation/situation-text.js +23 -0
- package/dist/cli/src/app/core/situation/situation.js +6 -4
- package/dist/cli/src/app/core/timing/timing.js +5 -2
- package/dist/cli/src/app/core/whatif/defer.js +29 -4
- package/dist/cli/src/app/core/whatif/source-importers.js +58 -0
- package/dist/cli/src/app/core/whatif/why.js +102 -0
- package/docs/CONFIG-REFERENCE.md +230 -0
- package/docs/CONFIG.md +511 -0
- package/docs/HOW-IT-WORKS.md +286 -25
- package/loadline.html +24 -20
- package/loadline.schema.json +1209 -0
- package/package.json +35 -29
- package/dist/cli/cli/locate.js +0 -60
- package/dist/cli/cli/text.js +0 -215
- /package/dist/cli/cli/{read-build.types.js → read/read-build.types.js} +0 -0
- /package/dist/cli/cli/{render-json.types.js → render/render-json.types.js} +0 -0
- /package/dist/cli/cli/{text.types.js → text/text.types.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{exclusive.js → graph/exclusive.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{insights.types.js → graph/insights.types.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{module-graph.js → graph/module-graph.js} +0 -0
- /package/dist/cli/src/app/core/analysis/{sourcemap.types.js → sourcemap/sourcemap.types.js} +0 -0
- /package/dist/cli/src/app/core/findings/{finding-plain.js → text/finding-plain.js} +0 -0
|
@@ -9,61 +9,23 @@
|
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.renderText = void 0;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const paletteOf = (color) => color
|
|
28
|
-
? { bold: code(1), dim: code(90), good: code(32), warn: code(33), bad: code(31) }
|
|
29
|
-
: { bold: plain, dim: plain, good: plain, warn: plain, bad: plain };
|
|
30
|
-
/** Length as the terminal shows it: padding a coloured string by its raw length breaks the column. */
|
|
31
|
-
const visible = (value) => value.replaceAll(ANSI, '').length;
|
|
32
|
-
const pad = (value, width, right) => {
|
|
33
|
-
const filler = ' '.repeat(Math.max(0, width - visible(value)));
|
|
34
|
-
return right ? `${filler}${value}` : `${value}${filler}`;
|
|
35
|
-
};
|
|
12
|
+
const tool_1 = require("../../src/app/core/analysis/tool");
|
|
13
|
+
const assets_1 = require("../../src/app/core/assets/assets");
|
|
14
|
+
const criteria_1 = require("../../src/app/core/criteria/criteria");
|
|
15
|
+
const actions_1 = require("../../src/app/core/findings/actions");
|
|
16
|
+
const finding_plain_1 = require("../../src/app/core/findings/text/finding-plain");
|
|
17
|
+
const format_utils_1 = require("../../src/app/core/format/format.utils");
|
|
18
|
+
const ui_1 = require("../../src/app/core/i18n/ui");
|
|
19
|
+
const budget_advice_1 = require("../../src/app/core/project/budget-advice");
|
|
20
|
+
const timing_1 = require("../../src/app/core/timing/timing");
|
|
21
|
+
const defer_1 = require("../../src/app/core/whatif/defer");
|
|
22
|
+
const gates_1 = require("../gates");
|
|
23
|
+
const since_last_1 = require("../since-last");
|
|
24
|
+
const text_1 = require("../text/text");
|
|
25
|
+
const render_asked_1 = require("./render-asked");
|
|
26
|
+
const terminal_1 = require("./terminal");
|
|
36
27
|
const verdictPaint = (palette, verdict) => verdict === 'good' ? palette.good : verdict === 'ok' ? palette.warn : palette.bad;
|
|
37
28
|
const severityPaint = (palette, severity) => severity === 'high' ? palette.bad : severity === 'mid' ? palette.warn : palette.dim;
|
|
38
|
-
/** Wraps at word boundaries. A signal is a sentence, and a sentence cut mid-word is harder to read. */
|
|
39
|
-
const wrap = (value, width) => {
|
|
40
|
-
const lines = [];
|
|
41
|
-
const words = value.split(/\s+/).filter(Boolean);
|
|
42
|
-
let current = '';
|
|
43
|
-
for (const word of words) {
|
|
44
|
-
if (current && current.length + word.length + 1 > width) {
|
|
45
|
-
lines.push(current);
|
|
46
|
-
current = word;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
current = current ? `${current} ${word}` : word;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (current) {
|
|
53
|
-
lines.push(current);
|
|
54
|
-
}
|
|
55
|
-
return lines;
|
|
56
|
-
};
|
|
57
|
-
/** A table sized to its own content: nothing truncated, nothing padded to a guess. */
|
|
58
|
-
const table = (columns, rows, palette) => {
|
|
59
|
-
const widths = columns.map((column, index) => Math.max(column.head.length, ...rows.map(row => visible(row[index] ?? ''))));
|
|
60
|
-
const line = (cells) => cells.map((value, index) => pad(value, widths[index] ?? 0, columns[index]?.right ?? false)).join(' ');
|
|
61
|
-
return [
|
|
62
|
-
palette.dim(line(columns.map(column => column.head))),
|
|
63
|
-
palette.dim(widths.map(width => '-'.repeat(width)).join(' ')),
|
|
64
|
-
...rows.map(row => line(row)),
|
|
65
|
-
];
|
|
66
|
-
};
|
|
67
29
|
/**
|
|
68
30
|
* What the first load costs in round trips, under the bootstrap figure. Empty without `--dist`:
|
|
69
31
|
* `index.html` is the only file that tells a preloaded chunk from one the browser has to discover
|
|
@@ -79,19 +41,72 @@ const startupLines = (report, palette) => {
|
|
|
79
41
|
late: startup.discovered.length,
|
|
80
42
|
chunks: report.analysis.bootFiles,
|
|
81
43
|
});
|
|
82
|
-
return
|
|
44
|
+
return (0, terminal_1.wrap)(note, terminal_1.WIDTH).map(line => palette.dim(line));
|
|
83
45
|
};
|
|
84
46
|
/**
|
|
85
47
|
* Everything the page asks for before anything appears, or — without a folder to read — just the
|
|
86
48
|
* stylesheets, which is as much of it as a page alone can say.
|
|
87
49
|
*/
|
|
50
|
+
/** The heaviest few of a list, by name and weight, and how many more there are. */
|
|
51
|
+
const fewOf = (entries) => {
|
|
52
|
+
const shown = entries.slice(0, 3).map(entry => `${entry.label} ${(0, format_utils_1.formatBytes)(entry.bytes)}`);
|
|
53
|
+
return entries.length > 3 ? `${shown.join(', ')}, +${entries.length - 3}` : shown.join(', ');
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* What loads lazily and has no row in the table above, under it — where HOW-IT-WORKS always said
|
|
57
|
+
* these lists were. Only the JSON carried them, so a build whose lazy parts are features rather
|
|
58
|
+
* than routes read as having five screens and nothing else.
|
|
59
|
+
*/
|
|
60
|
+
const notScreenLines = (report, palette) => {
|
|
61
|
+
const text = text_1.CLI_TEXT[report.lang];
|
|
62
|
+
const { analysis } = report;
|
|
63
|
+
const kinds = [
|
|
64
|
+
['blocks', analysis.deferredBlocks],
|
|
65
|
+
['groupers', analysis.routeGroupers],
|
|
66
|
+
['packages', analysis.lazyPackages],
|
|
67
|
+
['data', analysis.lazyData],
|
|
68
|
+
['workers', analysis.lazyWorkers],
|
|
69
|
+
['onDemand', analysis.lazyOnDemand],
|
|
70
|
+
];
|
|
71
|
+
const parts = kinds
|
|
72
|
+
.filter(([, entries]) => entries.length > 0)
|
|
73
|
+
.map(([kind, entries]) => text.notScreensPart[kind](entries.length, fewOf(entries)));
|
|
74
|
+
// Said only where it could have been found: a stats file carries no code to look in.
|
|
75
|
+
const untabled = analysis.routeTable === false && analysis.screens.length > 0 ? [text.noRouteTable] : [];
|
|
76
|
+
return [...(parts.length > 0 ? [text.notScreens(parts)] : []), ...untabled].flatMap(line => (0, terminal_1.wrap)(line, terminal_1.WIDTH).map(part => palette.dim(part)));
|
|
77
|
+
};
|
|
78
|
+
/** The stylesheets of the lazy routes, named under the table: see `routeStylesOf`. */
|
|
79
|
+
const routeCssLines = (report, palette) => {
|
|
80
|
+
const own = report.assets ? (0, assets_1.routeStylesOf)(report.assets) : [];
|
|
81
|
+
if (own.length === 0) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const list = own.length > 3 ? `${own.slice(0, 3).join(', ')}, +${own.length - 3}` : own.join(', ');
|
|
85
|
+
return (0, terminal_1.wrap)(text_1.CLI_TEXT[report.lang].routeCss(own.length, list), terminal_1.WIDTH).map(line => palette.dim(line));
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* A screen's name with the routes that open it, when they say something its name does not: `Home ·
|
|
89
|
+
* global-feed, my-feed +1`. The router's name for a page is what the team calls it.
|
|
90
|
+
*/
|
|
91
|
+
const withRoutes = (label, routes) => {
|
|
92
|
+
const other = routes.filter(route => route !== label);
|
|
93
|
+
if (other.length === 0) {
|
|
94
|
+
return label;
|
|
95
|
+
}
|
|
96
|
+
const shown = other.slice(0, 2).join(', ');
|
|
97
|
+
const cell = `${label} · ${other.length > 2 ? `${shown} +${other.length - 2}` : shown}`;
|
|
98
|
+
// The routes are a hint beside the name, not a column: a path that runs on is cut, never the table.
|
|
99
|
+
return cell.length > ROUTES_CELL ? `${cell.slice(0, ROUTES_CELL - 1)}…` : cell;
|
|
100
|
+
};
|
|
101
|
+
/** Widest a screen's name gets with its routes beside it. */
|
|
102
|
+
const ROUTES_CELL = 48;
|
|
88
103
|
const firstTripLines = (report, palette) => {
|
|
89
104
|
const text = text_1.CLI_TEXT[report.lang];
|
|
90
105
|
const trip = report.assets?.firstTrip;
|
|
91
106
|
if (trip && trip.total > 0) {
|
|
92
107
|
// The parts that are there: "0 B fonts" is a part of nothing.
|
|
93
108
|
const parts = [
|
|
94
|
-
[trip.scripts, 'JS'],
|
|
109
|
+
[trip.scripts, trip.inline > 0 ? `JS ${text.tripInline((0, format_utils_1.formatBytes)(trip.inline))}` : 'JS'],
|
|
95
110
|
[trip.styles, 'CSS'],
|
|
96
111
|
[trip.fonts, text.tripFonts],
|
|
97
112
|
[trip.images, text.tripImages],
|
|
@@ -99,14 +114,12 @@ const firstTripLines = (report, palette) => {
|
|
|
99
114
|
.filter(([bytes]) => bytes > 0)
|
|
100
115
|
.map(([bytes, label]) => `${(0, format_utils_1.formatBytes)(bytes)} ${label}`)
|
|
101
116
|
.join(' + ');
|
|
102
|
-
return
|
|
117
|
+
return (0, terminal_1.wrap)(text.firstTrip((0, format_utils_1.formatBytes)(trip.total), trip.files, parts), terminal_1.WIDTH).map(line => palette.warn(line));
|
|
103
118
|
}
|
|
104
119
|
if (report.pageCssBytes === null) {
|
|
105
120
|
return [];
|
|
106
121
|
}
|
|
107
|
-
return
|
|
108
|
-
palette.warn(text.pageCss((0, format_utils_1.formatBytes)(report.pageCssBytes), report.pageCssFiles, (0, format_utils_1.formatBytes)(report.analysis.bootBytes + report.pageCssBytes))),
|
|
109
|
-
];
|
|
122
|
+
return (0, terminal_1.wrap)(text.pageCss((0, format_utils_1.formatBytes)(report.pageCssBytes), report.pageCssFiles, (0, format_utils_1.formatBytes)(report.analysis.bootBytes + report.pageCssBytes)), terminal_1.WIDTH).map(line => palette.warn(line));
|
|
110
123
|
};
|
|
111
124
|
const screensTable = (report, palette) => {
|
|
112
125
|
const strings = ui_1.UI[report.lang];
|
|
@@ -131,7 +144,7 @@ const screensTable = (report, palette) => {
|
|
|
131
144
|
const rows = analysis.screens.map(screen => {
|
|
132
145
|
const verdict = (0, criteria_1.rate)(screen.total, criteria.screenOk, criteria.screenBad);
|
|
133
146
|
const cells = [
|
|
134
|
-
screen.label,
|
|
147
|
+
withRoutes(screen.label, screen.routes ?? []),
|
|
135
148
|
(0, format_utils_1.formatBytes)(screen.boot),
|
|
136
149
|
(0, format_utils_1.formatBytes)(screen.shared),
|
|
137
150
|
(0, format_utils_1.formatBytes)(screen.own),
|
|
@@ -144,13 +157,17 @@ const screensTable = (report, palette) => {
|
|
|
144
157
|
}
|
|
145
158
|
return cells;
|
|
146
159
|
});
|
|
147
|
-
return table(columns, rows, palette);
|
|
160
|
+
return (0, terminal_1.table)(columns, rows, palette);
|
|
148
161
|
};
|
|
149
|
-
const signalBlock = (finding, palette, fixLabel) => {
|
|
150
|
-
|
|
162
|
+
const signalBlock = (finding, palette, fixLabel, severity) => {
|
|
163
|
+
// The name `accepted` in loadline.json takes, in grey after the chip: living with a signal
|
|
164
|
+
// used to start with guessing its kind and key.
|
|
165
|
+
const key = finding.target?.key;
|
|
166
|
+
const name = palette.dim(`[${finding.kind}${key ? ` · ${key}` : ''}]`);
|
|
167
|
+
const head = `${severityPaint(palette, finding.severity)(`${severity[finding.severity].padEnd(5)} · ${(0, finding_plain_1.plainText)(finding.chip)}`)} ${name}`;
|
|
151
168
|
const indent = (line) => ` ${line}`;
|
|
152
|
-
const body = wrap((0, finding_plain_1.plainText)(finding.body), WIDTH - 6).map(element => indent(element));
|
|
153
|
-
const fix = finding.fix ? wrap(`${fixLabel}: ${(0, finding_plain_1.plainText)(finding.fix)}`, WIDTH - 6).map(l => indent(l)) : [];
|
|
169
|
+
const body = (0, terminal_1.wrap)((0, finding_plain_1.plainText)(finding.body), terminal_1.WIDTH - 6).map(element => indent(element));
|
|
170
|
+
const fix = finding.fix ? (0, terminal_1.wrap)(`${fixLabel}: ${(0, finding_plain_1.plainText)(finding.fix)}`, terminal_1.WIDTH - 6).map(l => indent(l)) : [];
|
|
154
171
|
return [
|
|
155
172
|
'',
|
|
156
173
|
` ${head}`,
|
|
@@ -184,20 +201,24 @@ const actionsBlock = (report, palette) => {
|
|
|
184
201
|
// Said only when there is a figure. "No signal here names a saving that can be measured" under
|
|
185
202
|
// a table whose saving column is all dashes repeated what the column had already said.
|
|
186
203
|
const words = (0, actions_1.savingWords)(report.analysis, total);
|
|
204
|
+
// A column of dashes over chunks nobody can see into is "not known", and without a line saying
|
|
205
|
+
// so it reads as "nothing here saves anything".
|
|
187
206
|
const summary = total.counted > 0 && total.bytes > 0
|
|
188
207
|
? text.totalSaving(words.saving, words.after, total.counted, words.estimated)
|
|
189
|
-
:
|
|
208
|
+
: (0, defer_1.blindBoot)(report.analysis)
|
|
209
|
+
? text.savingUnknown
|
|
210
|
+
: null;
|
|
190
211
|
return [
|
|
191
212
|
'',
|
|
192
213
|
palette.bold(text.headActions),
|
|
193
214
|
palette.dim(text.actionsNote),
|
|
194
|
-
...table([
|
|
215
|
+
...(0, terminal_1.table)([
|
|
195
216
|
{ head: '#', right: true },
|
|
196
217
|
{ head: text.colAction, right: false },
|
|
197
218
|
{ head: text.colSaving, right: true },
|
|
198
219
|
{ head: text.colEffort, right: false },
|
|
199
220
|
], rows, palette),
|
|
200
|
-
...(summary ? ['', ...wrap(summary, WIDTH).map(line => palette.dim(line))] : []),
|
|
221
|
+
...(summary ? ['', ...(0, terminal_1.wrap)(summary, terminal_1.WIDTH).map(line => palette.dim(line))] : []),
|
|
201
222
|
];
|
|
202
223
|
};
|
|
203
224
|
/**
|
|
@@ -224,8 +245,8 @@ const timeBlock = (report, palette) => {
|
|
|
224
245
|
return [
|
|
225
246
|
'',
|
|
226
247
|
palette.bold(text.headTime),
|
|
227
|
-
...wrap(text.timeNote, WIDTH).map(line => palette.dim(line)),
|
|
228
|
-
...table([
|
|
248
|
+
...(0, terminal_1.wrap)(text.timeNote, terminal_1.WIDTH).map(line => palette.dim(line)),
|
|
249
|
+
...(0, terminal_1.table)([
|
|
229
250
|
{ head: columns.profile, right: false },
|
|
230
251
|
{ head: columns.transfer, right: true },
|
|
231
252
|
{ head: columns.latency, right: true },
|
|
@@ -256,13 +277,13 @@ const budgetBlock = (report, palette) => {
|
|
|
256
277
|
return [
|
|
257
278
|
'',
|
|
258
279
|
palette.bold(text.headBudget),
|
|
259
|
-
...wrap(text.budgetNote(`${advice.warningKb}kB`, `${advice.errorKb}kB`, (0, format_utils_1.formatBytes)(advice.currentBytes)), WIDTH).map(line => palette.dim(line)),
|
|
280
|
+
...(0, terminal_1.wrap)(text.budgetNote(`${advice.warningKb}kB`, `${advice.errorKb}kB`, (0, format_utils_1.formatBytes)(advice.currentBytes)), terminal_1.WIDTH).map(line => palette.dim(line)),
|
|
260
281
|
'',
|
|
261
282
|
...advice.snippet.split('\n').map(line => ` ${line}`),
|
|
262
283
|
...(perScreen
|
|
263
284
|
? [
|
|
264
285
|
'',
|
|
265
|
-
...wrap(text.screenBudgetNote(`${perScreen.warningKb}kB`, largest?.name ?? '', (0, format_utils_1.formatBytes)(perScreen.currentBytes)), WIDTH).map(line => palette.dim(line)),
|
|
286
|
+
...(0, terminal_1.wrap)(text.screenBudgetNote(`${perScreen.warningKb}kB`, largest?.name ?? '', (0, format_utils_1.formatBytes)(perScreen.currentBytes)), terminal_1.WIDTH).map(line => palette.dim(line)),
|
|
266
287
|
...perScreen.snippet.split('\n').map(line => ` ${line}`),
|
|
267
288
|
]
|
|
268
289
|
: []),
|
|
@@ -293,40 +314,6 @@ const acceptedBlock = (report, palette) => {
|
|
|
293
314
|
});
|
|
294
315
|
return ['', palette.bold(text.headAccepted), ...lines];
|
|
295
316
|
};
|
|
296
|
-
/**
|
|
297
|
-
* "What would the first load weigh without this?", for each name asked about.
|
|
298
|
-
*
|
|
299
|
-
* The saving is exact — the graph walked without those files — and the note under it says what is
|
|
300
|
-
* deliberately not recomputed, because a simulated re-chunking would produce round trips that look
|
|
301
|
-
* exactly like the measured ones and are not.
|
|
302
|
-
*/
|
|
303
|
-
const whatIfBlock = (report, palette) => {
|
|
304
|
-
if (report.whatIf.length === 0) {
|
|
305
|
-
return [];
|
|
306
|
-
}
|
|
307
|
-
const text = text_1.CLI_TEXT[report.lang];
|
|
308
|
-
// In the report's unit, like the headline above it: see `unitScale`.
|
|
309
|
-
const scale = (0, actions_1.unitScale)(report.analysis);
|
|
310
|
-
const rows = report.whatIf.map(result => [
|
|
311
|
-
result.target,
|
|
312
|
-
(0, actions_1.formatSaving)(result.weight, scale),
|
|
313
|
-
palette.bold((0, actions_1.formatSaving)(result.saved, scale)),
|
|
314
|
-
(0, actions_1.formatRemaining)(report.analysis, result.saved, result.after),
|
|
315
|
-
result.screens.length > 0 ? result.screens.join(', ') : text.whatIfNobody,
|
|
316
|
-
]);
|
|
317
|
-
return [
|
|
318
|
-
'',
|
|
319
|
-
palette.bold(text.headWhatIf),
|
|
320
|
-
...wrap(scale.estimated ? `${text.whatIfNote} ${text.whatIfEstimated}` : text.whatIfNote, WIDTH).map(line => palette.dim(line)),
|
|
321
|
-
...table([
|
|
322
|
-
{ head: text.colWhatIf, right: false },
|
|
323
|
-
{ head: text.colSize, right: true },
|
|
324
|
-
{ head: text.colSaving, right: true },
|
|
325
|
-
{ head: text.colAfter, right: true },
|
|
326
|
-
{ head: text.colWhoPays, right: false },
|
|
327
|
-
], rows, palette),
|
|
328
|
-
];
|
|
329
|
-
};
|
|
330
317
|
const gateBlock = (violations, anyAsked, report, palette) => {
|
|
331
318
|
const text = text_1.CLI_TEXT[report.lang];
|
|
332
319
|
if (!anyAsked) {
|
|
@@ -348,13 +335,13 @@ const header = (report, palette) => {
|
|
|
348
335
|
const text = text_1.CLI_TEXT[report.lang];
|
|
349
336
|
const lines = [
|
|
350
337
|
palette.bold(report.projectName ? `Loadline · ${report.projectName}` : 'Loadline'),
|
|
351
|
-
palette.dim(text.lead(report.statsName, report.unit)),
|
|
338
|
+
palette.dim(text.lead(report.statsName, report.unit, (0, tool_1.toolLabel)(report.analysis.tool))),
|
|
352
339
|
];
|
|
353
340
|
if (report.comparison) {
|
|
354
341
|
lines.push(palette.dim(text.against(report.comparison.baselineName, report.comparison.baselineDate.slice(0, 10))));
|
|
355
342
|
}
|
|
356
343
|
if (report.comparisonBlocked) {
|
|
357
|
-
lines.push(palette.warn(text.blocked));
|
|
344
|
+
lines.push(palette.warn(text.blocked(report.baselineMode ?? 'raw', report.mode)));
|
|
358
345
|
}
|
|
359
346
|
if (report.located.length > 0) {
|
|
360
347
|
lines.push(palette.dim(text.located(report.located.join(' + '))));
|
|
@@ -366,6 +353,18 @@ const header = (report, palette) => {
|
|
|
366
353
|
if (report.analysis.splitSource === 'sourcemap') {
|
|
367
354
|
lines.push(palette.dim(text.exactSplit));
|
|
368
355
|
}
|
|
356
|
+
// In the lead and in warning colour: it changes how every figure below is read, and the signal
|
|
357
|
+
// that explains it is several cards down, where it was the only place it was said.
|
|
358
|
+
const unseen = (0, defer_1.opaqueBootChunks)(report.analysis);
|
|
359
|
+
if ((0, defer_1.blindBoot)(report.analysis)) {
|
|
360
|
+
lines.push(...(0, terminal_1.wrap)(text.opaque, terminal_1.WIDTH).map(line => palette.warn(line)));
|
|
361
|
+
}
|
|
362
|
+
else if (unseen.length > 0) {
|
|
363
|
+
// One chunk without its map in a folder that has them: named, with its weight, so it is
|
|
364
|
+
// read as the corner it is and not as the whole report going blind.
|
|
365
|
+
const named = unseen.map(chunk => `${(0, format_utils_1.baseName)(chunk)} (${(0, format_utils_1.formatBytes)(report.analysis.chunkOf(chunk)?.bytes ?? 0)})`);
|
|
366
|
+
lines.push(...(0, terminal_1.wrap)(text.opaqueSome(named.join(', '), unseen.length), terminal_1.WIDTH).map(line => palette.dim(line)));
|
|
367
|
+
}
|
|
369
368
|
// Which file the thresholds came from. A run judged by a committed file and one judged by the
|
|
370
369
|
// recommended values are different runs, and the log should not leave that to be guessed.
|
|
371
370
|
if (report.configName) {
|
|
@@ -381,10 +380,15 @@ const header = (report, palette) => {
|
|
|
381
380
|
if (report.analysis.componentStyles > 0) {
|
|
382
381
|
lines.push(palette.dim(text.componentStyles(report.analysis.componentStyles)));
|
|
383
382
|
}
|
|
383
|
+
// A folder holds files the page never downloads as part of a screen, and the reader found them.
|
|
384
|
+
const { offPage } = report.analysis;
|
|
385
|
+
if (offPage.legacy + offPage.serviceWorker + offPage.server + offPage.ignored > 0) {
|
|
386
|
+
lines.push(palette.dim(text.offPageLeftOut(offPage)));
|
|
387
|
+
}
|
|
384
388
|
return lines;
|
|
385
389
|
};
|
|
386
390
|
const renderText = (report, violations, anyAsked, color) => {
|
|
387
|
-
const palette = paletteOf(color);
|
|
391
|
+
const palette = (0, terminal_1.paletteOf)(color);
|
|
388
392
|
const text = text_1.CLI_TEXT[report.lang];
|
|
389
393
|
const strings = ui_1.UI[report.lang];
|
|
390
394
|
const { analysis, criteria } = report;
|
|
@@ -407,14 +411,17 @@ const renderText = (report, violations, anyAsked, color) => {
|
|
|
407
411
|
'',
|
|
408
412
|
palette.bold(text.headScreens),
|
|
409
413
|
...(analysis.screens.length > 0 ? screensTable(report, palette) : [palette.dim(text.noScreens)]),
|
|
414
|
+
...notScreenLines(report, palette),
|
|
415
|
+
...routeCssLines(report, palette),
|
|
410
416
|
'',
|
|
411
417
|
...actionsBlock(report, palette),
|
|
412
418
|
...timeBlock(report, palette),
|
|
413
419
|
...budgetBlock(report, palette),
|
|
414
420
|
'',
|
|
415
421
|
palette.bold(text.headSignals),
|
|
416
|
-
...report.findings.flatMap(finding => signalBlock(finding, palette, text.fix)),
|
|
417
|
-
...whatIfBlock(report, palette),
|
|
422
|
+
...report.findings.flatMap(finding => signalBlock(finding, palette, text.fix, text.severity)),
|
|
423
|
+
...(0, render_asked_1.whatIfBlock)(report, palette),
|
|
424
|
+
...(0, render_asked_1.whyBlock)(report, palette),
|
|
418
425
|
...acceptedBlock(report, palette),
|
|
419
426
|
...gateBlock(violations, anyAsked, report, palette),
|
|
420
427
|
'',
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What every block of the terminal report is drawn with: the width, the colours, wrapping and
|
|
4
|
+
* tables. Apart from the blocks so that more than one file can draw one.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.table = exports.wrap = exports.pad = exports.visible = exports.paletteOf = exports.WIDTH = void 0;
|
|
8
|
+
exports.WIDTH = 96;
|
|
9
|
+
const ESC = String.fromCodePoint(27);
|
|
10
|
+
const ANSI = new RegExp(String.raw `${ESC}\[\d+m`, 'g');
|
|
11
|
+
const code = (open) => value => `${ESC}[${open}m${value}${ESC}[0m`;
|
|
12
|
+
const plain = value => value;
|
|
13
|
+
const paletteOf = (color) => color
|
|
14
|
+
? { bold: code(1), dim: code(90), good: code(32), warn: code(33), bad: code(31) }
|
|
15
|
+
: { bold: plain, dim: plain, good: plain, warn: plain, bad: plain };
|
|
16
|
+
exports.paletteOf = paletteOf;
|
|
17
|
+
/** Length as the terminal shows it: padding a coloured string by its raw length breaks the column. */
|
|
18
|
+
const visible = (value) => value.replaceAll(ANSI, '').length;
|
|
19
|
+
exports.visible = visible;
|
|
20
|
+
const pad = (value, width, right) => {
|
|
21
|
+
const filler = ' '.repeat(Math.max(0, width - (0, exports.visible)(value)));
|
|
22
|
+
return right ? `${filler}${value}` : `${value}${filler}`;
|
|
23
|
+
};
|
|
24
|
+
exports.pad = pad;
|
|
25
|
+
/** Wraps at word boundaries. A signal is a sentence, and a sentence cut mid-word is harder to read. */
|
|
26
|
+
const wrap = (value, width) => {
|
|
27
|
+
const lines = [];
|
|
28
|
+
const words = value.split(/\s+/).filter(Boolean);
|
|
29
|
+
let current = '';
|
|
30
|
+
for (const word of words) {
|
|
31
|
+
if (current && current.length + word.length + 1 > width) {
|
|
32
|
+
lines.push(current);
|
|
33
|
+
current = word;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
current = current ? `${current} ${word}` : word;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (current) {
|
|
40
|
+
lines.push(current);
|
|
41
|
+
}
|
|
42
|
+
return lines;
|
|
43
|
+
};
|
|
44
|
+
exports.wrap = wrap;
|
|
45
|
+
/** A table sized to its own content: nothing truncated, nothing padded to a guess. */
|
|
46
|
+
const table = (columns, rows, palette) => {
|
|
47
|
+
const widths = columns.map((column, index) => Math.max(column.head.length, ...rows.map(row => (0, exports.visible)(row[index] ?? ''))));
|
|
48
|
+
const line = (cells) => cells.map((value, index) => (0, exports.pad)(value, widths[index] ?? 0, columns[index]?.right ?? false)).join(' ');
|
|
49
|
+
return [
|
|
50
|
+
palette.dim(line(columns.map(column => column.head))),
|
|
51
|
+
palette.dim(widths.map(width => '-'.repeat(width)).join(' ')),
|
|
52
|
+
...rows.map(row => line(row)),
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
exports.table = table;
|
package/dist/cli/cli/report.js
CHANGED
|
@@ -7,43 +7,58 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.buildReport = void 0;
|
|
9
9
|
const analysis_1 = require("../src/app/core/analysis/analysis");
|
|
10
|
-
const
|
|
10
|
+
const marks_1 = require("../src/app/core/analysis/screens/marks");
|
|
11
|
+
const sourcemap_1 = require("../src/app/core/analysis/sourcemap/sourcemap");
|
|
12
|
+
const assets_1 = require("../src/app/core/assets/assets");
|
|
11
13
|
const baseline_1 = require("../src/app/core/baseline/baseline");
|
|
12
14
|
const from_analysis_1 = require("../src/app/core/caching/from-analysis");
|
|
13
15
|
const loadline_config_1 = require("../src/app/core/config/loadline-config");
|
|
14
16
|
const criteria_1 = require("../src/app/core/criteria/criteria");
|
|
15
17
|
const deps_1 = require("../src/app/core/deps/deps");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
+
const actions_1 = require("../src/app/core/findings/actions");
|
|
19
|
+
const shipped_1 = require("../src/app/core/findings/bundle/shipped");
|
|
18
20
|
const compose_1 = require("../src/app/core/findings/compose");
|
|
19
|
-
const deps_2 = require("../src/app/core/findings/deps");
|
|
20
21
|
const findings_1 = require("../src/app/core/findings/findings");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
22
|
+
const assets_2 = require("../src/app/core/findings/folder/assets");
|
|
23
|
+
const caching_1 = require("../src/app/core/findings/folder/caching");
|
|
24
|
+
const page_1 = require("../src/app/core/findings/folder/page");
|
|
25
|
+
const scan_1 = require("../src/app/core/findings/folder/scan");
|
|
26
|
+
const deps_2 = require("../src/app/core/findings/supplied/deps");
|
|
27
|
+
const forbidden_1 = require("../src/app/core/findings/supplied/forbidden");
|
|
28
|
+
const situation_1 = require("../src/app/core/findings/supplied/situation");
|
|
25
29
|
const format_utils_1 = require("../src/app/core/format/format.utils");
|
|
26
30
|
const ui_1 = require("../src/app/core/i18n/ui");
|
|
31
|
+
const project_name_1 = require("../src/app/core/project/project-name");
|
|
27
32
|
const scan_2 = require("../src/app/core/scan/scan");
|
|
28
33
|
const situation_2 = require("../src/app/core/situation/situation");
|
|
29
34
|
const defer_1 = require("../src/app/core/whatif/defer");
|
|
30
|
-
const
|
|
35
|
+
const source_importers_1 = require("../src/app/core/whatif/source-importers");
|
|
36
|
+
const why_1 = require("../src/app/core/whatif/why");
|
|
37
|
+
const read_build_1 = require("./read/read-build");
|
|
31
38
|
/**
|
|
32
39
|
* Which figure the report is in. Brotli when the folder brought the `.br` files, gzip when it
|
|
33
40
|
* brought the assets, raw otherwise. Asking for a unit the folder cannot give is an error rather
|
|
34
41
|
* than a silent downgrade: a gate written for gzip and checked against raw bytes passes for a
|
|
35
42
|
* reason that has nothing to do with the build.
|
|
36
43
|
*/
|
|
37
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The unit of the report: `--mode`, then the `mode` of `loadline.json`, then the best the folder
|
|
46
|
+
* allows. The file's is not a label: its thresholds are written in it, and read in another unit a
|
|
47
|
+
* `maxBoot` of 100 kB written in raw bytes passed a build of 110 kB raw because it was shown 43 kB
|
|
48
|
+
* of gzip.
|
|
49
|
+
*/
|
|
50
|
+
const resolveMode = (input, typed) => {
|
|
38
51
|
const best = input.brotli ? 'brotli' : input.gzip ? 'gzip' : 'raw';
|
|
52
|
+
const asked = typed ?? input.config?.mode ?? null;
|
|
39
53
|
if (!asked) {
|
|
40
54
|
return best;
|
|
41
55
|
}
|
|
56
|
+
const by = (t) => (typed ? `--mode ${asked}` : t.modeInConfig(asked));
|
|
42
57
|
if (asked === 'brotli' && !input.brotli) {
|
|
43
|
-
throw new read_build_1.InputError(
|
|
58
|
+
throw new read_build_1.InputError(t => t.needsBrotli(by(t)));
|
|
44
59
|
}
|
|
45
60
|
if (asked === 'gzip' && !input.gzip) {
|
|
46
|
-
throw new read_build_1.InputError(
|
|
61
|
+
throw new read_build_1.InputError(t => t.needsDist(by(t)));
|
|
47
62
|
}
|
|
48
63
|
return asked;
|
|
49
64
|
};
|
|
@@ -52,9 +67,8 @@ const resolveMode = (input, asked) => {
|
|
|
52
67
|
*
|
|
53
68
|
* That order is the one people expect and the one that makes the file useful: the committed file
|
|
54
69
|
* is what the team agreed to, and a flag typed on a command line is somebody overriding it for one
|
|
55
|
-
* run on purpose. The file's own `mode` is
|
|
56
|
-
*
|
|
57
|
-
* for that shape of mistake elsewhere; here it would only be a second place to look.
|
|
70
|
+
* run on purpose. The file's own `mode` is the report's unit unless `--mode` says otherwise (see
|
|
71
|
+
* `resolveMode`), so the thresholds in it are read in the unit they were written in.
|
|
58
72
|
*/
|
|
59
73
|
const resolveCriteria = (mode, config, overrides) => ({
|
|
60
74
|
...criteria_1.RECOMMENDED[mode],
|
|
@@ -88,10 +102,14 @@ const buildReport = (input, options) => {
|
|
|
88
102
|
const criteria = resolveCriteria(mode, input.config, input.criteria);
|
|
89
103
|
// The language only decides the decimal separator, and it is set before anything is formatted.
|
|
90
104
|
(0, format_utils_1.setNumberLang)(lang);
|
|
91
|
-
|
|
105
|
+
// What `build.screens` of `loadline.json` says is a screen or a piece of one: the page's buttons, written down.
|
|
106
|
+
const marks = (0, marks_1.configuredMarks)(input.config?.build?.screens, input.meta);
|
|
107
|
+
const analysis = (0, analysis_1.analyze)(input.meta, sizes, exact, input.announced, marks, criteria, input.parallel, input.routes);
|
|
92
108
|
// The same build in raw bytes, for comparing against a raw baseline while showing compressed
|
|
93
109
|
// figures. It is the shown analysis itself when nothing is compressed, so it costs nothing then.
|
|
94
|
-
const raw = sizes
|
|
110
|
+
const raw = sizes
|
|
111
|
+
? (0, analysis_1.analyze)(input.meta, null, exact, input.announced, marks, criteria, input.parallel, input.routes)
|
|
112
|
+
: analysis;
|
|
95
113
|
// What the team answered about itself, out of the committed file. Unlike a measurement, this
|
|
96
114
|
// half of the context does reach the terminal: it is the same for everybody who runs the
|
|
97
115
|
// command, which is exactly why it lives in `loadline.json` rather than in a browser.
|
|
@@ -106,7 +124,7 @@ const buildReport = (input, options) => {
|
|
|
106
124
|
const cssBytes = pageCss ? (mode === 'brotli' ? (pageCss.brotli ?? pageCss.gzip) : pageCss[mode]) : null;
|
|
107
125
|
// What an update costs. It needs the baseline's file names, which only a snapshot carrying them
|
|
108
126
|
// has; without one the delta is absent and the other two caching figures still come out.
|
|
109
|
-
const caching = (0, from_analysis_1.cachingOf)(analysis, input.baseline, input.assets ?? null, new Set(input.announced), input.hrefs);
|
|
127
|
+
const caching = (0, from_analysis_1.cachingOf)(analysis, input.baseline, input.assets ?? null, new Set(input.announced), input.hrefs, sizes);
|
|
110
128
|
// What the text of the build says, and what the two dependency files say about what ships. Both
|
|
111
129
|
// are empty rather than absent when nothing was given: `null` inside them says which.
|
|
112
130
|
const scan = (input.texts?.size ?? 0) > 0
|
|
@@ -122,7 +140,7 @@ const buildReport = (input, options) => {
|
|
|
122
140
|
advisories: input.advisories ?? null,
|
|
123
141
|
modules: analysis.modules,
|
|
124
142
|
boot: new Set(analysis.bootChunks),
|
|
125
|
-
direct: new Set(input.context.pkg?.dependencies),
|
|
143
|
+
direct: new Set(input.context.pkg?.dependencies ?? input.lockDirect),
|
|
126
144
|
});
|
|
127
145
|
// The signals of this build alone, built once. They are what the comparison needs to say which
|
|
128
146
|
// of them are new, what the snapshot carries so the *next* run can ask the same question, and
|
|
@@ -131,22 +149,34 @@ const buildReport = (input, options) => {
|
|
|
131
149
|
// somebody had actually fixed could never show as gone, and a page export — which does carry
|
|
132
150
|
// them — read as three signals fixed the moment the terminal compared against it.
|
|
133
151
|
const base = (0, findings_1.buildFindings)(analysis, lang, mode, criteria, situation, input.declared ?? null);
|
|
134
|
-
|
|
152
|
+
// What `loadline.json` forbids goes with the project's own files: it is the team's rule, read
|
|
153
|
+
// from the repository, like a budget in `angular.json`.
|
|
154
|
+
const fromContext = [
|
|
155
|
+
...(0, findings_1.buildContextFindings)(input.context, analysis, lang, criteria),
|
|
156
|
+
...(0, forbidden_1.buildForbiddenFindings)(analysis, input.config?.forbidden, lang),
|
|
157
|
+
];
|
|
135
158
|
const fromBuild = [
|
|
136
159
|
...(0, shipped_1.buildFolderFindings)({
|
|
137
160
|
sourceMaps: input.splits?.size ?? 0,
|
|
138
161
|
derived: !!input.graph,
|
|
139
162
|
screens: analysis.screens.map(s => s.label),
|
|
140
163
|
drift: analysis.splitDrift,
|
|
164
|
+
tool: analysis.tool,
|
|
141
165
|
}, lang),
|
|
142
|
-
...(input.assets ? (0,
|
|
166
|
+
...(input.assets ? (0, assets_2.buildAssetFindings)(input.assets, lang, criteria, input.assetSources ?? null, true) : []),
|
|
143
167
|
...(0, page_1.buildPageFindings)(input.pageOrigins ?? null, lang),
|
|
144
|
-
...(0, caching_1.buildCachingFindings)(caching, lang, criteria, situation),
|
|
145
|
-
...(scan ? (0, scan_1.buildScanFindings)(scan, lang, criteria) : []),
|
|
146
|
-
...(0, deps_2.buildDepsFindings)(deps, lang, criteria),
|
|
168
|
+
...(0, caching_1.buildCachingFindings)(caching, lang, criteria, situation, analysis.tool),
|
|
169
|
+
...(scan ? (0, scan_1.buildScanFindings)(scan, lang, criteria, (0, actions_1.unitScale)(analysis), analysis.tool) : []),
|
|
170
|
+
...(0, deps_2.buildDepsFindings)(deps, lang, criteria, (0, actions_1.unitScale)(analysis)),
|
|
147
171
|
];
|
|
148
172
|
const own = [...base, ...fromContext, ...fromBuild];
|
|
149
173
|
const { comparison, blocked } = comparisonOf(input, analysis, raw, mode, own);
|
|
174
|
+
// The bootstrap chunks the page does not name are part of the first trip too, weighed with the
|
|
175
|
+
// same figures the folder weighed the rest of it with.
|
|
176
|
+
// In the unit of the report, which `--mode` may have made something other than the best one.
|
|
177
|
+
const lateBoot = (analysis.startup?.discovered ?? []).map(chunk => sizes?.get((0, format_utils_1.baseName)(chunk)) ?? input.meta.outputs[chunk]?.bytes ?? 0);
|
|
178
|
+
const trip = input.firstTrips?.[mode] ?? input.assets?.firstTrip;
|
|
179
|
+
const assets = input.assets && trip ? { ...input.assets, firstTrip: (0, assets_1.withLateBoot)(trip, lateBoot) } : null;
|
|
150
180
|
// This build as the next run's baseline. Written whether or not `--export` was asked for: it
|
|
151
181
|
// costs a walk over lists that are already in memory, and having it here is what keeps the
|
|
152
182
|
// exported file and the compared-against file the same shape by construction.
|
|
@@ -177,12 +207,21 @@ const buildReport = (input, options) => {
|
|
|
177
207
|
pageCssBytes: cssBytes,
|
|
178
208
|
pageCssRawBytes: pageCss?.raw ?? null,
|
|
179
209
|
pageCssFiles: pageCss?.files.length ?? 0,
|
|
180
|
-
assets
|
|
210
|
+
assets,
|
|
181
211
|
caching,
|
|
182
212
|
scan,
|
|
183
213
|
deps,
|
|
184
|
-
|
|
185
|
-
|
|
214
|
+
// A folder read alone carries no file-to-file imports: see `DeferResult.measurable`.
|
|
215
|
+
whatIf: options.whatIf.map(name => (0, defer_1.simulateDefer)(analysis, name, !input.graph)),
|
|
216
|
+
// A folder build says which chunk holds what and not who imports whom; the sources in its
|
|
217
|
+
// maps do, which is what lets `--why` answer for a Vite or Nuxt build at all.
|
|
218
|
+
why: options.why.map(name => (0, why_1.explainWhy)(analysis, name, !input.graph, input.graph ? pkg => (0, source_importers_1.importersInSources)(input.maps ?? [], pkg) : null)),
|
|
219
|
+
projectName: (0, project_name_1.projectNameOf)({
|
|
220
|
+
packageName: input.context.pkg?.name ?? input.packageName,
|
|
221
|
+
angularProject: input.context.angular?.project,
|
|
222
|
+
pageTitle: input.pageTitle,
|
|
223
|
+
folder: input.statsName,
|
|
224
|
+
}),
|
|
186
225
|
mode,
|
|
187
226
|
unit: units[mode],
|
|
188
227
|
lang,
|
|
@@ -190,7 +229,9 @@ const buildReport = (input, options) => {
|
|
|
190
229
|
analysis,
|
|
191
230
|
comparison,
|
|
192
231
|
comparisonBlocked: blocked,
|
|
232
|
+
baselineMode: input.baseline?.mode ?? null,
|
|
193
233
|
sinceLast,
|
|
234
|
+
sinceLastBranch: sinceLast ? (input.lastRunBranch ?? null) : null,
|
|
194
235
|
located: [],
|
|
195
236
|
findings: kept,
|
|
196
237
|
accepted,
|