@bymaksym/loadline 0.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/LICENSE +21 -0
- package/README.md +182 -0
- package/bin/loadline.js +50 -0
- package/dist/cli/cli/args.js +324 -0
- package/dist/cli/cli/args.types.js +3 -0
- package/dist/cli/cli/gates.js +173 -0
- package/dist/cli/cli/gates.types.js +3 -0
- package/dist/cli/cli/main.js +156 -0
- package/dist/cli/cli/read-build.js +382 -0
- package/dist/cli/cli/read-build.types.js +3 -0
- package/dist/cli/cli/render-json.js +116 -0
- package/dist/cli/cli/render-json.types.js +10 -0
- package/dist/cli/cli/render-markdown.js +30 -0
- package/dist/cli/cli/render-pr.js +76 -0
- package/dist/cli/cli/render-sarif.js +83 -0
- package/dist/cli/cli/render-text.js +388 -0
- package/dist/cli/cli/report.js +196 -0
- package/dist/cli/cli/report.types.js +3 -0
- package/dist/cli/cli/self-check.js +85 -0
- package/dist/cli/cli/text.js +180 -0
- package/dist/cli/cli/text.types.js +10 -0
- package/dist/cli/src/app/core/analysis/analysis.js +661 -0
- package/dist/cli/src/app/core/analysis/analysis.types.js +6 -0
- package/dist/cli/src/app/core/analysis/barrels.js +128 -0
- package/dist/cli/src/app/core/analysis/blast.js +172 -0
- package/dist/cli/src/app/core/analysis/cycles.js +110 -0
- package/dist/cli/src/app/core/analysis/delivery.js +143 -0
- package/dist/cli/src/app/core/analysis/entries.js +217 -0
- package/dist/cli/src/app/core/analysis/exclusive.js +91 -0
- package/dist/cli/src/app/core/analysis/importers.js +38 -0
- package/dist/cli/src/app/core/analysis/insights.js +202 -0
- package/dist/cli/src/app/core/analysis/insights.types.js +10 -0
- package/dist/cli/src/app/core/analysis/invariant.js +69 -0
- package/dist/cli/src/app/core/analysis/metafile.types.js +44 -0
- package/dist/cli/src/app/core/analysis/module-graph.js +192 -0
- package/dist/cli/src/app/core/analysis/sourcemap.js +231 -0
- package/dist/cli/src/app/core/analysis/sourcemap.types.js +3 -0
- package/dist/cli/src/app/core/analysis/split-drift.js +47 -0
- package/dist/cli/src/app/core/assets/assets.js +296 -0
- package/dist/cli/src/app/core/assets/assets.types.js +11 -0
- package/dist/cli/src/app/core/baseline/baseline.js +0 -0
- package/dist/cli/src/app/core/baseline/baseline.types.js +3 -0
- package/dist/cli/src/app/core/caching/caching.js +241 -0
- package/dist/cli/src/app/core/caching/caching.types.js +10 -0
- package/dist/cli/src/app/core/caching/from-analysis.js +73 -0
- package/dist/cli/src/app/core/config/loadline-config.js +110 -0
- package/dist/cli/src/app/core/config/loadline-config.types.js +12 -0
- package/dist/cli/src/app/core/criteria/criteria.js +228 -0
- package/dist/cli/src/app/core/criteria/criteria.types.js +3 -0
- package/dist/cli/src/app/core/deps/deps.js +225 -0
- package/dist/cli/src/app/core/deps/deps.types.js +15 -0
- package/dist/cli/src/app/core/export/markdown-table.utils.js +40 -0
- package/dist/cli/src/app/core/export/summary.js +72 -0
- package/dist/cli/src/app/core/findings/actions.js +59 -0
- package/dist/cli/src/app/core/findings/assets.js +130 -0
- package/dist/cli/src/app/core/findings/caching.js +165 -0
- package/dist/cli/src/app/core/findings/compose.js +41 -0
- package/dist/cli/src/app/core/findings/deps.js +66 -0
- package/dist/cli/src/app/core/findings/effort.js +117 -0
- package/dist/cli/src/app/core/findings/finding-html.js +13 -0
- package/dist/cli/src/app/core/findings/finding-plain.js +26 -0
- package/dist/cli/src/app/core/findings/finding-text.js +1231 -0
- package/dist/cli/src/app/core/findings/finding.types.js +80 -0
- package/dist/cli/src/app/core/findings/findings.js +514 -0
- package/dist/cli/src/app/core/findings/graph.js +167 -0
- package/dist/cli/src/app/core/findings/own-in-boot.js +88 -0
- package/dist/cli/src/app/core/findings/page.js +49 -0
- package/dist/cli/src/app/core/findings/requests.js +185 -0
- package/dist/cli/src/app/core/findings/scan.js +126 -0
- package/dist/cli/src/app/core/findings/shipped.js +244 -0
- package/dist/cli/src/app/core/findings/situation.js +116 -0
- package/dist/cli/src/app/core/format/format.utils.js +204 -0
- package/dist/cli/src/app/core/i18n/en.js +819 -0
- package/dist/cli/src/app/core/i18n/es.js +822 -0
- package/dist/cli/src/app/core/i18n/ui-strings.js +11 -0
- package/dist/cli/src/app/core/i18n/ui.js +7 -0
- package/dist/cli/src/app/core/intake/bundle-graph.js +346 -0
- package/dist/cli/src/app/core/intake/bundle-graph.types.js +3 -0
- package/dist/cli/src/app/core/intake/dist-files.js +160 -0
- package/dist/cli/src/app/core/intake/index-html.js +292 -0
- package/dist/cli/src/app/core/json/json.utils.js +55 -0
- package/dist/cli/src/app/core/measurement/measurement.types.js +14 -0
- package/dist/cli/src/app/core/project/budget-advice.js +76 -0
- package/dist/cli/src/app/core/project/project-context.js +394 -0
- package/dist/cli/src/app/core/project/project-context.types.js +3 -0
- package/dist/cli/src/app/core/scan/catalog.js +67 -0
- package/dist/cli/src/app/core/scan/scan.js +280 -0
- package/dist/cli/src/app/core/scan/scan.types.js +10 -0
- package/dist/cli/src/app/core/scan/secrets.js +0 -0
- package/dist/cli/src/app/core/situation/situation.js +261 -0
- package/dist/cli/src/app/core/situation/situation.types.js +19 -0
- package/dist/cli/src/app/core/timing/timing.js +87 -0
- package/dist/cli/src/app/core/timing/timing.types.js +3 -0
- package/dist/cli/src/app/core/whatif/defer.js +68 -0
- package/dist/cli/src/app/state/report-messages.utils.js +73 -0
- package/docs/HOW-IT-WORKS.md +1087 -0
- package/loadline.html +78 -0
- package/package.json +154 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* "What would the first load weigh if this were behind an `import()`?"
|
|
4
|
+
*
|
|
5
|
+
* It turns the report into a bench: today you know `chart.js` is in the way, and what is missing is
|
|
6
|
+
* how much the bootstrap drops **before** anybody spends the afternoon.
|
|
7
|
+
*
|
|
8
|
+
* ---
|
|
9
|
+
*
|
|
10
|
+
* **What this does and does not compute, because the difference is the whole design.**
|
|
11
|
+
*
|
|
12
|
+
* Deferring something takes off the first load exactly what has no other way in — its exclusive
|
|
13
|
+
* weight — and that figure is *exact*. It is not an estimate and not a model: the graph is walked
|
|
14
|
+
* with those files removed, and what stops being reachable is what stops being downloaded.
|
|
15
|
+
*
|
|
16
|
+
* What it deliberately does **not** do is re-chunk the build. Which files end up in which chunk is
|
|
17
|
+
* the bundler's decision, taken with rules this tool does not have and should not guess at; a
|
|
18
|
+
* simulated split would produce a second set of round-trip counts and per-screen totals that look
|
|
19
|
+
* exactly like the measured ones and are not. So the round trips are not re-counted, the screen
|
|
20
|
+
* totals are not redrawn, and the result says so rather than showing a figure it cannot stand
|
|
21
|
+
* behind. What it gives instead is the one number the decision turns on, plus who would then be
|
|
22
|
+
* paying for it.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.simulateDefer = void 0;
|
|
26
|
+
const format_utils_1 = require("../format/format.utils");
|
|
27
|
+
/**
|
|
28
|
+
* @param name a package name, a project folder as the breakdown spells it, or a source path. It is
|
|
29
|
+
* matched in that order, which is the order of how specific the answer is.
|
|
30
|
+
*/
|
|
31
|
+
const simulateDefer = (analysis, name) => {
|
|
32
|
+
const insights = analysis.insights();
|
|
33
|
+
const byBucket = insights.filesByBucket.get(name);
|
|
34
|
+
const kind = byBucket
|
|
35
|
+
? analysis.bootBuckets.find(bucket => bucket.name === name)?.isProjectCode
|
|
36
|
+
? 'folder'
|
|
37
|
+
: 'package'
|
|
38
|
+
: 'file';
|
|
39
|
+
// A bucket of the breakdown is the common case and the files are already known. A path that is
|
|
40
|
+
// not one is matched as a file, and as a fallback as anything under that package or folder —
|
|
41
|
+
// so naming a package that is nowhere near the bootstrap still answers.
|
|
42
|
+
const files = byBucket ??
|
|
43
|
+
analysis.modules
|
|
44
|
+
.filter(module => module.path === name || (0, format_utils_1.packageOf)(module.path) === name || (0, format_utils_1.projectFolderOf)(module.path) === name)
|
|
45
|
+
.map(module => module.path);
|
|
46
|
+
const weight = files.reduce((sum, file) => {
|
|
47
|
+
const module = analysis.modules.find(entry => entry.path === file);
|
|
48
|
+
const boot = new Set(analysis.bootChunks);
|
|
49
|
+
return (sum + (module?.places.filter(place => boot.has(place.chunk)).reduce((n, place) => n + place.bytes, 0) ?? 0));
|
|
50
|
+
}, 0);
|
|
51
|
+
const saved = files.length > 0 ? insights.exclusiveOf(files) : 0;
|
|
52
|
+
const screenOf = new Map(analysis.screens.map(screen => [screen.source, screen.label]));
|
|
53
|
+
const importers = kind === 'package'
|
|
54
|
+
? [...(analysis.packageImporters.get(name) ?? [])]
|
|
55
|
+
: [...new Set(files.flatMap(file => [...(analysis.ownImporters.get(file) ?? [])]))];
|
|
56
|
+
return {
|
|
57
|
+
target: name,
|
|
58
|
+
kind,
|
|
59
|
+
files,
|
|
60
|
+
weight,
|
|
61
|
+
saved,
|
|
62
|
+
before: insights.bootTotal,
|
|
63
|
+
after: Math.max(0, insights.bootTotal - saved),
|
|
64
|
+
screens: importers.map(file => screenOf.get(file)).filter(label => label !== undefined),
|
|
65
|
+
importers,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.simulateDefer = simulateDefer;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The codes the core throws, as sentences a person reads.
|
|
4
|
+
*
|
|
5
|
+
* They are outside the store because they are a translation table and nothing else: no state, no
|
|
6
|
+
* signals, one string in and one string out. The store passes the strings of the current language.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.measurementMessage = exports.foreignMessage = exports.errorMessage = void 0;
|
|
10
|
+
const metafile_types_1 = require("../core/analysis/metafile.types");
|
|
11
|
+
const json_utils_1 = require("../core/json/json.utils");
|
|
12
|
+
/** Anything thrown while reading a `stats.json`, named when it is one of ours and quoted when not. */
|
|
13
|
+
const errorMessage = (error, t) => `${reason(error, t)} ${t.errExpected}`;
|
|
14
|
+
exports.errorMessage = errorMessage;
|
|
15
|
+
/**
|
|
16
|
+
* A JSON that is not a metafile, named by the format it actually is. It lives on its own because
|
|
17
|
+
* the command needs the same sentence: the page had it and the terminal printed "not an esbuild
|
|
18
|
+
* metafile" for a webpack stats.json, which is the one file people most often try.
|
|
19
|
+
*/
|
|
20
|
+
const foreignMessage = (format, t) => {
|
|
21
|
+
if (format === 'webpack') {
|
|
22
|
+
return t.errWebpackStats;
|
|
23
|
+
}
|
|
24
|
+
if (format === 'viteManifest') {
|
|
25
|
+
return t.errViteManifest;
|
|
26
|
+
}
|
|
27
|
+
if (format === 'visualizer') {
|
|
28
|
+
return t.errVisualizer;
|
|
29
|
+
}
|
|
30
|
+
return t.errNotMetafile;
|
|
31
|
+
};
|
|
32
|
+
exports.foreignMessage = foreignMessage;
|
|
33
|
+
/**
|
|
34
|
+
* Why the file did not work. Every answer is followed by what was expected instead: a JSON that is
|
|
35
|
+
* not a metafile at all and a metafile missing its `outputs` used to end in the same sentence, and
|
|
36
|
+
* neither of them said what a good file looks like.
|
|
37
|
+
*/
|
|
38
|
+
const reason = (error, t) => {
|
|
39
|
+
const code = error instanceof Error ? error.message : String(error);
|
|
40
|
+
if (code === 'NO_ENTRIES') {
|
|
41
|
+
return t.errNoEntries;
|
|
42
|
+
}
|
|
43
|
+
if (code === 'NO_MAIN') {
|
|
44
|
+
return t.errNoMain;
|
|
45
|
+
}
|
|
46
|
+
if (code === 'NO_OUTPUTS') {
|
|
47
|
+
return t.errNoOutputs;
|
|
48
|
+
}
|
|
49
|
+
if (code === 'NO_PAGE') {
|
|
50
|
+
return t.errNoPage;
|
|
51
|
+
}
|
|
52
|
+
if (code === 'NOT_ESM_GRAPH') {
|
|
53
|
+
return t.errNotEsmGraph;
|
|
54
|
+
}
|
|
55
|
+
if (code.startsWith('NOT_METAFILE:')) {
|
|
56
|
+
// The code is a string the core assembled, so the format it carries is read back against
|
|
57
|
+
// the formats that exist. A code naming one that does not gets the general sentence, which
|
|
58
|
+
// is what `foreignMessage` already answers for `unknown`.
|
|
59
|
+
const named = (0, json_utils_1.asMember)(code.slice('NOT_METAFILE:'.length), metafile_types_1.FOREIGN_FORMATS);
|
|
60
|
+
return (0, exports.foreignMessage)(named ?? 'unknown', t);
|
|
61
|
+
}
|
|
62
|
+
return code;
|
|
63
|
+
};
|
|
64
|
+
/** Why a pasted browser measurement could not be used. */
|
|
65
|
+
const measurementMessage = (error, t) => {
|
|
66
|
+
const messages = {
|
|
67
|
+
empty: t.measureErrEmpty,
|
|
68
|
+
noFiles: t.measureErrNoFiles,
|
|
69
|
+
noMatch: t.measureErrNoMatch,
|
|
70
|
+
};
|
|
71
|
+
return messages[error];
|
|
72
|
+
};
|
|
73
|
+
exports.measurementMessage = measurementMessage;
|