@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
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The advice that depends on the tool that wrote the build, in its own words.
|
|
4
|
+
*
|
|
5
|
+
* Each signal used to name Vite and Angular side by side — "`sourcemap: true` in Vite, `"sourceMap":
|
|
6
|
+
* true` in Angular" — which is right for two tools and noise for the rest: an Ember build was told
|
|
7
|
+
* to edit a Vite config it does not have. With the tool known (`analysis/tool.ts`) the advice is the
|
|
8
|
+
* one line that applies; without it, it is the two common ones, as before.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.webpackSplit = exports.mayBeAngular = exports.mapsHidden = exports.mapsOn = void 0;
|
|
12
|
+
const finding_html_1 = require("./finding-html");
|
|
13
|
+
const VITE_CONFIG = { en: 'vite.config', es: 'vite.config' };
|
|
14
|
+
/** Source maps on. */
|
|
15
|
+
const MAPS = {
|
|
16
|
+
angular: { code: '"sourceMap": true', where: { en: 'angular.json', es: 'angular.json' } },
|
|
17
|
+
nuxt: { code: 'sourcemap: { client: true }', where: { en: 'nuxt.config', es: 'nuxt.config' } },
|
|
18
|
+
stencil: {
|
|
19
|
+
code: 'sourceMap: true',
|
|
20
|
+
where: { en: 'stencil.config.ts (Stencil 2 or later)', es: 'stencil.config.ts (Stencil 2 o posterior)' },
|
|
21
|
+
},
|
|
22
|
+
ember: { code: 'sourcemaps: { enabled: true }', where: { en: 'ember-cli-build.js', es: 'ember-cli-build.js' } },
|
|
23
|
+
sapper: {
|
|
24
|
+
code: 'output.sourcemap: true',
|
|
25
|
+
where: { en: 'the client of rollup.config.js', es: 'el client de rollup.config.js' },
|
|
26
|
+
},
|
|
27
|
+
vite: { code: 'build.sourcemap: true', where: VITE_CONFIG },
|
|
28
|
+
webpack: {
|
|
29
|
+
code: "devtool: 'source-map'",
|
|
30
|
+
where: { en: 'the webpack configuration', es: 'la configuración de webpack' },
|
|
31
|
+
},
|
|
32
|
+
rollup: { code: 'output.sourcemap: true', where: { en: 'rollup.config.js', es: 'rollup.config.js' } },
|
|
33
|
+
esbuild: { code: '--sourcemap', where: { en: 'the esbuild command', es: 'el comando de esbuild' } },
|
|
34
|
+
};
|
|
35
|
+
/** Source maps written but not linked from the bundle: for an error tool, not for the public. */
|
|
36
|
+
const HIDDEN_MAPS = {
|
|
37
|
+
angular: {
|
|
38
|
+
code: '"sourceMap": { "scripts": true, "hidden": true }',
|
|
39
|
+
where: { en: 'angular.json', es: 'angular.json' },
|
|
40
|
+
},
|
|
41
|
+
nuxt: { code: "sourcemap: { client: 'hidden' }", where: { en: 'nuxt.config', es: 'nuxt.config' } },
|
|
42
|
+
sapper: { code: "output.sourcemap: 'hidden'", where: { en: 'rollup.config.js', es: 'rollup.config.js' } },
|
|
43
|
+
vite: { code: "build.sourcemap: 'hidden'", where: VITE_CONFIG },
|
|
44
|
+
webpack: {
|
|
45
|
+
code: "devtool: 'hidden-source-map'",
|
|
46
|
+
where: { en: 'the webpack configuration', es: 'la configuración de webpack' },
|
|
47
|
+
},
|
|
48
|
+
rollup: { code: "output.sourcemap: 'hidden'", where: { en: 'rollup.config.js', es: 'rollup.config.js' } },
|
|
49
|
+
esbuild: { code: '--sourcemap=external', where: { en: 'the esbuild command', es: 'el comando de esbuild' } },
|
|
50
|
+
};
|
|
51
|
+
/** The framework's own setting first — Angular on webpack is still `angular.json` — then the bundler's. */
|
|
52
|
+
const settingFor = (table, tool) => (tool?.framework ? table[tool.framework] : undefined) ?? (tool?.bundler ? table[tool.bundler] : undefined) ?? null;
|
|
53
|
+
const said = (setting, lang) => `${(0, finding_html_1.mono)(setting.code)} ${lang === 'es' ? 'en' : 'in'} ${setting.where[lang]}`;
|
|
54
|
+
/** "`build.sourcemap: true` in vite.config", or the two common ones when the tool is not known. */
|
|
55
|
+
const mapsOn = (tool, lang) => {
|
|
56
|
+
const setting = settingFor(MAPS, tool);
|
|
57
|
+
if (setting) {
|
|
58
|
+
return said(setting, lang);
|
|
59
|
+
}
|
|
60
|
+
return lang === 'es'
|
|
61
|
+
? `${(0, finding_html_1.mono)('sourcemap: true')} en Vite, ${(0, finding_html_1.mono)('"sourceMap": true')} en Angular`
|
|
62
|
+
: `${(0, finding_html_1.mono)('sourcemap: true')} in Vite, ${(0, finding_html_1.mono)('"sourceMap": true')} in Angular`;
|
|
63
|
+
};
|
|
64
|
+
exports.mapsOn = mapsOn;
|
|
65
|
+
/** The same for maps generated without being linked. */
|
|
66
|
+
const mapsHidden = (tool, lang) => {
|
|
67
|
+
const setting = settingFor(HIDDEN_MAPS, tool);
|
|
68
|
+
if (setting) {
|
|
69
|
+
return said(setting, lang);
|
|
70
|
+
}
|
|
71
|
+
return lang === 'es'
|
|
72
|
+
? `${(0, finding_html_1.mono)('"sourceMap": { "scripts": true, "hidden": true }')} en Angular, ${(0, finding_html_1.mono)("build.sourcemap: 'hidden'")} en Vite`
|
|
73
|
+
: `${(0, finding_html_1.mono)('"sourceMap": { "scripts": true, "hidden": true }')} in Angular, ${(0, finding_html_1.mono)("build.sourcemap: 'hidden'")} in Vite`;
|
|
74
|
+
};
|
|
75
|
+
exports.mapsHidden = mapsHidden;
|
|
76
|
+
/** Whether the build may be Angular's, which ships a `console` call in every build there is. */
|
|
77
|
+
const mayBeAngular = (tool) => !tool?.framework || tool.framework === 'angular';
|
|
78
|
+
exports.mayBeAngular = mayBeAngular;
|
|
79
|
+
/**
|
|
80
|
+
* How a webpack build splits its dependencies out, said first when the build is webpack's: the
|
|
81
|
+
* `manualChunks` the rest of the advice names is Rollup's. Angular up to 16 builds with webpack and
|
|
82
|
+
* has an option of its own for it.
|
|
83
|
+
*/
|
|
84
|
+
const webpackSplit = (tool, lang) => {
|
|
85
|
+
if (tool?.bundler !== 'webpack') {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
if (tool.framework === 'angular') {
|
|
89
|
+
return lang === 'es'
|
|
90
|
+
? `con ${(0, finding_html_1.mono)('"vendorChunk": true')} en angular.json, que el browser builder de Angular 16 o anterior tiene para eso; `
|
|
91
|
+
: `with ${(0, finding_html_1.mono)('"vendorChunk": true')} in angular.json, which the browser builder of Angular 16 or earlier has for it; `;
|
|
92
|
+
}
|
|
93
|
+
return lang === 'es'
|
|
94
|
+
? `en webpack con un grupo de ${(0, finding_html_1.mono)('optimization.splitChunks.cacheGroups')} para ${(0, finding_html_1.mono)('node_modules')}; `
|
|
95
|
+
: `in webpack with a group of ${(0, finding_html_1.mono)('optimization.splitChunks.cacheGroups')} for ${(0, finding_html_1.mono)('node_modules')}; `;
|
|
96
|
+
};
|
|
97
|
+
exports.webpackSplit = webpackSplit;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/** Presentation helpers and metafile path normalisation. */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.formatDelta = exports.elidePath = exports.screenLabel = exports.SOURCE_EXTENSION = exports.ROUTE_SUFFIXES = exports.VIEW_SUFFIXES = exports.projectFolderOf = exports.chainSteps = exports.packageOf = exports.shortName = exports.baseName = exports.formatCount = exports.formatBytes = exports.setUnitSpace = exports.setNumberLang = void 0;
|
|
4
|
+
exports.matchesStars = exports.namedBy = exports.formatDelta = exports.elidePath = exports.uniqueLabels = exports.screenLabel = exports.chunkLabel = exports.SOURCE_EXTENSION = exports.ROUTE_SUFFIXES = exports.VIEW_SUFFIXES = exports.projectFolderOf = exports.chainSteps = exports.packageOf = exports.shortName = exports.ANGULAR_BAZEL = exports.baseName = exports.formatCount = exports.formatBytesApart = exports.formatBytes = exports.setUnitSpace = exports.setNumberLang = void 0;
|
|
5
|
+
const ownership_1 = require("./ownership");
|
|
5
6
|
const KB = 1024;
|
|
6
7
|
/**
|
|
7
8
|
* The language the figures are written in. It only decides the decimal separator, and it is set
|
|
@@ -46,6 +47,17 @@ const formatBytes = (bytes) => {
|
|
|
46
47
|
return bytes >= KB ? `${Math.round(bytes / KB)}${space}kB` : `${bytes}${space}B`;
|
|
47
48
|
};
|
|
48
49
|
exports.formatBytes = formatBytes;
|
|
50
|
+
/**
|
|
51
|
+
* Two sizes that have to read as different: a figure and the limit it broke. Rounded alike they
|
|
52
|
+
* said "1 kB, over the 1 kB allowed" of 1,047 bytes against 1,024; then both are given in bytes.
|
|
53
|
+
*/
|
|
54
|
+
const formatBytesApart = (actual, limit) => {
|
|
55
|
+
const [a, b] = [(0, exports.formatBytes)(actual), (0, exports.formatBytes)(limit)];
|
|
56
|
+
return a === b && actual !== limit
|
|
57
|
+
? [`${(0, exports.formatCount)(actual)}${numbers.unitSpace}B`, `${(0, exports.formatCount)(limit)}${numbers.unitSpace}B`]
|
|
58
|
+
: [a, b];
|
|
59
|
+
};
|
|
60
|
+
exports.formatBytesApart = formatBytesApart;
|
|
49
61
|
/**
|
|
50
62
|
* A small figure that is not a size: releases a week, screens a session, times a week something
|
|
51
63
|
* gets paid for.
|
|
@@ -59,21 +71,52 @@ exports.formatCount = formatCount;
|
|
|
59
71
|
/** Last segment of a path: `chunk-ABC.js`, `login.page.ts`. */
|
|
60
72
|
const baseName = (path) => path.split('/').pop() ?? path;
|
|
61
73
|
exports.baseName = baseName;
|
|
74
|
+
/**
|
|
75
|
+
* Where Angular's own source maps point. Its packages are built with Bazel, and the maps they ship
|
|
76
|
+
* name the file in the Bazel output folder, not in the package: once a build composes them, a file
|
|
77
|
+
* of `@angular/forms` reads `node_modules/.pnpm/k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/…`
|
|
78
|
+
* (`bin/src/material/…` for the components repo). Read like any other path, that is a package
|
|
79
|
+
* called `.pnpm` — 72 kB of one real build's first load were — or, under npm, `k8-fastbuild-…`.
|
|
80
|
+
* Only a build read through its source maps meets it: a stats file names the `.mjs` in the package.
|
|
81
|
+
*/
|
|
82
|
+
exports.ANGULAR_BAZEL = /^.*node_modules\/(?:\.pnpm\/)?[\w-]+-(?:fastbuild|opt|dbg)(?:-ST-[\da-f]+)?\/bin\/(?:packages|src)\//;
|
|
62
83
|
/**
|
|
63
84
|
* Strips the `node_modules` noise to leave the name a package is recognised by.
|
|
64
85
|
* pnpm adds an extra segment (`.pnpm/pkg@version/node_modules/`) that has to be skipped first.
|
|
65
86
|
*/
|
|
66
|
-
const shortName = (path) =>
|
|
87
|
+
const shortName = (path) => {
|
|
88
|
+
// What is yours is named by its path, wherever it sits; what `loadline.json` calls a dependency
|
|
89
|
+
// by the package it makes (`ownership.ts`).
|
|
90
|
+
if (!(0, ownership_1.isDependency)(path)) {
|
|
91
|
+
return path;
|
|
92
|
+
}
|
|
93
|
+
const declared = (0, ownership_1.declaredPackage)(path);
|
|
94
|
+
if (declared) {
|
|
95
|
+
return declared.rest ? `${declared.name}/${declared.rest}` : declared.name;
|
|
96
|
+
}
|
|
97
|
+
return path
|
|
98
|
+
.replace(exports.ANGULAR_BAZEL, '@angular/')
|
|
99
|
+
.replace(/^.*node_modules\/\.pnpm\/[^/]+\/node_modules\//, '')
|
|
100
|
+
.replace(/^.*node_modules\//, '');
|
|
101
|
+
};
|
|
67
102
|
exports.shortName = shortName;
|
|
68
103
|
/** Name of the npm package a path belongs to, or `null` if it is project code. */
|
|
69
104
|
const packageOf = (path) => {
|
|
70
|
-
|
|
71
|
-
if (short === path) {
|
|
105
|
+
if (!(0, ownership_1.isDependency)(path)) {
|
|
72
106
|
return null;
|
|
73
107
|
}
|
|
108
|
+
const declared = (0, ownership_1.declaredPackage)(path);
|
|
109
|
+
if (declared) {
|
|
110
|
+
return declared.name;
|
|
111
|
+
}
|
|
112
|
+
const short = (0, exports.shortName)(path);
|
|
74
113
|
const parts = short.split('/');
|
|
75
114
|
const head = parts[0] ?? short;
|
|
76
|
-
|
|
115
|
+
// A file straight in `node_modules/` or in a scope is a package of one file, resolved by name:
|
|
116
|
+
// Sapper's `@sapper/app.mjs` is `@sapper/app`, not a package called `@sapper/app.mjs`.
|
|
117
|
+
const scoped = head.startsWith('@');
|
|
118
|
+
const name = scoped ? parts.slice(0, 2).join('/') : head;
|
|
119
|
+
return parts.length === (scoped ? 2 : 1) ? name.replace(/\.[cm]?js$/, '') : name;
|
|
77
120
|
};
|
|
78
121
|
exports.packageOf = packageOf;
|
|
79
122
|
/**
|
|
@@ -144,7 +187,14 @@ exports.ROUTE_SUFFIXES = ['route', 'routes'];
|
|
|
144
187
|
* listed as `orders.page.vue`, extension and all.
|
|
145
188
|
*/
|
|
146
189
|
exports.SOURCE_EXTENSION = '(?:[tj]sx?|vue|svelte)';
|
|
147
|
-
|
|
190
|
+
/**
|
|
191
|
+
* What Angular up to 8 starts a lazy route at: `loadChildren: './article/article.module#…'` makes a
|
|
192
|
+
* chunk of `article.module.ngfactory.js` (or of `article.module.ts` without AOT), and an Angular 8
|
|
193
|
+
* build read through its webpack stats listed its screens as `article.module.ngfactory`. Only for
|
|
194
|
+
* the name: a module is no view, and the rules that tell screens from pieces of them never read it.
|
|
195
|
+
*/
|
|
196
|
+
const LAZY_MODULE_SUFFIXES = [String.raw `module\.ngfactory`, 'module'];
|
|
197
|
+
const SUFFIX = new RegExp(String.raw `\.(?:${[...exports.VIEW_SUFFIXES, ...exports.ROUTE_SUFFIXES, ...LAZY_MODULE_SUFFIXES].join('|')})\.${exports.SOURCE_EXTENSION}$`);
|
|
148
198
|
const EXTENSION = new RegExp(String.raw `\.${exports.SOURCE_EXTENSION}$`);
|
|
149
199
|
/**
|
|
150
200
|
* SvelteKit names a route file by its role and the route by its folder: `+page.svelte` in every
|
|
@@ -153,20 +203,88 @@ const EXTENSION = new RegExp(String.raw `\.${exports.SOURCE_EXTENSION}$`);
|
|
|
153
203
|
const ROLE_PREFIX = '+';
|
|
154
204
|
/** Folders that are the root of the routes rather than one route: there the file name is all there is. */
|
|
155
205
|
const ROUTE_ROOTS = new Set(['routes', 'pages', 'app', 'src']);
|
|
206
|
+
/** A route parameter written into a file name: `[id]`, `[...slug]`, `_id` (Nuxt 2), `$id` (Remix). */
|
|
207
|
+
const DYNAMIC_SEGMENT = /^(?:\[[^\]]+\]|[_$]\w+)$/;
|
|
208
|
+
/**
|
|
209
|
+
* A screen known only by its chunk — a folder read without source maps — named the way its bundler
|
|
210
|
+
* named the chunk, without the hash: `Article-BZRh73np.js` → `Article`. Rollup, Vite and esbuild
|
|
211
|
+
* name a chunk after the module it starts at and append eight characters, and on a real Vue build the
|
|
212
|
+
* table read `Article-BZRh73np` while a signal said every row was a hash nobody could read. A name
|
|
213
|
+
* that is only a hash stays one, and so does Angular's `chunk-`, which names nothing.
|
|
214
|
+
*/
|
|
215
|
+
const chunkLabel = (chunk) => {
|
|
216
|
+
const stem = (0, exports.baseName)(chunk).replace(/\.m?js$/i, '');
|
|
217
|
+
// `-` and eight characters is Rollup, Vite and esbuild; `.` and a hex hash is Rollup 1 and the
|
|
218
|
+
// bundlers of its time — Sapper's table read `index.e902f999` and `index.62e5829d`.
|
|
219
|
+
const named = stem.replace(/-[\w-]{8}$/, '').replace(/\.[\da-f]{8,}$/i, '');
|
|
220
|
+
// A letter names nothing either: Stencil calls every chunk `p-3b66a627`, and its polyfills
|
|
221
|
+
// were listed as "p, p, p".
|
|
222
|
+
return named.length > 1 && named !== stem && named.toLowerCase() !== 'chunk' ? named : stem;
|
|
223
|
+
};
|
|
224
|
+
exports.chunkLabel = chunkLabel;
|
|
156
225
|
/**
|
|
157
226
|
* Readable screen name from the file it originates from.
|
|
158
227
|
* `features/users/users.page.ts` -> `users`
|
|
159
228
|
* `src/routes/orders/+page.svelte` -> `orders`
|
|
229
|
+
*
|
|
230
|
+
* @param chunk the chunk the screen starts at. When it is the source too, the folder said nothing
|
|
231
|
+
* finer — no source map — and the chunk's own name is all there is: see `chunkLabel`.
|
|
160
232
|
*/
|
|
161
|
-
const screenLabel = (source) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return name;
|
|
233
|
+
const screenLabel = (source, chunk) => {
|
|
234
|
+
if (source === chunk) {
|
|
235
|
+
return (0, exports.chunkLabel)(chunk);
|
|
165
236
|
}
|
|
237
|
+
const name = (0, exports.baseName)(source).replace(SUFFIX, '').replace(EXTENSION, '') || (0, exports.baseName)(source);
|
|
166
238
|
const folder = source.split('/').at(-2) ?? '';
|
|
167
|
-
|
|
239
|
+
const routed = folder && !ROUTE_ROOTS.has(folder);
|
|
240
|
+
if (name.startsWith(ROLE_PREFIX)) {
|
|
241
|
+
return routed ? folder : name.slice(1);
|
|
242
|
+
}
|
|
243
|
+
// File-system routing names a route by its folder too: `pages/movie/index.vue` is `movie`, and
|
|
244
|
+
// `pages/movie/[id].vue` is `movie/[id]`. On their own, a Nuxt app's table had `index` twice
|
|
245
|
+
// and `[id]` twice, and its gate messages said "Screen index downloads 191 kB" about two
|
|
246
|
+
// different screens.
|
|
247
|
+
// Under a parameter, the route is the path: `genre/[no]/movie` is not the `movie` screen. Asked
|
|
248
|
+
// before `index`, or Sapper's `profile/[user]/index.svelte` came out as `[user]` next to its own
|
|
249
|
+
// sibling `profile/[user]/[view]`.
|
|
250
|
+
if (routed && DYNAMIC_SEGMENT.test(folder)) {
|
|
251
|
+
return routeOf(source) ?? name;
|
|
252
|
+
}
|
|
253
|
+
if (name === 'index' && routed) {
|
|
254
|
+
return folder;
|
|
255
|
+
}
|
|
256
|
+
return DYNAMIC_SEGMENT.test(name) && routed ? `${folder}/${name}` : name;
|
|
168
257
|
};
|
|
169
258
|
exports.screenLabel = screenLabel;
|
|
259
|
+
/** The path of a file below the root of the routes, without its extension or a trailing `index`. */
|
|
260
|
+
const routeOf = (source) => {
|
|
261
|
+
const parts = source.replace(SUFFIX, '').replace(EXTENSION, '').split('/');
|
|
262
|
+
const root = parts.findLastIndex(part => ROUTE_ROOTS.has(part));
|
|
263
|
+
const route = parts.slice(root + 1).filter(part => part !== 'index');
|
|
264
|
+
return route.length > 0 ? route.join('/') : null;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* The same labels made unique where two screens share one, by the folders above each, up to the
|
|
268
|
+
* root of the routes: `movie` and `genre/[no]/movie`. One that is unique already is left as it is.
|
|
269
|
+
*/
|
|
270
|
+
const uniqueLabels = (screens, isChunk = () => false) => {
|
|
271
|
+
const count = new Map();
|
|
272
|
+
for (const screen of screens) {
|
|
273
|
+
count.set(screen.label, (count.get(screen.label) ?? 0) + 1);
|
|
274
|
+
}
|
|
275
|
+
return screens.map(screen => {
|
|
276
|
+
if ((count.get(screen.label) ?? 0) < 2) {
|
|
277
|
+
return screen;
|
|
278
|
+
}
|
|
279
|
+
// A screen known only by its chunk has no folders to tell it apart by, only its hash: two
|
|
280
|
+
// Sapper `[slug]` read `client/[slug].df9e6d95`, the folder of the build and not of a route.
|
|
281
|
+
const longer = isChunk(screen.source)
|
|
282
|
+
? (0, exports.baseName)(screen.source).replace(/\.m?js$/i, '')
|
|
283
|
+
: routeOf(screen.source);
|
|
284
|
+
return longer && longer !== screen.label ? { ...screen, label: longer } : screen;
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
exports.uniqueLabels = uniqueLabels;
|
|
170
288
|
/**
|
|
171
289
|
* A path shortened to fit a table cell by dropping middle folders, never by cutting a word in two.
|
|
172
290
|
*
|
|
@@ -209,3 +327,32 @@ exports.elidePath = elidePath;
|
|
|
209
327
|
*/
|
|
210
328
|
const formatDelta = (diff) => `${diff >= 0 ? '+' : '−'}${(0, exports.formatBytes)(Math.abs(diff))}`;
|
|
211
329
|
exports.formatDelta = formatDelta;
|
|
330
|
+
/**
|
|
331
|
+
* Whether a pattern of `loadline.json` names a file: the whole name, or with `*` standing for any
|
|
332
|
+
* text — the hash, a folder. Matched against the file name and against its path in the folder, so `client.*.js` and
|
|
333
|
+
* `build/p-*.js` both work. Matched by hand rather than turned into a regular expression: the
|
|
334
|
+
* pattern is somebody's text, and a regular expression built from it is one more thing to get wrong.
|
|
335
|
+
*/
|
|
336
|
+
const namedBy = (pattern, path) => [(0, exports.baseName)(path), path].some(name => (0, exports.matchesStars)(pattern, name));
|
|
337
|
+
exports.namedBy = namedBy;
|
|
338
|
+
/** Whether `text` is `pattern` whole, with `*` standing for any text. The matcher `namedBy` uses. */
|
|
339
|
+
const matchesStars = (pattern, text) => {
|
|
340
|
+
const [first = '', ...rest] = pattern.split('*');
|
|
341
|
+
if (rest.length === 0) {
|
|
342
|
+
return text === first;
|
|
343
|
+
}
|
|
344
|
+
const last = rest.pop() ?? '';
|
|
345
|
+
if (!text.startsWith(first) || !text.endsWith(last) || text.length < first.length + last.length) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
let at = first.length;
|
|
349
|
+
for (const part of rest) {
|
|
350
|
+
const found = text.indexOf(part, at);
|
|
351
|
+
if (found === -1) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
at = found + part.length;
|
|
355
|
+
}
|
|
356
|
+
return at <= text.length - last.length;
|
|
357
|
+
};
|
|
358
|
+
exports.matchesStars = matchesStars;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Yours or theirs: the one place that decides whether a file is the project's own code or a
|
|
4
|
+
* dependency, and what the dependency is called.
|
|
5
|
+
*
|
|
6
|
+
* It was a dozen `includes('node_modules')` across the analysis, the scan and the command, each
|
|
7
|
+
* written for the case in front of it, and `packageOf` beside them. Two builds showed where that
|
|
8
|
+
* ends. Sapper keeps an application's own modules in `src/node_modules/` so they import by name —
|
|
9
|
+
* the RealWorld app's `api.js` and `utils.js` — and they came out as packages. And a monorepo's
|
|
10
|
+
* `packages/ui` is a dependency of the app in every sense but where it sits, and came out as yours.
|
|
11
|
+
*
|
|
12
|
+
* The default is `node_modules/`, with Sapper's convention read; `build.own` and
|
|
13
|
+
* `build.dependencies` of `loadline.json` say the rest for a project (`setOwnership`). Like the
|
|
14
|
+
* language of the figures, it is set once from outside — by the command when it reads the file, by
|
|
15
|
+
* the page when one is dropped — because it is asked from everywhere a path is named.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.declaredPackage = exports.isOwnFile = exports.isDependency = exports.setOwnership = void 0;
|
|
19
|
+
const rules = { own: [], dependencies: [] };
|
|
20
|
+
/**
|
|
21
|
+
* `packages/*` matches `packages/ui/src/x.ts` and captures `packages/ui`: `*` is one segment or a
|
|
22
|
+
* part of one, `**` any number of them. The capture is what names a dependency.
|
|
23
|
+
*/
|
|
24
|
+
const ruleOf = (pattern) => {
|
|
25
|
+
const source = pattern
|
|
26
|
+
.replace(/^\.?\//, '')
|
|
27
|
+
.replace(/\/+$/, '')
|
|
28
|
+
.split('**')
|
|
29
|
+
.map(part => part
|
|
30
|
+
.split('*')
|
|
31
|
+
.map(text => text.replaceAll(/[$()+.?[\\\]^{|}]/g, String.raw `\$&`))
|
|
32
|
+
.join('[^/]*'))
|
|
33
|
+
.join('.*');
|
|
34
|
+
return { pattern, at: new RegExp(`^(${source})(?:/|$)`) };
|
|
35
|
+
};
|
|
36
|
+
/** The project's own words on it, from `build.own` and `build.dependencies`; `null` clears them. */
|
|
37
|
+
const setOwnership = (hints) => {
|
|
38
|
+
rules.own = (hints?.own ?? []).map(pattern => ruleOf(pattern));
|
|
39
|
+
rules.dependencies = (hints?.dependencies ?? []).map(pattern => ruleOf(pattern));
|
|
40
|
+
};
|
|
41
|
+
exports.setOwnership = setOwnership;
|
|
42
|
+
/**
|
|
43
|
+
* Sapper's convention: `src/node_modules/` holds the application's own modules, importable by name,
|
|
44
|
+
* and `src/node_modules/@sapper/` the runtime Sapper writes there, which is the framework's. A
|
|
45
|
+
* package's own `node_modules` further in is a package again.
|
|
46
|
+
*/
|
|
47
|
+
const isSapperOwn = (path) => {
|
|
48
|
+
const marker = 'src/node_modules/';
|
|
49
|
+
const at = path.indexOf(marker);
|
|
50
|
+
if (at === -1 || (at > 0 && path[at - 1] !== '/')) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const inside = path.slice(at + marker.length);
|
|
54
|
+
return !inside.startsWith('@sapper/') && !inside.includes('node_modules/');
|
|
55
|
+
};
|
|
56
|
+
/** The part of the path a `build.dependencies` pattern matched, when one did. */
|
|
57
|
+
const declaredDependency = (path) => {
|
|
58
|
+
for (const rule of rules.dependencies) {
|
|
59
|
+
const match = rule.at.exec(path);
|
|
60
|
+
if (match?.[1]) {
|
|
61
|
+
return match[1];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
/** Whether a source file is a dependency rather than the project's own code. */
|
|
67
|
+
const isDependency = (path) => {
|
|
68
|
+
// `build.own` first: it wins over a dependency pattern that matches the same file.
|
|
69
|
+
const own = rules.own.some(rule => rule.at.test(path));
|
|
70
|
+
return !own && (declaredDependency(path) !== null || (path.includes('node_modules/') && !isSapperOwn(path)));
|
|
71
|
+
};
|
|
72
|
+
exports.isDependency = isDependency;
|
|
73
|
+
/** The opposite, for the many places that ask it that way round. */
|
|
74
|
+
const isOwnFile = (path) => !(0, exports.isDependency)(path);
|
|
75
|
+
exports.isOwnFile = isOwnFile;
|
|
76
|
+
/**
|
|
77
|
+
* What a `build.dependencies` pattern makes of a path: the package name — the last segment of what
|
|
78
|
+
* the pattern matched, or the last two when they are a scope and a name — and the rest. `null`
|
|
79
|
+
* when no pattern matched.
|
|
80
|
+
*/
|
|
81
|
+
const declaredPackage = (path) => {
|
|
82
|
+
const prefix = declaredDependency(path);
|
|
83
|
+
if (!prefix || rules.own.some(rule => rule.at.test(path))) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const segments = prefix.split('/');
|
|
87
|
+
const scoped = segments.at(-2)?.startsWith('@') === true;
|
|
88
|
+
return {
|
|
89
|
+
name: segments.slice(scoped ? -2 : -1).join('/'),
|
|
90
|
+
rest: path.slice(prefix.length).replace(/^\//, ''),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
exports.declaredPackage = declaredPackage;
|
|
@@ -49,7 +49,7 @@ exports.EN = {
|
|
|
49
49
|
compareVersionsHelp: 'Read from the installed path, which only pnpm writes the version into. With npm or yarn the column is empty because nothing could be read — which is not the same as the versions agreeing.',
|
|
50
50
|
compareVersionUnknown: 'not readable',
|
|
51
51
|
compareVersionsNote: 'No installed path carried a version, so the versions could not be read at all. That is a gap in what these files say, not a finding that everything agrees: pnpm writes the version into the path, npm and yarn do not.',
|
|
52
|
-
compareRejected: files => `Not a build: ${files.join(', ')}. Each file has to be a stats.json (an esbuild metafile).`,
|
|
52
|
+
compareRejected: files => `Not a build: ${files.join(', ')}. Each file has to be a stats.json (an esbuild metafile or webpack's stats).`,
|
|
53
53
|
secCriteria: 'Rating criteria',
|
|
54
54
|
secCriteriaSub: 'The thresholds behind “good”, “fair” and “bad”, and the ones that fire each signal. You can change them.',
|
|
55
55
|
howToCriteria: '<p>Every rated figure in the report is compared against two thresholds: up to the first it is <strong>good</strong>, up to the second <strong>fair</strong>, above that <strong>bad</strong>. The criteria in the second and third sections are the ones that fire the signals.</p><p><strong>Where the recommended values come from.</strong> With compressed figures, 170 kB of initial JavaScript is the usual budget for a page to become responsive within a few seconds on a mid-range phone; 350 kB is twice that. With raw figures, 500 kB and 1 MB are the values Angular CLI writes by default into <code>angular.json</code>. Per-screen and own-code values are multiples of those. Signal thresholds that are proportions — coverage, number of importers — do not depend on the unit. The ones that are sizes do: a 50 kB minimum applied to compressed figures is three times stricter than the same minimum in raw, so they scale down with everything else.</p><p>Whatever you change is stored in this browser, separately for raw and compressed, and applies immediately to ratings and signals. A value equal to the recommended one stops counting as custom.</p>',
|
|
@@ -230,14 +230,14 @@ exports.EN = {
|
|
|
230
230
|
searchKeys: 'Ctrl K',
|
|
231
231
|
homeAria: 'Loadline: change what is loaded',
|
|
232
232
|
buildChipHelp: 'Change what is loaded',
|
|
233
|
-
intakeRequired: 'required',
|
|
233
|
+
intakeRequired: 'required · one of the two',
|
|
234
234
|
intakeOptional: 'Optional · each one adds detail, now or later',
|
|
235
235
|
intakeBack: 'Back to the report',
|
|
236
236
|
contextRawNote: 'Raw figures: bytes on disk, not what travels',
|
|
237
237
|
contextAddDetail: 'Add detail:',
|
|
238
238
|
contextAddDist: 'browser/ folder → compressed figures',
|
|
239
239
|
contextAddBaseline: 'baseline → compare',
|
|
240
|
-
contextAddContext: '
|
|
240
|
+
contextAddContext: 'package.json + angular.json → name, budgets',
|
|
241
241
|
heroCaptionBoot: boot => `${boot} the bundler marks as initial`,
|
|
242
242
|
heroCaptionExtra: (extra, chunks, ratio) => `${extra} in ${chunks === 1 ? 'one chunk' : `${chunks} chunks`} marked lazy that at least ${(0, ui_strings_1.pct)(ratio)} of the screens load anyway.`,
|
|
243
243
|
heroCaptionSame: 'No lazy chunk is loaded by enough screens to add to it.',
|
|
@@ -270,9 +270,10 @@ exports.EN = {
|
|
|
270
270
|
keyClose: 'Close this, and close an open explanation',
|
|
271
271
|
keyHelp: 'This list',
|
|
272
272
|
keyTabs: 'Between tabs, with a tab focused',
|
|
273
|
-
drop1Title: 'Drop your stats.json here',
|
|
274
|
-
drop1Body: '
|
|
273
|
+
drop1Title: 'Drop your build folder or its stats.json here',
|
|
274
|
+
drop1Body: 'The build folder is enough for anything that emits ES modules — Vite, Rollup, SvelteKit, Nuxt, Astro, esbuild — because its chunks carry the import graph. Angular writes a <code>stats.json</code> with <code>ng build --stats-json</code>, esbuild a <code>metafile</code> and webpack its stats with <code>--json</code> — Angular 16 or earlier, Create React App, Vue CLI — and any of them is more exact than the folder alone. It is processed in your browser: nothing leaves your machine.',
|
|
275
275
|
drop1Btn: 'Choose stats.json',
|
|
276
|
+
drop1FolderBtn: 'Choose build folder',
|
|
276
277
|
sampleBtn: 'See an example',
|
|
277
278
|
sampleLoaded: outputs => `Example build · ${outputs} outputs · not your project`,
|
|
278
279
|
sampleRemove: 'Close the example',
|
|
@@ -288,7 +289,7 @@ exports.EN = {
|
|
|
288
289
|
statsIdle: 'Nothing loaded',
|
|
289
290
|
distIdle: 'Nothing loaded · raw figures',
|
|
290
291
|
statsLoaded: (name, outputs) => `${name} · ${outputs} outputs`,
|
|
291
|
-
statsFromFolder: (name, outputs) => `${name} · ${outputs} chunks · graph read from the folder`,
|
|
292
|
+
statsFromFolder: (name, outputs, opaque) => `${name} · ${outputs} chunks · graph read from the folder${opaque ? ' · no source maps: what is inside each chunk, and so any saving, cannot be measured' : ''}`,
|
|
292
293
|
statsError: message => `Could not read it: ${message}`,
|
|
293
294
|
distNoFiles: 'That folder has no build output in it',
|
|
294
295
|
distNoApi: 'Your browser cannot compress here; keeping raw figures',
|
|
@@ -298,15 +299,37 @@ exports.EN = {
|
|
|
298
299
|
distLoadedMaps: (files, maps) => `${files} files · compressed figures · ${maps} source maps read`,
|
|
299
300
|
distLoadedBrotli: 'real brotli from the .br files',
|
|
300
301
|
distLoadedIndex: 'index.html read',
|
|
302
|
+
distTextUnread: 'restored without the text of the chunks: drop the folder again to search it for secrets and leftovers',
|
|
301
303
|
splitExact: 'split from the source maps',
|
|
302
304
|
splitApprox: 'split from the metafile',
|
|
303
305
|
serverIgnored: n => `${n === 1 ? '1 server output' : `${n} server outputs`} left out`,
|
|
304
|
-
serverIgnoredHelp: '
|
|
306
|
+
serverIgnoredHelp: 'Outputs of the build that are not in the browser folder: almost always the server bundle (server-side rendering), which nobody downloads and is usually the larger of the two, so only the browser side is analysed. It can also be a file renamed after it was built, like the es5 polyfills of Angular 8, which nobody downloads under that name.',
|
|
307
|
+
offPageIgnored: ({ legacy, serviceWorker, server, ignored }) => `${[
|
|
308
|
+
legacy > 0 && `${legacy === 1 ? '1 file' : `${legacy} files`} for browsers without ES modules`,
|
|
309
|
+
serviceWorker > 0 && (serviceWorker === 1 ? 'the service worker' : `${serviceWorker} service worker files`),
|
|
310
|
+
server > 0 && `${server === 1 ? '1 file' : `${server} files`} only the server runs`,
|
|
311
|
+
ignored > 0 && `${ignored === 1 ? '1 file' : `${ignored} files`} loadline.json ignores`,
|
|
312
|
+
]
|
|
313
|
+
.filter(Boolean)
|
|
314
|
+
.join(' and ')} left out`,
|
|
315
|
+
offPageIgnoredHelp: 'Only a browser that cannot run ES modules downloads the nomodule copy, a service worker runs beside the page rather than as part of a screen, the files of FastBoot run on the server, and build.ignore in loadline.json names what the team says no screen downloads. None of them is in any figure here, so every figure is what a current browser downloads.',
|
|
305
316
|
notScreensLabel: 'Not counted as screens:',
|
|
306
|
-
notScreenKind: {
|
|
317
|
+
notScreenKind: {
|
|
318
|
+
block: 'lazy block inside a screen',
|
|
319
|
+
grouper: 'route group',
|
|
320
|
+
data: 'data',
|
|
321
|
+
package: 'package on demand',
|
|
322
|
+
worker: 'web worker',
|
|
323
|
+
onDemand: 'no route opens it',
|
|
324
|
+
},
|
|
307
325
|
blocksHelp: 'An Angular @defer, or a lazy() inside a component, produces a lazy chunk exactly like a route does. It is not a screen: nobody enters it, it loads when its trigger fires inside the screen holding it. Counting it as a screen would raise the screen count and lower the median with something nobody opens. What the graph cannot say is WHEN that trigger fires: a block behind a button really is bytes nobody pays for until they press it, while one imported as the screen mounts comes down with the first paint, and then the screen weighs more than its row says. Both look identical here. The Measured tab is what settles it.',
|
|
308
326
|
groupersHelp: 'A file that adds practically nothing of its own to its chunk and holds nothing but dynamic imports is grouping routes, whatever it is called. What it loads are the screens; it is not one of them. That is measured rather than read off the file name, so it also holds in a project that does not name its files the Angular way.',
|
|
309
327
|
dataHelp: 'A language file, a table of countries, a dictionary: an import() of a .json produces a lazy chunk exactly like a route does. Nobody navigates to one, and an application that lazy-loads fifty languages would otherwise report fifty screens. What to do about these is not "is this a screen" but whether the data has to travel inside the bundle at all.',
|
|
328
|
+
packagesHelp: "A package with an import() of its own: a diagram renderer, a formula typesetter. Nobody navigates to it, and when it is asked for is what the graph cannot say, so it is in no screen's total.",
|
|
329
|
+
workersHelp: 'Code started with new Worker(): it runs off the page, in a chunk of its own, when the page starts it. Not a screen and not in any total.',
|
|
330
|
+
onDemandHelp: 'The code carries a route table, and no route of it imports this chunk: it is a component, a tab or a language file loaded inside a page, not a place somebody navigates to. If it is a route all the same, count it as a screen.',
|
|
331
|
+
noRouteTable: 'No route table was found in the code, so every chunk loaded lazily counts as a screen: some of these may be tabs or components inside a page rather than places somebody navigates to.',
|
|
332
|
+
routeCss: (count, list) => `Screens also load ${count === 1 ? 'a stylesheet' : `${count} stylesheets`} of their own (${list}), not in their totals: the figures here are JavaScript.`,
|
|
310
333
|
markScreen: 'Count as a screen',
|
|
311
334
|
markScreenHelp: 'Puts this entry in the table as a screen of its own. Telling a screen from a piece of one is partly read off file names, and no set of names fits every project: this is the way out that does not need Loadline to learn yours.',
|
|
312
335
|
markBlock: 'Not a screen',
|
|
@@ -319,13 +342,12 @@ exports.EN = {
|
|
|
319
342
|
rereadBtn: 'Read the folder again',
|
|
320
343
|
rereadHelp: 'Reads the same build folder again, for after a rebuild. It is offered only where the browser can hold on to a folder, which is not from a file:// page and not in every browser; everywhere else, drop the folder again.',
|
|
321
344
|
drop3Title: 'The previous measurement',
|
|
322
|
-
drop3Body: 'The <code>stats.json</code> of the previous build, an analysis exported from Loadline, or the whole previous <code>browser/</code> folder
|
|
345
|
+
drop3Body: 'The <code>stats.json</code> of the previous build, an analysis exported from Loadline, or the whole previous <code>browser/</code> folder — with its <code>stats.json</code> or without one, the way the build on screen is read — to compare compressed figures. Every screen shows how much it changed, and a signal fires if something grew or entered the bootstrap.',
|
|
323
346
|
drop3Btn: 'Choose baseline',
|
|
324
347
|
drop3BtnDist: 'Choose previous folder',
|
|
325
|
-
baselineNoStats: 'The folder has no stats.json in it.',
|
|
326
348
|
baselineWorking: 'Compressing the previous folder…',
|
|
327
349
|
drop4Title: 'The project context',
|
|
328
|
-
drop4Body: '<code>
|
|
350
|
+
drop4Body: '<code>package.json</code> names the project and says what it asks for directly, which tells a package you chose from one that came along. On an Angular project, <code>angular.json</code> and the pipeline file (<code>.gitlab-ci.yml</code> or the GitHub workflow) also say where the size budget is and whether the configuration the pipeline builds applies it.',
|
|
329
351
|
drop4Btn: 'Choose files',
|
|
330
352
|
baselineIdle: 'Nothing loaded · no comparison',
|
|
331
353
|
baselineLoaded: (name, mode, screens) => `${name} · ${mode} · ${screens} screens`,
|
|
@@ -337,6 +359,8 @@ exports.EN = {
|
|
|
337
359
|
contextLoaded: files => files.join(' · '),
|
|
338
360
|
contextIgnored: files => `Not recognised: ${files.join(', ')}`,
|
|
339
361
|
contextShort: n => (n === 1 ? 'context: 1 file' : `context: ${n} files`),
|
|
362
|
+
configExtends: names => `loadline.json extends ${names}, which the page cannot read`,
|
|
363
|
+
configExtendsHelp: 'The page has no disk to follow "extends" on, so it applies only what this file says itself. Run npx @bymaksym/loadline --print-config and drop what it prints here instead: that is the file with everything it extends joined in.',
|
|
340
364
|
contextRemove: 'Remove context',
|
|
341
365
|
restorePrompt: (name, date) => `This browser kept the last measurement: ${name} · ${date}`,
|
|
342
366
|
restoreBtn: 'Restore',
|
|
@@ -423,6 +447,7 @@ exports.EN = {
|
|
|
423
447
|
tileBoot: 'Declared bootstrap',
|
|
424
448
|
tileBootCss: (size, files, total) => `+ ${size} of CSS the page asks for${files > 1 ? ` in ${files} sheets` : ''} · ${total} before the first paint`,
|
|
425
449
|
bootSplitRaw: total => `Packages and your code are split in raw bytes, ${total} in all: a compressed file cannot be divided by what is inside it.`,
|
|
450
|
+
bootSplitUnknown: 'How much of it is packages and how much is your code is not known: the folder carries no source maps, so a chunk is a weight with nothing named inside. Build with source maps, or add the stats.json, to see the split.',
|
|
426
451
|
tileBootSub: files => `what the bundler marks as initial · ${files === 1 ? '1 file' : `${files} files`}`,
|
|
427
452
|
tileScreens: 'Lazy screens',
|
|
428
453
|
tileScreensTypical: 'the typical one costs',
|
|
@@ -795,6 +820,7 @@ exports.EN = {
|
|
|
795
820
|
helpBootPercent: 'The share of the bootstrap this entry takes.',
|
|
796
821
|
helpBootOfBoot: 'of the bootstrap',
|
|
797
822
|
helpBootLazyOnly: max => `At most ${max} files of yours import it and at least one is in a lazy screen, so they can be checked one by one. If they all turn out to be lazy, this package downloads on the first load for people who may never reach that screen.`,
|
|
823
|
+
helpImportsUnknown: 'Not known: a build folder says what each chunk carries, not which file imports which. The stats.json says it.',
|
|
798
824
|
helpImportersNone: 'No file of yours imports it directly: another package imports it. It is not removed from your code but from the package that brings it.',
|
|
799
825
|
bootChain: 'How it enters the bootstrap',
|
|
800
826
|
bootChainNone: 'Could not be followed from the entry point over static imports.',
|
|
@@ -866,14 +892,47 @@ exports.EN = {
|
|
|
866
892
|
noScreens: 'No lazy screens found. The whole app is in the bootstrap.',
|
|
867
893
|
noShared: 'No lazy chunk is shared by two screens.',
|
|
868
894
|
footer: 'Everything is computed in your browser from the metafile: nothing is uploaded anywhere. Raw figures are bytes on disk; compressed ones are gzipped from the real files, which is what your users actually pay. The browser cannot compress in brotli, so that figure only appears when the folder brings the pre-compressed .js.br files; without them, count on brotli being 15 % to 20 % below the gzip you see. Press ? for the keyboard shortcuts.',
|
|
895
|
+
// --- three views drawn from figures the report already has ---
|
|
896
|
+
diffTitle: 'What changed in the bootstrap',
|
|
897
|
+
diffSub: (before, after, diff, baseline) => `${before} → ${after} (${diff}) against ${baseline}. Each area is what the part weighs now; its colour, how it moved.`,
|
|
898
|
+
diffChange: { new: 'new', grew: 'grew', shrank: 'shrank', same: 'unchanged', gone: 'gone' },
|
|
899
|
+
diffOwn: 'your code',
|
|
900
|
+
diffGone: 'No longer in the bootstrap',
|
|
901
|
+
diffEstimated: 'The changes are raw weights at the ratio the bootstrap compresses by: the right size, not the exact one, hence the ≈.',
|
|
902
|
+
diffPackagesOnly: 'Packages only: the baseline was exported before the folders of your own code were recorded, so they are drawn without a change.',
|
|
903
|
+
diffTile: (name, size, change) => `${name}, ${size}, ${change}`,
|
|
904
|
+
gridTitle: 'Screens × packages',
|
|
905
|
+
gridSub: 'What each screen downloads from each package. A column full from top to bottom is something every screen pays for, whether or not it uses it.',
|
|
906
|
+
gridBoot: 'In the bootstrap',
|
|
907
|
+
gridLazy: 'Loaded with the screen',
|
|
908
|
+
gridOwn: 'your code',
|
|
909
|
+
gridRest: 'the rest',
|
|
910
|
+
gridTotal: 'Screen total',
|
|
911
|
+
gridCell: (screen, size, what) => `${screen} carries ${size} of ${what}, raw, inside its chunks`,
|
|
912
|
+
gridScale: { less: 'less', more: 'more' },
|
|
913
|
+
gridRaw: 'Raw minified bytes inside the chunks; the total is in the report’s unit.',
|
|
914
|
+
tripsTitle: 'How it loads, trip by trip',
|
|
915
|
+
tripsNote: 'An estimate, not a measurement: the report’s round trips laid out on a time axis, with a standard connection profile. Each gap is a round trip spent waiting before the first byte.',
|
|
916
|
+
tripsProfile: { slow4g: 'slow 4G', fast4g: '4G', cable: 'cable' },
|
|
917
|
+
tripsBoot: 'first load',
|
|
918
|
+
tripsScreen: 'this screen',
|
|
919
|
+
tripLabel: index => `trip ${index}`,
|
|
920
|
+
tripsWait: 'waiting',
|
|
921
|
+
tripsParse: 'parse',
|
|
922
|
+
tripsTotal: (time, trips) => `≈ ${time} to have everything, in ${trips} ${trips === 1 ? 'trip' : 'trips'}`,
|
|
923
|
+
tripsAssumed: 'Without index.html the first load is drawn as one trip: the graph alone cannot tell which of its chunks the page names.',
|
|
924
|
+
tripBar: (index, wait, transfer, size, files) => `Trip ${index}: ${wait} waiting, ${transfer} transferring ${size} in ${files} ${files === 1 ? 'file' : 'files'}`,
|
|
869
925
|
errNoEntries: 'This does not look like an esbuild metafile: no entry points found.',
|
|
870
926
|
errNoMain: 'Could not identify the main entry point.',
|
|
871
927
|
errNoOutputs: 'The JSON is shaped like a metafile but has no "outputs" key.',
|
|
872
928
|
errNotMetafile: 'The JSON is not a metafile in any format this reads.',
|
|
873
|
-
errExpected: 'What is expected is the
|
|
874
|
-
errNotEsmGraph:
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
929
|
+
errExpected: 'What is expected is the build folder, the one holding the index.html — enough for anything that emits ES modules: Vite, Rollup, SvelteKit, Nuxt, Astro — or a stats file: the metafile Angular 17 or later writes with `ng build --stats-json` (an object with "outputs" and "inputs"), or the stats.json of webpack (`webpack --json`).',
|
|
930
|
+
errNotEsmGraph: "The chunks of this folder are webpack or Turbopack output, not ES modules: their imports are numbers resolved at run time by the loader, so there is no graph in the files to read. The build's stats file has it, and Loadline reads it: `ng build --stats-json` on Angular 16 or earlier, `webpack --json > stats.json`, `react-scripts build --stats` on Create React App, `vue-cli-service build --report-json` on Vue CLI. Put it in the folder, or drop it with the folder, and the figures stay compressed. Next.js with Turbopack writes no such file.",
|
|
931
|
+
entryLabel: 'The script the application starts at, with * for the hash:',
|
|
932
|
+
entryBtn: 'Read the folder with it',
|
|
933
|
+
errNoPage: 'No index.html in the folder names a script of the folder the application starts at — no <script src>, no import() and no file name in an inline script — and without it there is no way to tell the entry chunk from a shared one: a bundler writes the shared code into the entry chunk, so the entry ends up imported by its own children. Add the page to the folder, load the stats.json of the build, or name the script it starts at: --entry "main.*.js" in the command, the field under this message in the page, or { "build": { "entries": ["main.*.js"] } } in loadline.json.',
|
|
934
|
+
errFolderUnreadable: 'The browser would not let this page read the folder dropped on it. Chrome does that to a page opened from the disk (file://): the folder arrives, and listing what is inside it fails. Choose the same folder with "Choose build folder", which it does allow, or write the page with the build already in it: npx @bymaksym/loadline <folder> --html loadline.html --open.',
|
|
935
|
+
errWebpackStats: 'This is a webpack stats.json with no chunk in it that writes a script, so there is nothing to analyse: it was written with `chunks` or `assets` turned off. Write it again with the defaults — `webpack --json > stats.json`, `ng build --stats-json` — which carry chunks, modules and the reasons each module is in.',
|
|
936
|
+
errViteManifest: 'This is not an esbuild metafile but a Vite manifest.json. It is not needed: drop the build folder itself and Loadline reads the graph out of the chunks, which is where Vite actually writes it.',
|
|
937
|
+
errVisualizer: 'This is not an esbuild metafile but rollup-plugin-visualizer output. Loadline reads the esbuild metafile, which is a different thing.',
|
|
879
938
|
};
|