@bymaksym/loadline 0.1.0 → 1.1.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 +272 -45
- package/dist/cli/cli/args.js +97 -116
- package/dist/cli/cli/gates.js +80 -14
- package/dist/cli/cli/main.js +275 -31
- package/dist/cli/cli/memory.js +114 -0
- package/dist/cli/cli/read/declared.js +52 -0
- package/dist/cli/cli/read/locate.js +214 -0
- package/dist/cli/cli/{read-build.js → read/read-build.js} +156 -87
- package/dist/cli/cli/read/read-config.js +120 -0
- package/dist/cli/cli/render/html-report.js +111 -0
- 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} +26 -10
- package/dist/cli/cli/{render-markdown.js → render/render-markdown.js} +6 -6
- package/dist/cli/cli/{render-pr.js → render/render-pr.js} +37 -15
- package/dist/cli/cli/{render-sarif.js → render/render-sarif.js} +11 -6
- package/dist/cli/cli/{render-text.js → render/render-text.js} +169 -127
- package/dist/cli/cli/render/terminal.js +55 -0
- package/dist/cli/cli/report.js +76 -29
- package/dist/cli/cli/self-check.js +19 -23
- package/dist/cli/cli/since-last.js +45 -0
- 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 +68 -24
- package/dist/cli/src/app/core/analysis/{barrels.js → graph/barrels.js} +10 -3
- 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 +21 -7
- 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} +87 -11
- 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} +13 -7
- package/dist/cli/src/app/core/analysis/tool.js +83 -0
- package/dist/cli/src/app/core/assets/assets.js +137 -16
- package/dist/cli/src/app/core/baseline/baseline.js +0 -0
- package/dist/cli/src/app/core/{intake → build-text}/index-html.js +234 -29
- 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 +123 -45
- 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 +141 -23
- package/dist/cli/src/app/core/deps/pins.js +63 -0
- package/dist/cli/src/app/core/export/summary.js +54 -12
- package/dist/cli/src/app/core/findings/actions.js +65 -6
- package/dist/cli/src/app/core/findings/bundle/boot-single.js +76 -0
- package/dist/cli/src/app/core/findings/bundle/dupes.js +68 -0
- package/dist/cli/src/app/core/findings/{graph.js → bundle/graph.js} +32 -20
- 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} +30 -18
- package/dist/cli/src/app/core/findings/compose.js +6 -1
- package/dist/cli/src/app/core/findings/effort.js +4 -0
- package/dist/cli/src/app/core/findings/finding.types.js +2 -0
- package/dist/cli/src/app/core/findings/findings.js +68 -55
- package/dist/cli/src/app/core/findings/{assets.js → folder/assets.js} +65 -16
- package/dist/cli/src/app/core/findings/{caching.js → folder/caching.js} +17 -10
- 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} +37 -13
- 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/text/finding-html.js +33 -0
- package/dist/cli/src/app/core/findings/{finding-text.js → text/finding-text.js} +307 -103
- package/dist/cli/src/app/core/findings/text/tool-advice.js +97 -0
- package/dist/cli/src/app/core/format/format.utils.js +172 -18
- package/dist/cli/src/app/core/format/ownership.js +93 -0
- package/dist/cli/src/app/core/i18n/en.js +180 -61
- package/dist/cli/src/app/core/i18n/es.js +192 -68
- package/dist/cli/src/app/core/intake/bundle-graph.js +285 -46
- package/dist/cli/src/app/core/intake/dist-files.js +87 -16
- package/dist/cli/src/app/core/intake/embedded.js +56 -0
- 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/budget-advice.js +14 -10
- package/dist/cli/src/app/core/project/project-context.js +89 -19
- package/dist/cli/src/app/core/project/project-name.js +36 -0
- package/dist/cli/src/app/core/scan/scan.js +116 -39
- package/dist/cli/src/app/core/scan/secrets.js +0 -0
- package/dist/cli/src/app/core/situation/situation-text.js +23 -0
- package/dist/cli/src/app/core/situation/situation.js +9 -8
- 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/dist/cli/src/app/state/report-messages.utils.js +1 -4
- package/docs/CONFIG-REFERENCE.md +230 -0
- package/docs/CONFIG.md +511 -0
- package/docs/HOW-IT-WORKS.md +286 -25
- package/loadline.html +26 -24
- package/loadline.schema.json +1209 -0
- package/package.json +71 -35
- package/dist/cli/cli/text.js +0 -180
- package/dist/cli/src/app/core/findings/finding-html.js +0 -13
- /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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The same package at two versions, each copy followed to whatever brings it in.
|
|
4
|
+
*
|
|
5
|
+
* Knowing there are two says nothing about what to do: the fix depends on where each one comes
|
|
6
|
+
* from. A copy your own code imports is aligned in `package.json`; one a dependency brings is
|
|
7
|
+
* forced with an override; and one a dependency **pins** to an exact version, a major away from the
|
|
8
|
+
* other, cannot be moved from the project at all without changing that dependency — which is the
|
|
9
|
+
* case the report used to answer with "force the resolution" and nothing else.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.buildDupesFindings = void 0;
|
|
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");
|
|
18
|
+
const buildDupesFindings = (analysis, lang, declared) => {
|
|
19
|
+
const text = finding_text_1.TEXT[lang];
|
|
20
|
+
const firstDupe = analysis.duplicates[0];
|
|
21
|
+
if (!firstDupe) {
|
|
22
|
+
return [];
|
|
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);
|
|
26
|
+
const pins = (0, pins_1.pinsOf)(analysis.duplicates, declared);
|
|
27
|
+
const allPins = [...pins.values()].flat();
|
|
28
|
+
const parents = (apart) => {
|
|
29
|
+
const names = [...new Set(allPins.filter(pin => pin.majorApart === apart).map(pin => pin.parent))];
|
|
30
|
+
return names.length > 0 ? names.map(name => (0, finding_html_1.mono)(name)).join(', ') : null;
|
|
31
|
+
};
|
|
32
|
+
const list = analysis.duplicates
|
|
33
|
+
.map(dupe => {
|
|
34
|
+
const copies = dupe.copies
|
|
35
|
+
.map(copy => {
|
|
36
|
+
const pin = (pins.get(dupe.name) ?? []).find(one => copy.viaPackages.includes(one.parent));
|
|
37
|
+
return text.dupeCopy({
|
|
38
|
+
version: copy.version,
|
|
39
|
+
under: copy.under,
|
|
40
|
+
size: (0, actions_1.formatSaving)(copy.bytes, scale),
|
|
41
|
+
zone: text.dupeZone[copy.zone],
|
|
42
|
+
chain: copy.chain ? (0, finding_html_1.chainHtml)((0, format_utils_1.chainSteps)(copy.chain)) : null,
|
|
43
|
+
own: copy.importers.length > 0 ? copy.importers.map(file => (0, finding_html_1.mono)(file)).join(', ') : null,
|
|
44
|
+
via: copy.viaPackages.length > 0 ? copy.viaPackages.map(pkg => (0, finding_html_1.mono)(pkg)).join(', ') : null,
|
|
45
|
+
pinned: pin ? { parent: (0, finding_html_1.mono)(pin.parent), range: (0, finding_html_1.mono)(pin.range) } : null,
|
|
46
|
+
});
|
|
47
|
+
})
|
|
48
|
+
.join(' ');
|
|
49
|
+
return `<strong>${dupe.name}</strong> — ${copies}`;
|
|
50
|
+
})
|
|
51
|
+
.join(' ');
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
severity: 'mid',
|
|
55
|
+
target: { tab: 'search', key: firstDupe.name },
|
|
56
|
+
kind: 'dupes',
|
|
57
|
+
...text.dupes({
|
|
58
|
+
count: analysis.duplicates.length,
|
|
59
|
+
list,
|
|
60
|
+
viaDependency: analysis.duplicates.some(dupe => dupe.copies.some(copy => copy.importers.length === 0)),
|
|
61
|
+
inBoot: analysis.duplicates.some(dupe => dupe.inBoot),
|
|
62
|
+
pinnedApart: parents(true),
|
|
63
|
+
pinnedSame: parents(false),
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
exports.buildDupesFindings = buildDupesFindings;
|
|
@@ -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: (
|
|
65
|
-
importers:
|
|
70
|
+
size: sized(worstBarrel.exclusive),
|
|
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)} — ${barrel.reexports
|
|
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: (
|
|
86
|
-
importers:
|
|
91
|
+
size: sized(worstPackage.bytes),
|
|
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)} — ${pkg.files
|
|
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 = /^
|
|
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. */
|
|
@@ -145,10 +154,7 @@ exports.buildShippedFindings = buildShippedFindings;
|
|
|
145
154
|
*/
|
|
146
155
|
const unnamedScreen = (label) => {
|
|
147
156
|
const rest = label.replace(/^chunk[-._]/i, '');
|
|
148
|
-
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
return /^[\dA-Za-z_-]{6,}$/.test(rest) && /[a-z]/.test(rest) && /[A-Z]/.test(rest) && /\d/.test(rest);
|
|
157
|
+
return rest !== label || (/^[\w-]{6,}$/.test(rest) && /[a-z]/.test(rest) && /[A-Z]/.test(rest) && /\d/.test(rest));
|
|
152
158
|
};
|
|
153
159
|
/**
|
|
154
160
|
* How far the two measurements of the same chunks have to be apart before it is worth a line.
|
|
@@ -181,7 +187,7 @@ const DRIFT_OVERHEAD_PER_CHUNK = 1024;
|
|
|
181
187
|
* before a later pass shrinks the output — while the headline weight beside it stays exact. Nothing
|
|
182
188
|
* said so, and a quarter is enough to change which row somebody spends an afternoon on.
|
|
183
189
|
*/
|
|
184
|
-
const driftFinding = (drift, lang) => {
|
|
190
|
+
const driftFinding = (drift, lang, tool) => {
|
|
185
191
|
if (!drift) {
|
|
186
192
|
return [];
|
|
187
193
|
}
|
|
@@ -201,6 +207,8 @@ const driftFinding = (drift, lang) => {
|
|
|
201
207
|
chunks: drift.chunks,
|
|
202
208
|
file: (0, format_utils_1.formatBytes)(drift.file),
|
|
203
209
|
measured: (0, format_utils_1.formatBytes)(drift.measured),
|
|
210
|
+
angular: drift.angular === true,
|
|
211
|
+
...(tool && { tool }),
|
|
204
212
|
}),
|
|
205
213
|
},
|
|
206
214
|
];
|
|
@@ -208,11 +216,15 @@ const driftFinding = (drift, lang) => {
|
|
|
208
216
|
const buildFolderFindings = (build, lang) => {
|
|
209
217
|
// The drift is about the metafile, not about the folder, so it is raised whichever way in was
|
|
210
218
|
// used and whether or not the maps are there: the early returns below are about the folder.
|
|
211
|
-
const drift = driftFinding(build.drift ?? null, lang);
|
|
219
|
+
const drift = driftFinding(build.drift ?? null, lang, build.tool);
|
|
212
220
|
if (build.sourceMaps > 0) {
|
|
213
221
|
return [
|
|
214
222
|
...drift,
|
|
215
|
-
{
|
|
223
|
+
{
|
|
224
|
+
severity: 'info',
|
|
225
|
+
kind: 'sourceMaps',
|
|
226
|
+
...finding_text_1.TEXT[lang].sourceMaps({ count: build.sourceMaps, tool: build.tool }),
|
|
227
|
+
},
|
|
216
228
|
];
|
|
217
229
|
}
|
|
218
230
|
if (!build.derived) {
|
|
@@ -237,7 +249,7 @@ const buildFolderFindings = (build, lang) => {
|
|
|
237
249
|
{
|
|
238
250
|
severity: blind ? 'mid' : 'info',
|
|
239
251
|
kind: 'noSourceMaps',
|
|
240
|
-
...finding_text_1.TEXT[lang].noSourceMaps({ unnamed: blind ? unnamed : 0 }),
|
|
252
|
+
...finding_text_1.TEXT[lang].noSourceMaps({ unnamed: blind ? unnamed : 0, tool: build.tool }),
|
|
241
253
|
},
|
|
242
254
|
];
|
|
243
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;
|
|
@@ -21,6 +21,8 @@ exports.EFFORT_WEIGHT = { config: 1, import: 2, refactor: 5, none: 0 };
|
|
|
21
21
|
exports.EFFORT = {
|
|
22
22
|
// One import moved, or one import narrowed.
|
|
23
23
|
bootLazy: 'import',
|
|
24
|
+
// One import turned into an `await import()` where the package is used.
|
|
25
|
+
bootSingle: 'import',
|
|
24
26
|
ownInBoot: 'refactor',
|
|
25
27
|
mixedImport: 'import',
|
|
26
28
|
ownBarrel: 'import',
|
|
@@ -98,6 +100,8 @@ exports.EFFORT = {
|
|
|
98
100
|
thirdParty: 'none',
|
|
99
101
|
licences: 'none',
|
|
100
102
|
transitive: 'none',
|
|
103
|
+
// The import the chain names, removed or made dynamic: the rule already said what to use instead.
|
|
104
|
+
forbidden: 'import',
|
|
101
105
|
updateWeight: 'none',
|
|
102
106
|
bootGrew: 'none',
|
|
103
107
|
bootNewPackages: 'none',
|
|
@@ -12,6 +12,7 @@ exports.FINDING_KINDS = void 0;
|
|
|
12
12
|
exports.FINDING_KINDS = [
|
|
13
13
|
'shared',
|
|
14
14
|
'bootLazy',
|
|
15
|
+
'bootSingle',
|
|
15
16
|
'bigFile',
|
|
16
17
|
'dupes',
|
|
17
18
|
'heavy',
|
|
@@ -47,6 +48,7 @@ exports.FINDING_KINDS = [
|
|
|
47
48
|
'licences',
|
|
48
49
|
'vulnerable',
|
|
49
50
|
'transitive',
|
|
51
|
+
'forbidden',
|
|
50
52
|
'bootWaves',
|
|
51
53
|
'slowScreens',
|
|
52
54
|
'manyRequests',
|