@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
|
@@ -35,6 +35,15 @@ const nameFromPath = (path) => {
|
|
|
35
35
|
const parts = rest.split('/');
|
|
36
36
|
return (parts[0]?.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]) ?? null;
|
|
37
37
|
};
|
|
38
|
+
/** One line of a JSON-lines file, or `null` for one that is not JSON. */
|
|
39
|
+
const safeJson = (line) => {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(line);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
38
47
|
/** The `version` of one lock entry, when the entry is an object carrying one. */
|
|
39
48
|
const versionOf = (entry) => (0, json_utils_1.asText)((0, json_utils_1.asRecord)(entry)?.['version']);
|
|
40
49
|
const readNpmLock = (lock) => {
|
|
@@ -136,7 +145,8 @@ exports.readLock = readLock;
|
|
|
136
145
|
* Nothing here checks a version range against a version: an advisory is attributed to a package by
|
|
137
146
|
* name, and the range is printed so whoever reads it can judge. Matching ranges properly needs a
|
|
138
147
|
* semver implementation, and being approximately right about whether somebody is vulnerable is
|
|
139
|
-
* worse than being explicit about what is and is not known.
|
|
148
|
+
* worse than being explicit about what is and is not known. The one exact comparison made is
|
|
149
|
+
* between installed versions, when the report names them: see `affectsShipped`.
|
|
140
150
|
*/
|
|
141
151
|
const readAudit = (text) => {
|
|
142
152
|
let parsed;
|
|
@@ -144,7 +154,24 @@ const readAudit = (text) => {
|
|
|
144
154
|
parsed = JSON.parse(text);
|
|
145
155
|
}
|
|
146
156
|
catch {
|
|
147
|
-
|
|
157
|
+
// `yarn audit --json` writes one object per line. The advisories in it are npm 6's, so they
|
|
158
|
+
// are gathered into npm 6's shape and read like one; yarn repeats an advisory once per path
|
|
159
|
+
// it is reached by, and the id keeps one of each.
|
|
160
|
+
const advisories = {};
|
|
161
|
+
for (const line of text.split('\n')) {
|
|
162
|
+
const entry = (0, json_utils_1.asRecord)(safeJson(line));
|
|
163
|
+
const advisory = entry?.['type'] === 'auditAdvisory' ? (0, json_utils_1.asRecord)((0, json_utils_1.asRecord)(entry['data'])?.['advisory']) : null;
|
|
164
|
+
if (!advisory) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const id = advisory['id'];
|
|
168
|
+
const key = typeof id === 'number' || typeof id === 'string' ? String(id) : `#${Object.keys(advisories).length}`;
|
|
169
|
+
advisories[key] = advisory;
|
|
170
|
+
}
|
|
171
|
+
if (Object.keys(advisories).length === 0 && !text.includes('"auditSummary"')) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
parsed = { advisories };
|
|
148
175
|
}
|
|
149
176
|
// An audit report is an object. `null`, a list and a bare number are all valid JSON, and the
|
|
150
177
|
// shape this used to assert made reading a property off any of them a crash rather than a
|
|
@@ -169,7 +196,7 @@ const readAudit = (text) => {
|
|
|
169
196
|
severity: severityOf(entry['severity']),
|
|
170
197
|
title: (0, json_utils_1.asText)(detail?.['title']) ?? name,
|
|
171
198
|
url: (0, json_utils_1.asText)(detail?.['url']),
|
|
172
|
-
range: (0, json_utils_1.asText)(detail?.['range']),
|
|
199
|
+
range: (0, json_utils_1.asText)(detail?.['range']) ?? (0, json_utils_1.asText)(entry['range']),
|
|
173
200
|
// npm's `fixAvailable` is either `false` or an object naming a package and a version
|
|
174
201
|
// to move to — which is not the same as "this advisory is fixed in X". Rather than
|
|
175
202
|
// reword it into something it does not say, it is left out.
|
|
@@ -182,16 +209,23 @@ const readAudit = (text) => {
|
|
|
182
209
|
for (const value of listed) {
|
|
183
210
|
const entry = (0, json_utils_1.asRecord)(value);
|
|
184
211
|
const module = (0, json_utils_1.asText)(entry?.['module_name']);
|
|
185
|
-
if (entry
|
|
186
|
-
|
|
187
|
-
package: module,
|
|
188
|
-
severity: severityOf(entry['severity']),
|
|
189
|
-
title: (0, json_utils_1.asText)(entry['title']) ?? module,
|
|
190
|
-
url: (0, json_utils_1.asText)(entry['url']),
|
|
191
|
-
range: null,
|
|
192
|
-
fixedIn: null,
|
|
193
|
-
});
|
|
212
|
+
if (!entry || !module) {
|
|
213
|
+
continue;
|
|
194
214
|
}
|
|
215
|
+
// pnpm writes this shape too, with what npm 6 left out: the range, what fixes it, and the
|
|
216
|
+
// versions actually installed. Read as `null`, the report printed no range at all.
|
|
217
|
+
const versions = ((0, json_utils_1.asArray)(entry['findings']) ?? [])
|
|
218
|
+
.map(finding => (0, json_utils_1.asText)((0, json_utils_1.asRecord)(finding)?.['version']))
|
|
219
|
+
.filter(version => version !== null);
|
|
220
|
+
found.push({
|
|
221
|
+
package: module,
|
|
222
|
+
severity: severityOf(entry['severity']),
|
|
223
|
+
title: (0, json_utils_1.asText)(entry['title']) ?? module,
|
|
224
|
+
url: (0, json_utils_1.asText)(entry['url']),
|
|
225
|
+
range: (0, json_utils_1.asText)(entry['vulnerable_versions']),
|
|
226
|
+
fixedIn: (0, json_utils_1.asText)(entry['patched_versions']),
|
|
227
|
+
...(versions.length > 0 && { versions }),
|
|
228
|
+
});
|
|
195
229
|
}
|
|
196
230
|
// Neither key present means this JSON was not an audit report at all, which is not the same
|
|
197
231
|
// answer as an audit report with nothing in it.
|
|
@@ -199,12 +233,30 @@ const readAudit = (text) => {
|
|
|
199
233
|
};
|
|
200
234
|
exports.readAudit = readAudit;
|
|
201
235
|
const RANK = { critical: 0, high: 1, moderate: 2, low: 3, info: 4 };
|
|
236
|
+
/**
|
|
237
|
+
* The version of `pkg` a module path names, when pnpm laid it out: `.pnpm/devalue@6.0.2/…`.
|
|
238
|
+
* `null` in every other layout, and when the segment is some other package's.
|
|
239
|
+
*/
|
|
240
|
+
const PNPM_SEGMENT = /\.pnpm\/((?:@[^/+]+\+)?[^@/]+)@([^/_]+)/;
|
|
241
|
+
const shippedVersionOf = (path, pkg) => {
|
|
242
|
+
const match = PNPM_SEGMENT.exec(path);
|
|
243
|
+
return match?.[1]?.replace('+', '/') === pkg ? (match[2] ?? null) : null;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Whether the advisory is about the copy that ships. Only answered "no" when both sides name exact
|
|
247
|
+
* versions and they share none: an audit of a Nuxt app reported six advisories against
|
|
248
|
+
* `devalue <=5.9.2` as in the first load, raised them to `high` and failed `--fail-on high`, while
|
|
249
|
+
* the browser carried `devalue@6.0.2` and 5.9.2 was a copy only the server had. Anything less
|
|
250
|
+
* certain than that stays reported, which is the side to be wrong on.
|
|
251
|
+
*/
|
|
252
|
+
const affectsShipped = (advisory, shipped) => !advisory.versions || !shipped || shipped.size === 0 || advisory.versions.some(version => shipped.has(version));
|
|
202
253
|
/**
|
|
203
254
|
* The crossing. What every figure here is about is the word **shipped**: an advisory whose package
|
|
204
255
|
* never reaches a browser is real and is not what this report is for.
|
|
205
256
|
*/
|
|
206
257
|
const readDeps = (input) => {
|
|
207
258
|
const shippedBytes = new Map();
|
|
259
|
+
const shippedVersions = new Map();
|
|
208
260
|
for (const module of input.modules) {
|
|
209
261
|
if (!module.pkg) {
|
|
210
262
|
continue;
|
|
@@ -213,22 +265,58 @@ const readDeps = (input) => {
|
|
|
213
265
|
entry.bytes += module.bytes;
|
|
214
266
|
entry.inBoot ||= module.places.some(place => input.boot.has(place.chunk));
|
|
215
267
|
shippedBytes.set(module.pkg, entry);
|
|
268
|
+
const version = shippedVersionOf(module.path, module.pkg);
|
|
269
|
+
if (version) {
|
|
270
|
+
shippedVersions.set(module.pkg, (shippedVersions.get(module.pkg) ?? new Set()).add(version));
|
|
271
|
+
}
|
|
216
272
|
}
|
|
273
|
+
const ships = (advisory) => shippedBytes.has(advisory.package) && affectsShipped(advisory, shippedVersions.get(advisory.package));
|
|
217
274
|
const byName = new Map();
|
|
218
275
|
const locked = input.lock ?? [];
|
|
276
|
+
const parents = new Map();
|
|
219
277
|
for (const entry of locked) {
|
|
220
278
|
byName.set(entry.name, [...(byName.get(entry.name) ?? []), entry]);
|
|
279
|
+
const declared = Object.keys(entry.declares ?? {});
|
|
280
|
+
for (const dependency of declared) {
|
|
281
|
+
parents.set(dependency, (parents.get(dependency) ?? new Set()).add(entry.name));
|
|
282
|
+
}
|
|
221
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* The shortest chain from something the project asked for to the package that pulls `name` in,
|
|
286
|
+
* walked up what each lock entry declares. Nothing filled `requiredBy`, so "each one comes with
|
|
287
|
+
* the dependency chain that pulls it" was printed over chains that were always empty. Empty
|
|
288
|
+
* still when the lock does not record what each entry declares (pnpm's does not here) or when
|
|
289
|
+
* nothing the project asked for is up the chain.
|
|
290
|
+
*/
|
|
291
|
+
const chainOf = (name) => {
|
|
292
|
+
const seen = new Set([name]);
|
|
293
|
+
const queue = [[name]];
|
|
294
|
+
for (let path = queue.shift(); path; path = queue.shift()) {
|
|
295
|
+
const above = parents.get(path[0] ?? '') ?? [];
|
|
296
|
+
for (const parent of above) {
|
|
297
|
+
if (seen.has(parent)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const longer = [parent, ...path];
|
|
301
|
+
if (input.direct.has(parent)) {
|
|
302
|
+
return longer.slice(0, -1);
|
|
303
|
+
}
|
|
304
|
+
seen.add(parent);
|
|
305
|
+
queue.push(longer);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return byName.get(name)?.[0]?.requiredBy ?? [];
|
|
309
|
+
};
|
|
222
310
|
const advisories = input.advisories ?? [];
|
|
223
311
|
const shipped = advisories
|
|
224
|
-
.filter(advisory =>
|
|
312
|
+
.filter(advisory => ships(advisory))
|
|
225
313
|
.map(advisory => {
|
|
226
314
|
const where = shippedBytes.get(advisory.package);
|
|
227
315
|
return {
|
|
228
316
|
...advisory,
|
|
229
317
|
bytes: where?.bytes ?? 0,
|
|
230
318
|
inBoot: where?.inBoot ?? false,
|
|
231
|
-
chain:
|
|
319
|
+
chain: chainOf(advisory.package),
|
|
232
320
|
};
|
|
233
321
|
})
|
|
234
322
|
.toSorted((a, b) => Number(b.inBoot) - Number(a.inBoot) || RANK[a.severity] - RANK[b.severity]);
|
|
@@ -236,14 +324,14 @@ const readDeps = (input) => {
|
|
|
236
324
|
lockRead: input.lock !== null,
|
|
237
325
|
auditRead: input.advisories !== null,
|
|
238
326
|
shipped,
|
|
239
|
-
notShipped: advisories.filter(advisory => !
|
|
327
|
+
notShipped: advisories.filter(advisory => !ships(advisory)),
|
|
240
328
|
transitive: [...shippedBytes]
|
|
241
329
|
.filter(([name]) => input.direct.size > 0 && !input.direct.has(name))
|
|
242
330
|
.map(([name, entry]) => ({
|
|
243
331
|
name,
|
|
244
332
|
bytes: entry.bytes,
|
|
245
333
|
inBoot: entry.inBoot,
|
|
246
|
-
chain:
|
|
334
|
+
chain: chainOf(name),
|
|
247
335
|
}))
|
|
248
336
|
.toSorted((a, b) => b.bytes - a.bytes),
|
|
249
337
|
multipleVersions: [...byName]
|
|
@@ -12,19 +12,24 @@
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.summaryText = void 0;
|
|
14
14
|
const actions_1 = require("../findings/actions");
|
|
15
|
-
const finding_plain_1 = require("../findings/finding-plain");
|
|
15
|
+
const finding_plain_1 = require("../findings/text/finding-plain");
|
|
16
16
|
const format_utils_1 = require("../format/format.utils");
|
|
17
|
+
const defer_1 = require("../whatif/defer");
|
|
17
18
|
const WORDS = {
|
|
18
19
|
en: {
|
|
19
20
|
boot: 'Bootstrap',
|
|
20
21
|
trip: 'First trip',
|
|
21
22
|
screens: 'Screens',
|
|
22
23
|
worst: 'Heaviest screen',
|
|
23
|
-
signals:
|
|
24
|
+
signals: (shown, all) => `Signals to review: ${shown} of ${all}`,
|
|
24
25
|
actions: 'What to fix first',
|
|
25
26
|
saving: 'All of it is worth',
|
|
26
27
|
whatIf: 'What if it were deferred',
|
|
28
|
+
gatesPassed: 'Gates: all passed',
|
|
29
|
+
gatesBroken: (count) => `Gates: ${count} broken`,
|
|
27
30
|
without: (target, saved, after) => ` without ${target}: ${saved} off the first load, which would then weigh ${after}`,
|
|
31
|
+
unknown: (target) => ` without ${target}: cannot be measured, this build does not say which file imports which`,
|
|
32
|
+
opaque: 'No source maps: what each chunk weighs is known, what is inside it is not.',
|
|
28
33
|
tail: (unit) => `— Loadline, figures ${unit}`,
|
|
29
34
|
},
|
|
30
35
|
es: {
|
|
@@ -32,11 +37,15 @@ const WORDS = {
|
|
|
32
37
|
trip: 'Primer viaje',
|
|
33
38
|
screens: 'Pantallas',
|
|
34
39
|
worst: 'Pantalla más pesada',
|
|
35
|
-
signals:
|
|
40
|
+
signals: (shown, all) => `Señales a revisar: ${shown} de ${all}`,
|
|
36
41
|
actions: 'Qué arreglo primero',
|
|
37
42
|
saving: 'Todo junto vale',
|
|
38
43
|
whatIf: 'Y si se difiriera',
|
|
44
|
+
gatesPassed: 'Gates: todos pasan',
|
|
45
|
+
gatesBroken: (count) => `Gates: ${count} ${count === 1 ? 'roto' : 'rotos'}`,
|
|
39
46
|
without: (target, saved, after) => ` sin ${target}: ${saved} menos en la primera carga, que pasaría a pesar ${after}`,
|
|
47
|
+
unknown: (target) => ` sin ${target}: no se puede medir, este build no dice qué fichero importa a cuál`,
|
|
48
|
+
opaque: 'Sin source maps: se sabe lo que pesa cada chunk, no lo que hay dentro.',
|
|
40
49
|
tail: (unit) => `— Loadline, cifras ${unit}`,
|
|
41
50
|
},
|
|
42
51
|
};
|
|
@@ -53,18 +62,31 @@ const summaryText = (input) => {
|
|
|
53
62
|
const total = (0, actions_1.totalSaving)(analysis, input.findings);
|
|
54
63
|
const actions = (0, actions_1.rankActions)(input.findings).slice(0, 3);
|
|
55
64
|
const whatIf = input.whatIf ?? [];
|
|
65
|
+
const opaque = (0, defer_1.blindBoot)(analysis);
|
|
56
66
|
const bootLine = comparison
|
|
57
67
|
? `${(0, format_utils_1.formatBytes)(analysis.bootBytes)} (${(0, format_utils_1.formatDelta)(comparison.boot.diff)} vs ${comparison.baselineName})`
|
|
58
68
|
: (0, format_utils_1.formatBytes)(analysis.bootBytes);
|
|
59
69
|
const lines = [
|
|
60
70
|
`Loadline · ${input.name}`,
|
|
71
|
+
// Up here and not in a signal: it decides how every line below is read, and a paste is
|
|
72
|
+
// read once, from the top.
|
|
73
|
+
...(opaque ? [words.opaque] : []),
|
|
61
74
|
'',
|
|
62
75
|
`${words.boot}: ${bootLine}`,
|
|
63
76
|
...(input.since ? [input.since] : []),
|
|
64
77
|
...(input.firstTrip === null ? [] : [`${words.trip}: ${(0, format_utils_1.formatBytes)(input.firstTrip)}`]),
|
|
65
78
|
`${words.screens}: ${analysis.screens.length}`,
|
|
66
79
|
...(worst ? [`${words.worst}: ${worst.label} — ${(0, format_utils_1.formatBytes)(worst.total)}`] : []),
|
|
67
|
-
|
|
80
|
+
// The ones worth a look, out of all of them: "Signals: 2" next to another format's 7
|
|
81
|
+
// read as two reports disagreeing.
|
|
82
|
+
words.signals(problems.length, input.findings.length),
|
|
83
|
+
// A pipeline that went red has to say why in the step that turned it red: the summary is
|
|
84
|
+
// the format recommended for a job log, and it used to exit 1 without naming the gate.
|
|
85
|
+
...(input.gates === undefined
|
|
86
|
+
? []
|
|
87
|
+
: input.gates.length === 0
|
|
88
|
+
? [words.gatesPassed]
|
|
89
|
+
: [words.gatesBroken(input.gates.length), ...input.gates.map(line => ` x ${line}`)]),
|
|
68
90
|
...(actions.length > 0
|
|
69
91
|
? [
|
|
70
92
|
'',
|
|
@@ -79,7 +101,9 @@ const summaryText = (input) => {
|
|
|
79
101
|
? [
|
|
80
102
|
'',
|
|
81
103
|
`${words.whatIf}:`,
|
|
82
|
-
...whatIf.map(result =>
|
|
104
|
+
...whatIf.map(result => result.measurable
|
|
105
|
+
? words.without(result.target, (0, actions_1.formatSaving)(result.saved, scale), (0, actions_1.formatRemaining)(analysis, result.saved, result.after))
|
|
106
|
+
: words.unknown(result.target)),
|
|
83
107
|
]
|
|
84
108
|
: []),
|
|
85
109
|
'',
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* what removing both gives. It is one walk of the graph with every named file taken out at once.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.rankActions = exports.savingInUnit = exports.savingWords = exports.formatRemaining = exports.remainingInUnit = exports.formatSaving = exports.inUnit = exports.unitScale = exports.totalSaving = void 0;
|
|
15
|
+
exports.rankActions = exports.savingInUnit = exports.savingWords = exports.formatRemaining = exports.remainingInUnit = exports.formatSaving = exports.inUnit = exports.unitScale = exports.RAW_SCALE = exports.totalSaving = void 0;
|
|
16
16
|
const format_utils_1 = require("../format/format.utils");
|
|
17
17
|
const effort_1 = require("./effort");
|
|
18
18
|
/**
|
|
@@ -39,6 +39,8 @@ const totalSaving = (analysis, findings) => {
|
|
|
39
39
|
return { bytes, before: insights.bootTotal, after: Math.max(0, insights.bootTotal - bytes), counted };
|
|
40
40
|
};
|
|
41
41
|
exports.totalSaving = totalSaving;
|
|
42
|
+
/** A raw report: nothing converted, nothing estimated. */
|
|
43
|
+
exports.RAW_SCALE = { ratio: 1, estimated: false };
|
|
42
44
|
const unitScale = (analysis) => {
|
|
43
45
|
const estimated = analysis.bootRawBytes > 0 && analysis.bootBytes !== analysis.bootRawBytes;
|
|
44
46
|
return { ratio: estimated ? analysis.bootBytes / analysis.bootRawBytes : 1, estimated };
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.buildBootSingleFindings = void 0;
|
|
14
|
-
const format_utils_1 = require("
|
|
15
|
-
const finding_html_1 = require("
|
|
16
|
-
const finding_text_1 = require("
|
|
14
|
+
const format_utils_1 = require("../../format/format.utils");
|
|
15
|
+
const finding_html_1 = require("../text/finding-html");
|
|
16
|
+
const finding_text_1 = require("../text/finding-text");
|
|
17
17
|
/**
|
|
18
18
|
* Packages a bootstrap needs by definition: the framework, its runtime and the helpers every file
|
|
19
19
|
* compiles against. One file importing `@angular/platform-browser` is `main.ts` starting the app,
|
|
@@ -10,16 +10,19 @@
|
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.buildDupesFindings = void 0;
|
|
13
|
-
const pins_1 = require("
|
|
14
|
-
const format_utils_1 = require("
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
const pins_1 = require("../../deps/pins");
|
|
14
|
+
const format_utils_1 = require("../../format/format.utils");
|
|
15
|
+
const actions_1 = require("../actions");
|
|
16
|
+
const finding_html_1 = require("../text/finding-html");
|
|
17
|
+
const finding_text_1 = require("../text/finding-text");
|
|
17
18
|
const buildDupesFindings = (analysis, lang, declared) => {
|
|
18
19
|
const text = finding_text_1.TEXT[lang];
|
|
19
20
|
const firstDupe = analysis.duplicates[0];
|
|
20
21
|
if (!firstDupe) {
|
|
21
22
|
return [];
|
|
22
23
|
}
|
|
24
|
+
// A copy's weight is its modules', raw: shown at the ratio the bootstrap compresses by.
|
|
25
|
+
const scale = (0, actions_1.unitScale)(analysis);
|
|
23
26
|
const pins = (0, pins_1.pinsOf)(analysis.duplicates, declared);
|
|
24
27
|
const allPins = [...pins.values()].flat();
|
|
25
28
|
const parents = (apart) => {
|
|
@@ -34,7 +37,7 @@ const buildDupesFindings = (analysis, lang, declared) => {
|
|
|
34
37
|
return text.dupeCopy({
|
|
35
38
|
version: copy.version,
|
|
36
39
|
under: copy.under,
|
|
37
|
-
size: (0,
|
|
40
|
+
size: (0, actions_1.formatSaving)(copy.bytes, scale),
|
|
38
41
|
zone: text.dupeZone[copy.zone],
|
|
39
42
|
chain: copy.chain ? (0, finding_html_1.chainHtml)((0, format_utils_1.chainSteps)(copy.chain)) : null,
|
|
40
43
|
own: copy.importers.length > 0 ? copy.importers.map(file => (0, finding_html_1.mono)(file)).join(', ') : null,
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.buildGraphFindings = void 0;
|
|
14
|
-
const format_utils_1 = require("
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const format_utils_1 = require("../../format/format.utils");
|
|
15
|
+
const actions_1 = require("../actions");
|
|
16
|
+
const finding_html_1 = require("../text/finding-html");
|
|
17
|
+
const finding_text_1 = require("../text/finding-text");
|
|
17
18
|
const named = (items) => items.map(item => (0, finding_html_1.mono)(item)).join(', ');
|
|
18
19
|
/** A cycle as the circle somebody would draw: `checkout › shared › analytics › checkout`. */
|
|
19
20
|
const loop = (cycle) => cycle.steps.map(step => (0, finding_html_1.mono)(step)).join(' › ');
|
|
@@ -21,6 +22,11 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
21
22
|
const text = finding_text_1.TEXT[lang];
|
|
22
23
|
const insights = analysis.insights();
|
|
23
24
|
const findings = [];
|
|
25
|
+
// Every figure below is about modules, and a module only has raw bytes: gzip compresses a chunk
|
|
26
|
+
// as a whole. Shown at the ratio the bootstrap compresses by and marked `≈`, as savings are —
|
|
27
|
+
// printed raw, a gzip report put "a 40 kB package" next to "≈+15 kB" for the same package.
|
|
28
|
+
const scale = (0, actions_1.unitScale)(analysis);
|
|
29
|
+
const sized = (bytes) => (0, actions_1.formatSaving)(bytes, scale);
|
|
24
30
|
// 1 · The `import()` that defers nothing. The classic silent failure of code splitting, and it
|
|
25
31
|
// lives on the edges of the graph, which is why no tool looking at chunks shows it.
|
|
26
32
|
const mixed = insights.mixedImports;
|
|
@@ -38,10 +44,10 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
38
44
|
...text.mixedImport({
|
|
39
45
|
count: mixed.length,
|
|
40
46
|
name: worstMixed.label,
|
|
41
|
-
size: (
|
|
47
|
+
size: sized(mixed.reduce((sum, entry) => sum + entry.bytes, 0)),
|
|
42
48
|
inBoot: mixed.some(entry => entry.inBoot),
|
|
43
49
|
list: mixed
|
|
44
|
-
.map(entry => `${(0, finding_html_1.mono)(entry.label)} (${(
|
|
50
|
+
.map(entry => `${(0, finding_html_1.mono)(entry.label)} (${sized(entry.bytes)}${entry.inBoot ? ', bootstrap' : ''}) — ${named(entry.staticImporters.map(file => (0, format_utils_1.baseName)(file)))}`)
|
|
45
51
|
.join(' · '),
|
|
46
52
|
}),
|
|
47
53
|
});
|
|
@@ -61,10 +67,10 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
61
67
|
count: barrels.length,
|
|
62
68
|
name: worstBarrel.path,
|
|
63
69
|
pulls: worstBarrel.pulls,
|
|
64
|
-
size: (
|
|
70
|
+
size: sized(worstBarrel.exclusive),
|
|
65
71
|
importers: (0, finding_html_1.fewNamed)(worstBarrel.importers.map(file => (0, format_utils_1.baseName)(file)), text.andMore),
|
|
66
72
|
list: barrels
|
|
67
|
-
.map(barrel => `${(0, finding_html_1.mono)(barrel.path)} — ${text.ownBarrelRow(barrel.reexports, barrel.pulls, (
|
|
73
|
+
.map(barrel => `${(0, finding_html_1.mono)(barrel.path)} — ${text.ownBarrelRow(barrel.reexports, barrel.pulls, sized(barrel.exclusive))}`)
|
|
68
74
|
.join(' · '),
|
|
69
75
|
}),
|
|
70
76
|
});
|
|
@@ -82,10 +88,10 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
82
88
|
name: worstPackage.name,
|
|
83
89
|
files: worstPackage.files,
|
|
84
90
|
entryPoints: worstPackage.entryPoints,
|
|
85
|
-
size: (
|
|
91
|
+
size: sized(worstPackage.bytes),
|
|
86
92
|
importers: (0, finding_html_1.fewNamed)(worstPackage.importers.map(file => (0, format_utils_1.baseName)(file)), text.andMore),
|
|
87
93
|
list: packages
|
|
88
|
-
.map(pkg => `${(0, finding_html_1.mono)(pkg.name)} — ${text.packageBarrelRow(pkg.files, pkg.entryPoints, (
|
|
94
|
+
.map(pkg => `${(0, finding_html_1.mono)(pkg.name)} — ${text.packageBarrelRow(pkg.files, pkg.entryPoints, sized(pkg.bytes), pkg.inBoot)}`)
|
|
89
95
|
.join(' · '),
|
|
90
96
|
}),
|
|
91
97
|
});
|
|
@@ -102,10 +108,12 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
102
108
|
...text.cycles({
|
|
103
109
|
files: cycles.length,
|
|
104
110
|
folders: folders.length,
|
|
105
|
-
|
|
111
|
+
// Plain: it goes into the title, which every renderer prints as text. Through `loop`
|
|
112
|
+
// the page showed `<span class="mono">features/article</span> › …` as written.
|
|
113
|
+
worst: firstCycle.steps.join(' › '),
|
|
106
114
|
inBoot: cycles.some(cycle => cycle.inBoot),
|
|
107
115
|
folderList: folders.map(cycle => loop(cycle)).join(' · '),
|
|
108
|
-
fileList: cycles.map(cycle => `${loop(cycle)} (${(
|
|
116
|
+
fileList: cycles.map(cycle => `${loop(cycle)} (${sized(cycle.bytes)})`).join(' · '),
|
|
109
117
|
}),
|
|
110
118
|
});
|
|
111
119
|
}
|
|
@@ -120,9 +128,9 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
120
128
|
kind: 'paidTwice',
|
|
121
129
|
...text.paidTwice({
|
|
122
130
|
count: twice.length,
|
|
123
|
-
size: (
|
|
131
|
+
size: sized(twiceBytes),
|
|
124
132
|
list: twice
|
|
125
|
-
.map(entry => `${(0, finding_html_1.mono)(entry.label)} ×${entry.copies} (${(
|
|
133
|
+
.map(entry => `${(0, finding_html_1.mono)(entry.label)} ×${entry.copies} (${sized(entry.wasted)}) — ${named(entry.chunks)}`)
|
|
126
134
|
.join(' · '),
|
|
127
135
|
}),
|
|
128
136
|
});
|
|
@@ -140,14 +148,16 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
140
148
|
a: firstTwin.labelA,
|
|
141
149
|
b: firstTwin.labelB,
|
|
142
150
|
pct: Math.round(firstTwin.overlap * 100),
|
|
143
|
-
apart: (
|
|
151
|
+
apart: sized(firstTwin.apartBytes),
|
|
144
152
|
list: twins
|
|
145
|
-
.map(twin => `${(0, finding_html_1.mono)(twin.labelA)} / ${(0, finding_html_1.mono)(twin.labelB)} (${Math.round(twin.overlap * 100)} %, ${(
|
|
153
|
+
.map(twin => `${(0, finding_html_1.mono)(twin.labelA)} / ${(0, finding_html_1.mono)(twin.labelB)} (${Math.round(twin.overlap * 100)} %, ${sized(twin.apartBytes)})`)
|
|
146
154
|
.join(' · '),
|
|
147
155
|
}),
|
|
148
156
|
});
|
|
149
157
|
}
|
|
150
158
|
// 7 · Whose code the first load is. Context, never a fault: a framework is somebody else's code.
|
|
159
|
+
// The split is raw, like everything inside a chunk; shown at the ratio the bootstrap
|
|
160
|
+
// compresses by, or a gzip report read "268 kB of packages" over an 87 kB bootstrap.
|
|
151
161
|
const { ownership } = insights;
|
|
152
162
|
if (ownership.theirsRatio >= c.theirsRatio && ownership.theirs > 0) {
|
|
153
163
|
findings.push({
|
|
@@ -156,9 +166,11 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
156
166
|
kind: 'theirs',
|
|
157
167
|
...text.theirs({
|
|
158
168
|
pct: Math.round(ownership.theirsRatio * 100),
|
|
159
|
-
theirs: (0,
|
|
160
|
-
yours: (0,
|
|
161
|
-
list: ownership.topPackages
|
|
169
|
+
theirs: (0, actions_1.formatSaving)(ownership.theirs, scale),
|
|
170
|
+
yours: (0, actions_1.formatSaving)(ownership.yours, scale),
|
|
171
|
+
list: ownership.topPackages
|
|
172
|
+
.map(pkg => `${(0, finding_html_1.mono)(pkg.name)} (${(0, actions_1.formatSaving)(pkg.bytes, scale)})`)
|
|
173
|
+
.join(' · '),
|
|
162
174
|
}),
|
|
163
175
|
});
|
|
164
176
|
}
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.buildOwnInBootFindings = void 0;
|
|
20
|
-
const format_utils_1 = require("
|
|
21
|
-
const
|
|
22
|
-
const
|
|
20
|
+
const format_utils_1 = require("../../format/format.utils");
|
|
21
|
+
const actions_1 = require("../actions");
|
|
22
|
+
const finding_html_1 = require("../text/finding-html");
|
|
23
|
+
const finding_text_1 = require("../text/finding-text");
|
|
23
24
|
const inBoot = (module) => module.places.some(place => place.zone === 'boot');
|
|
24
25
|
const candidatesOf = (analysis, c) => {
|
|
25
26
|
const screens = new Set(analysis.screens.map(screen => screen.source));
|
|
@@ -67,6 +68,9 @@ const buildOwnInBootFindings = (analysis, lang, c) => {
|
|
|
67
68
|
}
|
|
68
69
|
const insights = analysis.insights();
|
|
69
70
|
const files = candidates.flatMap(entry => insights.filesByBucket.get(entry.folder) ?? []);
|
|
71
|
+
// Folders are raw bytes; in a gzip report "6 files of yours take 389 kB" read as 46 % of an
|
|
72
|
+
// 847 kB bootstrap when it was 14 % of it.
|
|
73
|
+
const scale = (0, actions_1.unitScale)(analysis);
|
|
70
74
|
return [
|
|
71
75
|
{
|
|
72
76
|
severity: 'mid',
|
|
@@ -77,9 +81,9 @@ const buildOwnInBootFindings = (analysis, lang, c) => {
|
|
|
77
81
|
...text.ownInBoot({
|
|
78
82
|
count: candidates.length,
|
|
79
83
|
name: first.folder,
|
|
80
|
-
size: (0,
|
|
84
|
+
size: (0, actions_1.formatSaving)(bytes, scale),
|
|
81
85
|
list: candidates
|
|
82
|
-
.map(entry => `${(0, finding_html_1.mono)(entry.folder)} (${(0,
|
|
86
|
+
.map(entry => `${(0, finding_html_1.mono)(entry.folder)} (${(0, actions_1.formatSaving)(entry.bytes, scale)}) — ${text.ownInBootKept(entry.keeping.map(file => (0, finding_html_1.mono)(file)).join(', '), entry.lazy.length)}`)
|
|
83
87
|
.join(' · '),
|
|
84
88
|
}),
|
|
85
89
|
},
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.buildRequestFindings = void 0;
|
|
22
|
-
const format_utils_1 = require("
|
|
23
|
-
const finding_html_1 = require("
|
|
24
|
-
const finding_text_1 = require("
|
|
22
|
+
const format_utils_1 = require("../../format/format.utils");
|
|
23
|
+
const finding_html_1 = require("../text/finding-html");
|
|
24
|
+
const finding_text_1 = require("../text/finding-text");
|
|
25
25
|
/** The middle screen, which is what "the typical screen" means everywhere else in the report. */
|
|
26
26
|
const median = (list) => list[Math.floor(list.length / 2)];
|
|
27
27
|
/**
|
|
@@ -16,14 +16,22 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.buildFolderFindings = exports.buildShippedFindings = void 0;
|
|
19
|
-
const format_utils_1 = require("
|
|
20
|
-
const finding_text_1 = require("
|
|
19
|
+
const format_utils_1 = require("../../format/format.utils");
|
|
20
|
+
const finding_text_1 = require("../text/finding-text");
|
|
21
21
|
/**
|
|
22
22
|
* A file named after a language: `es.js`, `pt-BR.json`, `zh-Hant.mjs`. Counting **codes** and not
|
|
23
23
|
* files is what keeps the count right — `date-fns` splits one language across ten files under
|
|
24
24
|
* `locale/en-US/_lib/`, and counting those would report ten languages where there is one.
|
|
25
25
|
*/
|
|
26
|
-
const LOCALE_CODE = /^[a-z]{2,3}(
|
|
26
|
+
const LOCALE_CODE = /^[a-z]{2,3}(?:[-_](?:[A-Za-z]{2}|\d{3}|[A-Za-z]{4})){0,2}$/;
|
|
27
|
+
/**
|
|
28
|
+
* The same, for a file that sits in no language folder: two letters only. Three-letter names are
|
|
29
|
+
* mostly not languages — `map`, `has`, `url`, `dsn`, `ast` — and a subtag of any length let in
|
|
30
|
+
* `ast-utils` and `jsx-runtime`: langium was reported as shipping four language files that were
|
|
31
|
+
* its syntax tree helpers. A subtag is what BCP 47 says it is: a region of two letters or three
|
|
32
|
+
* digits, or a script of four letters.
|
|
33
|
+
*/
|
|
34
|
+
const BARE_LOCALE_CODE = /^[a-z]{2}(?:[-_](?:[A-Za-z]{2}|\d{3}|[A-Za-z]{4})){0,2}$/;
|
|
27
35
|
/**
|
|
28
36
|
* What a library calls the folder it keeps its languages in. `locale` and `locales` were the whole
|
|
29
37
|
* list, which quietly meant that a package shipping them under `i18n/` — which plenty do — raised
|
|
@@ -38,14 +46,15 @@ const LOCALE_FOLDERS = new Set(['locale', 'locales', 'i18n', 'lang', 'langs', 'l
|
|
|
38
46
|
const localeOf = (path) => {
|
|
39
47
|
const parts = path.split('/');
|
|
40
48
|
const marker = parts.findIndex(part => LOCALE_FOLDERS.has(part));
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const code = (
|
|
44
|
-
|
|
45
|
-
return code;
|
|
46
|
-
}
|
|
49
|
+
const codeOf = (part) => (part ?? '').replace(/\.[^.]+$/, '');
|
|
50
|
+
if (marker === -1) {
|
|
51
|
+
const code = codeOf(parts.at(-1));
|
|
52
|
+
return BARE_LOCALE_CODE.test(code) ? code : null;
|
|
47
53
|
}
|
|
48
|
-
|
|
54
|
+
// Right under the language folder, as a folder (`locale/es/index.js`) or as the file itself
|
|
55
|
+
// (`locale/es.js`). Deeper than that it is something else the folder happens to hold.
|
|
56
|
+
const code = codeOf(parts[marker + 1]);
|
|
57
|
+
return LOCALE_CODE.test(code) ? code : null;
|
|
49
58
|
};
|
|
50
59
|
const sum = (modules) => modules.reduce((total, module) => total + module.bytes, 0);
|
|
51
60
|
/** The worst place a set of files lands: the bootstrap is the one everybody pays for. */
|
|
@@ -178,7 +187,7 @@ const DRIFT_OVERHEAD_PER_CHUNK = 1024;
|
|
|
178
187
|
* before a later pass shrinks the output — while the headline weight beside it stays exact. Nothing
|
|
179
188
|
* said so, and a quarter is enough to change which row somebody spends an afternoon on.
|
|
180
189
|
*/
|
|
181
|
-
const driftFinding = (drift, lang) => {
|
|
190
|
+
const driftFinding = (drift, lang, tool) => {
|
|
182
191
|
if (!drift) {
|
|
183
192
|
return [];
|
|
184
193
|
}
|
|
@@ -199,6 +208,7 @@ const driftFinding = (drift, lang) => {
|
|
|
199
208
|
file: (0, format_utils_1.formatBytes)(drift.file),
|
|
200
209
|
measured: (0, format_utils_1.formatBytes)(drift.measured),
|
|
201
210
|
angular: drift.angular === true,
|
|
211
|
+
...(tool && { tool }),
|
|
202
212
|
}),
|
|
203
213
|
},
|
|
204
214
|
];
|
|
@@ -206,11 +216,15 @@ const driftFinding = (drift, lang) => {
|
|
|
206
216
|
const buildFolderFindings = (build, lang) => {
|
|
207
217
|
// The drift is about the metafile, not about the folder, so it is raised whichever way in was
|
|
208
218
|
// used and whether or not the maps are there: the early returns below are about the folder.
|
|
209
|
-
const drift = driftFinding(build.drift ?? null, lang);
|
|
219
|
+
const drift = driftFinding(build.drift ?? null, lang, build.tool);
|
|
210
220
|
if (build.sourceMaps > 0) {
|
|
211
221
|
return [
|
|
212
222
|
...drift,
|
|
213
|
-
{
|
|
223
|
+
{
|
|
224
|
+
severity: 'info',
|
|
225
|
+
kind: 'sourceMaps',
|
|
226
|
+
...finding_text_1.TEXT[lang].sourceMaps({ count: build.sourceMaps, tool: build.tool }),
|
|
227
|
+
},
|
|
214
228
|
];
|
|
215
229
|
}
|
|
216
230
|
if (!build.derived) {
|
|
@@ -235,7 +249,7 @@ const buildFolderFindings = (build, lang) => {
|
|
|
235
249
|
{
|
|
236
250
|
severity: blind ? 'mid' : 'info',
|
|
237
251
|
kind: 'noSourceMaps',
|
|
238
|
-
...finding_text_1.TEXT[lang].noSourceMaps({ unnamed: blind ? unnamed : 0 }),
|
|
252
|
+
...finding_text_1.TEXT[lang].noSourceMaps({ unnamed: blind ? unnamed : 0, tool: build.tool }),
|
|
239
253
|
},
|
|
240
254
|
];
|
|
241
255
|
};
|
|
@@ -33,9 +33,14 @@ const composeFindings = (sources) => {
|
|
|
33
33
|
* nothing lazy at all, which has to say "everything is in the bootstrap" and stay a report — and
|
|
34
34
|
* it is what caught this.
|
|
35
35
|
*/
|
|
36
|
+
//
|
|
37
|
+
// Nor when the folder had no source maps. The card vouches for the breakdown — "no package
|
|
38
|
+
// shipped twice" — and without maps there is no breakdown: a real build read that way printed
|
|
39
|
+
// it right above the note saying there was no breakdown by package.
|
|
40
|
+
const blind = extra.some(finding => finding.kind === 'noSourceMaps');
|
|
36
41
|
const notes = [...base, ...fromMeasurement, ...extra]
|
|
37
42
|
.filter(finding => !isProblem(finding))
|
|
38
|
-
.filter(finding => problems.length === 0 || finding.kind !== 'clean');
|
|
43
|
+
.filter(finding => (problems.length === 0 && !blind) || finding.kind !== 'clean');
|
|
39
44
|
return [...problems, ...notes];
|
|
40
45
|
};
|
|
41
46
|
exports.composeFindings = composeFindings;
|