@bymaksym/loadline 1.0.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 +211 -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
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ own fonts and works offline.
|
|
|
19
19
|
|
|
20
20
|
## Quick start
|
|
21
21
|
|
|
22
|
-
**In the browser.** Open [`loadline.html`](loadline.html) and drop your build on it
|
|
23
|
-
server, no build step. Press **See an example** to see the report on a synthetic build that ships
|
|
22
|
+
**In the browser.** Open [`loadline.html`](loadline.html) and drop your build on it, or choose it with
|
|
23
|
+
**Choose build folder**. No install, no server, no build step. Press **See an example** to see the report on a synthetic build that ships
|
|
24
24
|
inside the page.
|
|
25
25
|
|
|
26
26
|
**In the terminal.**
|
|
@@ -29,6 +29,7 @@ inside the page.
|
|
|
29
29
|
npx @bymaksym/loadline dist/app # the build root: the metafile and browser/ are found
|
|
30
30
|
npx @bymaksym/loadline dist/app --html loadline.html --open # and the page, with the build already in it
|
|
31
31
|
npx @bymaksym/loadline dist/app/browser # the build folder on its own
|
|
32
|
+
npx @bymaksym/loadline . # the project: the newest build inside it is found
|
|
32
33
|
npx @bymaksym/loadline dist/app/browser-stats.json --dist dist/app/browser
|
|
33
34
|
```
|
|
34
35
|
|
|
@@ -48,16 +49,29 @@ ships `loadline.html` next to the command, under `npm root -g`.
|
|
|
48
49
|
## Compatibility
|
|
49
50
|
|
|
50
51
|
Loadline reads ES module output, either from an esbuild metafile or from the compiled folder, whose
|
|
51
|
-
chunks carry their own import graph.
|
|
52
|
+
chunks carry their own import graph, and webpack builds from their `stats.json`.
|
|
52
53
|
|
|
53
|
-
| Build tool
|
|
54
|
-
|
|
|
55
|
-
| esbuild (metafile)
|
|
56
|
-
| Vite, Rollup, Rolldown
|
|
57
|
-
|
|
|
54
|
+
| Build tool | Frameworks | What to pass |
|
|
55
|
+
| ---------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
56
|
+
| esbuild (metafile) | Angular 17+, plain esbuild | The build root, or the metafile with `--dist` |
|
|
57
|
+
| Vite, Rollup, Rolldown | Vue, React, Svelte, Solid, Nuxt, SvelteKit, Astro, React Router 7 | The build folder |
|
|
58
|
+
| Older formats: AMD, SystemJS, `nomodule` | Sapper, Stencil, Polymer, Ember, RequireJS, Vite's legacy plugin | The build folder, or the project root: the build is found inside it |
|
|
59
|
+
| webpack, Rspack | Angular ≤ 16, Create React App, Vue CLI, Gatsby, Nuxt 2 | The `stats.json` with `--dist`, or the build folder when it is inside it |
|
|
60
|
+
| Turbopack | Next.js | Not supported: it writes no stats file |
|
|
58
61
|
|
|
59
62
|
Webpack resolves imports at run time through its own loader, so the shipped files contain no graph
|
|
60
|
-
to read.
|
|
63
|
+
to read; its `stats.json` does, and Loadline reads it as a metafile. How to get one:
|
|
64
|
+
|
|
65
|
+
| Tool | Command | Where it lands |
|
|
66
|
+
| ---------------- | ------------------------------------- | -------------------------------- |
|
|
67
|
+
| Angular 8 to 16 | `ng build --stats-json` | `dist/<app>/stats(-es2015).json` |
|
|
68
|
+
| Create React App | `react-scripts build --stats` | `build/bundle-stats.json` |
|
|
69
|
+
| Vue CLI | `vue-cli-service build --report-json` | `dist/report.json` |
|
|
70
|
+
| plain webpack | `webpack --json > stats.json` | wherever it is redirected |
|
|
71
|
+
|
|
72
|
+
Inside the build folder, `loadline <folder>` finds it; anywhere else, pass it with `--dist <folder>`.
|
|
73
|
+
A module's size in that file is its source before minification, so what each file weighs inside a
|
|
74
|
+
chunk is shared out in proportion until the folder's source maps measure it.
|
|
61
75
|
|
|
62
76
|
A build folder must contain the `index.html` of the build, which names the chunk the application
|
|
63
77
|
starts at. Source maps in the folder are optional: without them every figure still comes out, but
|
|
@@ -106,6 +120,114 @@ Optional inputs widen the report:
|
|
|
106
120
|
|
|
107
121
|
## In CI
|
|
108
122
|
|
|
123
|
+
### The minimum
|
|
124
|
+
|
|
125
|
+
Enough for most projects: every pull request is built and fails if the first load is over the
|
|
126
|
+
limit. Copy one, change `dist/my-app` to your build folder (`outputPath` in `angular.json`, `outDir`
|
|
127
|
+
in Vite), and that is all.
|
|
128
|
+
|
|
129
|
+
**GitHub Actions** — `.github/workflows/loadline.yml`:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
name: Loadline
|
|
133
|
+
on: pull_request
|
|
134
|
+
jobs:
|
|
135
|
+
loadline:
|
|
136
|
+
runs-on: ubuntu-latest
|
|
137
|
+
steps:
|
|
138
|
+
- uses: actions/checkout@v7
|
|
139
|
+
- uses: actions/setup-node@v7
|
|
140
|
+
with: { node-version: 22 }
|
|
141
|
+
- run: npm ci && npm run build
|
|
142
|
+
- run: npx @bymaksym/loadline@1 dist/my-app --format summary --max-boot 350kB
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**GitLab CI** — `.gitlab-ci.yml`:
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
loadline:
|
|
149
|
+
image: node:22
|
|
150
|
+
rules:
|
|
151
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
152
|
+
script:
|
|
153
|
+
- npm ci && npm run build
|
|
154
|
+
- npx @bymaksym/loadline@1 dist/my-app --format summary --max-boot 350kB
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Bitbucket Pipelines** — `bitbucket-pipelines.yml`:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
image: node:22
|
|
161
|
+
pipelines:
|
|
162
|
+
pull-requests:
|
|
163
|
+
'**':
|
|
164
|
+
- step:
|
|
165
|
+
name: Loadline
|
|
166
|
+
script:
|
|
167
|
+
- npm ci && npm run build
|
|
168
|
+
- npx @bymaksym/loadline@1 dist/my-app --format summary --max-boot 350kB
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Azure Pipelines** — `azure-pipelines.yml` (the `pr` trigger covers GitHub and Bitbucket
|
|
172
|
+
repositories; in Azure Repos, a branch policy runs it):
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
trigger: none
|
|
176
|
+
pr:
|
|
177
|
+
- '*'
|
|
178
|
+
pool:
|
|
179
|
+
vmImage: ubuntu-latest
|
|
180
|
+
steps:
|
|
181
|
+
- task: NodeTool@0
|
|
182
|
+
inputs: { versionSpec: '22.x' }
|
|
183
|
+
- script: npm ci && npm run build
|
|
184
|
+
- script: npx @bymaksym/loadline@1 dist/my-app --format summary --max-boot 350kB
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**CircleCI** — `.circleci/config.yml` (it runs on every push; "Only build pull requests" in the
|
|
188
|
+
project settings limits it to pull requests):
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
version: 2.1
|
|
192
|
+
jobs:
|
|
193
|
+
loadline:
|
|
194
|
+
docker:
|
|
195
|
+
- image: cimg/node:22
|
|
196
|
+
steps:
|
|
197
|
+
- checkout
|
|
198
|
+
- run: npm ci && npm run build
|
|
199
|
+
- run: npx @bymaksym/loadline@1 dist/my-app --format summary --max-boot 350kB
|
|
200
|
+
workflows:
|
|
201
|
+
loadline:
|
|
202
|
+
jobs:
|
|
203
|
+
- loadline
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- **Your own install command** if it is not npm: `pnpm install --frozen-lockfile`, `yarn`.
|
|
207
|
+
- **More to fail on**: `--fail-on high` adds the most serious signals; run it once first without
|
|
208
|
+
the flag, so an existing build does not fail on day one for something nobody touched.
|
|
209
|
+
- **Limits in `loadline.json`** instead of flags, and the step becomes
|
|
210
|
+
`npx @bymaksym/loadline@1 dist/my-app --format summary`. See [Configuration](#configuration).
|
|
211
|
+
- **The whole report** — package names, the import chains, the screens by name — needs the build to
|
|
212
|
+
say what is inside each file: `ng build --stats-json` in Angular, `build.sourcemap: true` in Vite.
|
|
213
|
+
Without it the limits still work.
|
|
214
|
+
|
|
215
|
+
**A badge** of the first load, green, amber or red by the same verdict as the report, with the
|
|
216
|
+
change when there is a `--baseline`:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npx @bymaksym/loadline@1 dist/my-app --format badge > loadline.svg
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Commit it from the pipeline of the main branch and show it in the README with
|
|
223
|
+
``, or attach it to the pull request. It is a plain SVG: nothing fetched,
|
|
224
|
+
no badge service.
|
|
225
|
+
|
|
226
|
+
When you want the comment on every pull request with what it **adds** compared with `main`, use the
|
|
227
|
+
full recipes below.
|
|
228
|
+
|
|
229
|
+
### Everything it can do
|
|
230
|
+
|
|
109
231
|
The command prints the same headline, table and signals as the page, and can fail the build.
|
|
110
232
|
|
|
111
233
|
```bash
|
|
@@ -126,8 +248,10 @@ for builds that write no `stats.json`. Write it on every run, passing or failing
|
|
|
126
248
|
compares against yesterday rather than against the last green build.
|
|
127
249
|
|
|
128
250
|
Output formats: `text` (default), `summary` for the whole report in a dozen lines, `json`,
|
|
129
|
-
`markdown`, `sarif` for GitHub code scanning,
|
|
130
|
-
the next run edits its comment instead of adding another
|
|
251
|
+
`markdown`, `sarif` for GitHub code scanning, `pr-comment`, which carries an HTML marker so
|
|
252
|
+
the next run edits its comment instead of adding another, and `agent` for a coding agent or a
|
|
253
|
+
script: the five actions worth most, each with its file, import chain and saving, as `key=value`
|
|
254
|
+
lines with no prose. `--lang en|es` — English unless it is
|
|
131
255
|
asked for in Spanish, never read from the machine's locale, which is the same rule the page
|
|
132
256
|
follows with its language button. `loadline --help` for the full list.
|
|
133
257
|
|
|
@@ -148,8 +272,8 @@ jobs:
|
|
|
148
272
|
weight:
|
|
149
273
|
runs-on: ubuntu-latest
|
|
150
274
|
steps:
|
|
151
|
-
- uses: actions/checkout@
|
|
152
|
-
- uses: actions/setup-node@
|
|
275
|
+
- uses: actions/checkout@v7
|
|
276
|
+
- uses: actions/setup-node@v7
|
|
153
277
|
with: { node-version: 22 }
|
|
154
278
|
- run: npm ci && npm run build
|
|
155
279
|
|
|
@@ -162,7 +286,7 @@ jobs:
|
|
|
162
286
|
|
|
163
287
|
- run: |
|
|
164
288
|
baseline=$([ -f base/loadline-baseline.json ] && echo "--baseline base/loadline-baseline.json")
|
|
165
|
-
npx @bymaksym/loadline dist/app/browser $baseline --export loadline-baseline.json --format pr-comment > comment.md
|
|
289
|
+
npx @bymaksym/loadline@1 dist/app/browser $baseline --export loadline-baseline.json --format pr-comment > comment.md
|
|
166
290
|
|
|
167
291
|
- if: github.event_name == 'pull_request'
|
|
168
292
|
run: gh pr comment "$NUMBER" --body-file comment.md --edit-last --create-if-none
|
|
@@ -170,59 +294,103 @@ jobs:
|
|
|
170
294
|
|
|
171
295
|
# On main, the snapshot becomes the baseline of every pull request opened after it.
|
|
172
296
|
- if: github.event_name == 'push'
|
|
173
|
-
uses: actions/upload-artifact@
|
|
297
|
+
uses: actions/upload-artifact@v7
|
|
174
298
|
with: { name: loadline-baseline, path: loadline-baseline.json }
|
|
175
299
|
|
|
176
|
-
- run: npx @bymaksym/loadline dist/app/browser --format sarif > loadline.sarif
|
|
177
|
-
- uses: github/codeql-action/upload-sarif@
|
|
300
|
+
- run: npx @bymaksym/loadline@1 dist/app/browser --format sarif > loadline.sarif
|
|
301
|
+
- uses: github/codeql-action/upload-sarif@v4
|
|
178
302
|
with: { sarif_file: loadline.sarif }
|
|
179
303
|
```
|
|
180
304
|
|
|
181
305
|
To make the pull request fail on growth rather than only report it, add one more step after the
|
|
182
306
|
comment, so the comment is posted whatever the verdict:
|
|
183
|
-
`npx @bymaksym/loadline dist/app/browser $baseline --max-growth 20kB` (or
|
|
184
|
-
|
|
307
|
+
`[ -z "$baseline" ] || npx @bymaksym/loadline@1 dist/app/browser $baseline --max-growth 20kB` (or
|
|
308
|
+
`--max-growth-pct 5`). It judges what this pull request added, not the size of the whole
|
|
309
|
+
application — and it needs a baseline, which the first run on `main` does not have yet.
|
|
310
|
+
|
|
311
|
+
The recipes pin the major version (`@1`): a new major can move a threshold, and a pipeline should
|
|
312
|
+
change its verdict because the code changed, not because a tool updated overnight. In a job log,
|
|
313
|
+
`--format summary` prints a dozen lines instead of the whole report.
|
|
314
|
+
|
|
315
|
+
### GitLab CI
|
|
316
|
+
|
|
317
|
+
The same idea: the default branch keeps its snapshot as an artifact, and each merge request
|
|
318
|
+
downloads it, compares, and keeps one note up to date. Posting the note needs a project access
|
|
319
|
+
token with the `api` scope, saved as a masked CI/CD variable called `LOADLINE_TOKEN` — the job's own
|
|
320
|
+
token can read artifacts but cannot write notes. Without the variable the job still runs and fails
|
|
321
|
+
on the gates; it only does not comment.
|
|
322
|
+
|
|
323
|
+
```yaml
|
|
324
|
+
# .gitlab-ci.yml
|
|
325
|
+
loadline:
|
|
326
|
+
image: node:22
|
|
327
|
+
rules:
|
|
328
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
329
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
330
|
+
script:
|
|
331
|
+
- npm ci && npm run build
|
|
332
|
+
# The snapshot the default branch left on its last successful run of this job.
|
|
333
|
+
- >
|
|
334
|
+
curl --fail --silent --location --header "JOB-TOKEN: $CI_JOB_TOKEN" --output base.json
|
|
335
|
+
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/raw/loadline-baseline.json?job=loadline"
|
|
336
|
+
|| rm -f base.json
|
|
337
|
+
- baseline=$([ -f base.json ] && echo "--baseline base.json")
|
|
338
|
+
- npx @bymaksym/loadline@1 dist/app/browser $baseline --export loadline-baseline.json --format pr-comment > comment.md
|
|
339
|
+
# One note per merge request, edited on every push: found by the marker the comment carries.
|
|
340
|
+
- |
|
|
341
|
+
if [ "$CI_PIPELINE_SOURCE" = "merge_request_event" ] && [ -n "$LOADLINE_TOKEN" ]; then
|
|
342
|
+
notes="$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes"
|
|
343
|
+
id=$(curl --silent --header "PRIVATE-TOKEN: $LOADLINE_TOKEN" "$notes?per_page=100" \
|
|
344
|
+
| node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const n=JSON.parse(s).find(n=>n.body.includes("<!-- loadline-report -->"));process.stdout.write(n?String(n.id):"")})')
|
|
345
|
+
if [ -n "$id" ]; then method=PUT; url="$notes/$id"; else method=POST; url="$notes"; fi
|
|
346
|
+
curl --silent --request "$method" --header "PRIVATE-TOKEN: $LOADLINE_TOKEN" --data-urlencode "body@comment.md" "$url" > /dev/null
|
|
347
|
+
fi
|
|
348
|
+
# Fails the merge request on growth, after the note is posted. Growth needs a baseline,
|
|
349
|
+
# which the very first run of the default branch does not have yet.
|
|
350
|
+
- if [ -n "$baseline" ]; then npx @bymaksym/loadline@1 dist/app/browser $baseline --max-growth 20kB --format summary; fi
|
|
351
|
+
artifacts:
|
|
352
|
+
paths: [loadline-baseline.json]
|
|
353
|
+
expire_in: 30 days
|
|
354
|
+
```
|
|
185
355
|
|
|
186
356
|
## Configuration
|
|
187
357
|
|
|
188
|
-
A `loadline.json`
|
|
189
|
-
|
|
190
|
-
|
|
358
|
+
Everything is optional. A `loadline.json` next to your code sets the thresholds, makes CI fail, and
|
|
359
|
+
records the signals the team has decided to live with. The page and the command both read it, so
|
|
360
|
+
they judge the build the same way.
|
|
191
361
|
|
|
192
362
|
```json
|
|
193
363
|
{
|
|
364
|
+
"$schema": "https://unpkg.com/@bymaksym/loadline/loadline.schema.json",
|
|
194
365
|
"tool": "loadline",
|
|
195
366
|
"version": 1,
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"packages": ["@angular/core", "@angular/common", "rxjs"],
|
|
199
|
-
"accepted": [
|
|
200
|
-
{
|
|
201
|
-
"kind": "dupes",
|
|
202
|
-
"key": "date-fns",
|
|
203
|
-
"why": "two versions until the calendar library releases 4.x",
|
|
204
|
-
"who": "@maks",
|
|
205
|
-
"until": "2026-12-01",
|
|
206
|
-
"bytes": 14336
|
|
207
|
-
}
|
|
208
|
-
]
|
|
367
|
+
"gates": { "maxBoot": "350kB", "screens": { "map": "900kB" }, "failOn": "high" },
|
|
368
|
+
"accepted": [{ "kind": "dupes", "key": "date-fns", "why": "until 4.x", "until": "2026-12-01" }]
|
|
209
369
|
}
|
|
210
370
|
```
|
|
211
371
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
Everything accepted is listed under the report, so no signal disappears silently.
|
|
372
|
+
With the `$schema` line your editor completes every key, explains it on hover and underlines a typo.
|
|
373
|
+
Anything the command cannot use in the file is printed, never ignored. Flags win over the file.
|
|
215
374
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
375
|
+
| I want to… | Read |
|
|
376
|
+
| ------------------------------------------------ | ------------------------------------------------------------------------------- |
|
|
377
|
+
| Fail CI on size, growth, new packages, signals | [Configuring Loadline](docs/CONFIG.md#fail-the-build-on-size) |
|
|
378
|
+
| Give one heavy screen its own limit | [One limit per screen](docs/CONFIG.md#one-limit-per-screen) |
|
|
379
|
+
| Change what counts as good or bad | [Thresholds](docs/CONFIG.md#change-the-thresholds) |
|
|
380
|
+
| Live with a signal without hiding it forever | [Accept a signal](docs/CONFIG.md#accept-a-signal) |
|
|
381
|
+
| Never ship a package, or never in the first load | [Forbid something](docs/CONFIG.md#forbid-something) |
|
|
382
|
+
| Share one file between many repositories | [Share the configuration](docs/CONFIG.md#share-the-configuration) |
|
|
383
|
+
| Fix a build read wrong: entry, screens, page | [When it reads your build wrong](docs/CONFIG.md#when-it-reads-your-build-wrong) |
|
|
384
|
+
| See every key and its recommended value | [Reference](docs/CONFIG-REFERENCE.md) |
|
|
219
385
|
|
|
220
386
|
## Documentation
|
|
221
387
|
|
|
388
|
+
- [Configuring Loadline](docs/CONFIG.md) — `loadline.json` by task, with examples, and the
|
|
389
|
+
[reference](docs/CONFIG-REFERENCE.md) of every key.
|
|
222
390
|
- [How it works](docs/HOW-IT-WORKS.md) — the algorithm, what each signal means, the limits of the
|
|
223
391
|
analysis, and [how the other tools compare](docs/HOW-IT-WORKS.md#7-what-the-other-tools-do).
|
|
224
|
-
- [CONTRIBUTING.md](CONTRIBUTING.md) — what CI checks before you spend time on a change.
|
|
225
|
-
- [SECURITY.md](SECURITY.md) — report vulnerabilities privately, never as an issue.
|
|
392
|
+
- [CONTRIBUTING.md](.github/CONTRIBUTING.md) — what CI checks before you spend time on a change.
|
|
393
|
+
- [SECURITY.md](.github/SECURITY.md) — report vulnerabilities privately, never as an issue.
|
|
226
394
|
- [CHANGELOG.md](CHANGELOG.md) — what changed in each version.
|
|
227
395
|
|
|
228
396
|
When opening an issue, the **Copy diagnostics** button at the end of the report writes about thirty
|