@vernikr/size-report 2.4.0 → 2.6.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 +989 -1081
- package/bin/postinstall.js +17 -18
- package/bin/size.js +2 -2
- package/package.json +3 -4
- package/src/args.js +72 -72
- package/src/artifact.js +14 -14
- package/src/check.js +41 -42
- package/src/cli.js +26 -29
- package/src/config.js +87 -91
- package/src/css.js +14 -14
- package/src/data.js +26 -50
- package/src/derived.js +31 -35
- package/src/doctor.js +95 -99
- package/src/explain.js +46 -47
- package/src/git.js +66 -71
- package/src/history.js +74 -83
- package/src/hook.js +130 -149
- package/src/init.js +37 -37
- package/src/journal.js +17 -15
- package/src/locales.js +31 -22
- package/src/metrics.js +72 -89
- package/src/minify.js +28 -27
- package/src/modes.js +57 -60
- package/src/optional.js +13 -11
- package/src/page/app.css +76 -94
- package/src/page/app.js +124 -80
- package/src/page/build.js +193 -50
- package/src/page/dom.js +8 -9
- package/src/page/panel.js +157 -69
- package/src/page/payload.js +168 -0
- package/src/page/state.js +144 -104
- package/src/page/table.js +270 -86
- package/src/parse-worker.js +10 -10
- package/src/parse.js +43 -45
- package/src/project.js +100 -104
- package/src/refusal.js +75 -76
- package/src/size-table.js +41 -76
- package/src/strip/forms.js +5 -5
- package/src/strip/guard.js +28 -28
- package/src/strip/js.js +27 -27
- package/src/strip.js +17 -21
- package/src/table.css +54 -19
- package/src/tokens.js +27 -27
- package/src/tool.js +10 -11
- package/templates/README.md +71 -77
- package/templates/ci.yml +33 -33
- package/templates/size-report.config.json +3 -3
- package/CHANGELOG.md +0 -690
package/templates/README.md
CHANGED
|
@@ -1,93 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Templates for a project wiring the tool in
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
существовать в инструменте.
|
|
3
|
+
Two files a project takes as they are: settings that pass the tool's own check, and a description of the CI
|
|
4
|
+
check. They are installed together with the package, which is why they travel in its delivery (`files` in
|
|
5
|
+
`package.json`) and are guarded by `test/templates.test.js`: the draft has to be valid, and the commands of
|
|
6
|
+
the description have to exist in the tool.
|
|
8
7
|
|
|
9
|
-
|
|
|
8
|
+
| File | Where | What to do |
|
|
10
9
|
|---|---|---|
|
|
11
|
-
| `size-report.config.json` | `size-table.config.json`
|
|
12
|
-
| `ci.yml` | `.github/workflows/size-report.yml` |
|
|
10
|
+
| `size-report.config.json` | `size-table.config.json` in the project root | **Fix the columns** and, if needed, the rest |
|
|
11
|
+
| `ci.yml` | `.github/workflows/size-report.yml` | Nothing: the file works as it is |
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
The report appears in the project without manual work: after the package is installed and the tool runs for
|
|
14
|
+
the first time, it installs the hooks `post-commit`/`post-merge` itself, and `docs/size-report.html` is
|
|
15
|
+
created by the very first commit. To take the automation away — `size uninstall-hook`; to switch it off
|
|
16
|
+
without removing it — `"hooks": {"enabled": false}`.
|
|
18
17
|
|
|
19
|
-
##
|
|
18
|
+
## Settings
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
выведены, инструмент говорит строкой, а закрепляет их файлом `size --init`: дальше
|
|
28
|
-
это обычные настройки, которые правят руками.
|
|
20
|
+
**A settings file is not needed.** Without one the tool derives the profile from the project itself: the
|
|
21
|
+
columns are every tracked file that can be measured (the report then describes the project as a whole rather
|
|
22
|
+
than a few of its largest files), the journal is the first familiar one (`WORKLOG.md`, `CHANGELOG.md`, …),
|
|
23
|
+
the report file is `docs/size-report.html`, the fix command is the declared `sizes` script, and the commit
|
|
24
|
+
link comes from the `origin` address. That the settings were derived the tool says in a line, and it pins
|
|
25
|
+
them to a file with `size --init`: from then on they are ordinary settings, edited by hand.
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
README и журнал колонкой не отслеживаются, — так и задумано.
|
|
27
|
+
This sample is for another case: starting from an edited file, or seeing all the keys at once. **Its columns
|
|
28
|
+
are an example** rather than a list of your files: the template holds `README.md` and `package.json` because
|
|
29
|
+
nearly any project has them, and with them the first report is assembled at once. Your own columns come from
|
|
30
|
+
`size --init` (it takes them from your tree and history; documentation is included): either take its file
|
|
31
|
+
whole and carry over the keys the template has and it does not, or copy the template and write the columns in
|
|
32
|
+
by hand. The expectation grows from the same place: the columns are examples, so `size check` will name the
|
|
33
|
+
paths that are not columns — the project's own sources and its journal — and that is deliberate.
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
What is worth knowing about the template's values:
|
|
40
36
|
|
|
41
|
-
- `metrics: ["raw", "min", "tok"]` —
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- `fixCommand` —
|
|
48
|
-
`node node_modules/@vernikr/size-report/bin/size.js --write` —
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- `
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
- `metrics: ["raw", "min", "tok"]` — the report's three measurements. `min` is counted by the real minifier
|
|
38
|
+
(`minify.engine: "esbuild"`) and `tok` by the `o200k_base` dictionary. Both travel as optional
|
|
39
|
+
dependencies of the package and are installed by an ordinary installation; without them (an installation
|
|
40
|
+
without the optional dependencies, a platform that has none) the tool still works, but says that the
|
|
41
|
+
numbers were counted another way, and returns **code 4** — that is a named different count rather than an
|
|
42
|
+
error of the settings.
|
|
43
|
+
- `fixCommand` — the command the report's signature and the refusals quote. In the template it is
|
|
44
|
+
`node node_modules/@vernikr/size-report/bin/size.js --write` — the path to the installed package inside
|
|
45
|
+
the project. **The package name as a command cannot stand here:** `npx <name>` in a project without the
|
|
46
|
+
installed package goes to the registry and pulls the package over the network, so the advice that is meant
|
|
47
|
+
to help would depend on access to the registry and on what lies there. If the project has a script of its
|
|
48
|
+
own — `pnpm run sizes`, say — write it in: the report's signature will lead to it.
|
|
49
|
+
- `journal: null` — there will be no references to journal sections. If the project has `WORKLOG.md` or
|
|
50
|
+
`CHANGELOG.md`, put an object with `path`, `url` and `pattern`: that very object is what `size --init`
|
|
51
|
+
derives when the project has a journal.
|
|
52
|
+
- `paths` inside a column are aliases of one file: if the file was renamed, list both the old name and the
|
|
53
|
+
new one, and the column will not break apart.
|
|
54
|
+
- `output: "docs/size-report.html"` — the report file (there is one of it: a self-contained page with all the
|
|
55
|
+
numbers, the filters and the link); the tool creates the directory itself. The updating hook is installed by
|
|
56
|
+
itself — by the install script (npm, yarn) or by the first run (pnpm 10 does not run dependency scripts
|
|
57
|
+
unless `pnpm.onlyBuiltDependencies` allows it) — and the report is rebuilt after every commit. The first
|
|
58
|
+
report stays untracked until you add it to git; from then on it updates itself by commits.
|
|
61
59
|
|
|
62
|
-
##
|
|
60
|
+
## The check in CI
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
есть проверка того, что числа не зависят от машины.
|
|
62
|
+
Copy `ci.yml` to `.github/workflows/size-report.yml` — it needs no edits if the project is on `pnpm`. What it
|
|
63
|
+
does and why exactly so is written in its comments; in short: it assembles the table again and compares it
|
|
64
|
+
with the file on disk, then takes the report's data twice — usually and in an environment with no git
|
|
65
|
+
settings at all (`GIT_CONFIG_GLOBAL=/dev/null`) — and compares the snapshots byte for byte. The second one is
|
|
66
|
+
the check that the numbers do not depend on the machine.
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
проект инструмент не должен.
|
|
68
|
+
It needs no secrets of its own, and must not: the package is installed from a public repository, and pnpm
|
|
69
|
+
pulls its archive over HTTPS — neither the installation nor the check itself needs a key or a token. Should
|
|
70
|
+
the project move to a private registry or to a copy of the package of its own, the key step will have to be
|
|
71
|
+
added by hand: bringing it into the template on the project's behalf is not the tool's business.
|
|
76
72
|
|
|
77
|
-
|
|
73
|
+
For `npm` and `yarn` the file itself says what to replace.
|
|
78
74
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Про один коммит отвечает `pnpm exec size explain <sha>`.
|
|
75
|
+
There is deliberately no completeness check (`pnpm exec size check`) in the template: it demands that
|
|
76
|
+
**every** path of the history be a column or an exception, while the template's columns are examples — and in
|
|
77
|
+
a project whose columns are not chosen yet such a check would be red for no reason. Once the columns describe
|
|
78
|
+
the project, add the step yourself: `check` names the paths a column does not track and the commits that
|
|
79
|
+
introduced them; those that need not be counted go to `skip` — the same list makes a path an exception as
|
|
80
|
+
well. About a single commit `pnpm exec size explain <sha>` answers.
|
|
86
81
|
|
|
87
|
-
##
|
|
82
|
+
## What the templates do not have
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
«Для ИИ-агента».
|
|
84
|
+
A block for the project's own agent files (`AGENTS.md` and the like) is deliberately absent here: the
|
|
85
|
+
requirements do not ask for such a file, and inventing the format of someone else's repository is not
|
|
86
|
+
something the tool should do. What an agent needs to know it will take from `size --help` and `size --data` —
|
|
87
|
+
the commands and the data are described in the package's `README.md`, section "For an AI agent".
|
package/templates/ci.yml
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# Checking the size for a project that has installed @vernikr/size-report.
|
|
2
|
+
# Put the file in .github/workflows/size-report.yml — it needs no edits.
|
|
3
3
|
#
|
|
4
|
-
#
|
|
5
|
-
# *
|
|
6
|
-
#
|
|
7
|
-
# *
|
|
8
|
-
#
|
|
9
|
-
#
|
|
4
|
+
# What is checked, and why it is done this way:
|
|
5
|
+
# * the report on disk agrees with the git history — these are its numbers (the report is one:
|
|
6
|
+
# the self-contained page `size-report.html`);
|
|
7
|
+
# * the same snapshot of numbers, taken in an environment where there are no git settings at all,
|
|
8
|
+
# is byte-identical: the output of the tool must not depend on what is
|
|
9
|
+
# configured on the machine (BLOCKERS.md §B1, §B2).
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
11
|
+
# The template requires no secrets and cannot require any: the package comes from
|
|
12
|
+
# a public repository, and pnpm pulls its archive from codeload.github.com over HTTPS —
|
|
13
|
+
# the install needs neither a key nor a token (proved by an install in an environment without
|
|
14
|
+
# git settings and without a credential helper; the package's README, §1). If the project
|
|
15
|
+
# moves to a private registry, the step with a key is yours to add.
|
|
16
16
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
# `size`:
|
|
20
|
-
# `pnpm install`, `npm exec size`
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
17
|
+
# The package manager: pnpm below. For npm — `npm ci` instead of `pnpm install`,
|
|
18
|
+
# for yarn — `yarn --immutable`. The check itself is always the same command
|
|
19
|
+
# `size`: the local binary the install puts there (`pnpm exec size` after
|
|
20
|
+
# `pnpm install`, `npm exec size` after `npm ci`).
|
|
21
|
+
# The package name as a command is deliberately absent here: `npx <name>` in a project
|
|
22
|
+
# without the package installed goes to the registry and pulls it over the network, while
|
|
23
|
+
# the check step has to work on what the install put there.
|
|
24
|
+
# An explicit path is what is needed — `node node_modules/@vernikr/size-report/bin/size.js`.
|
|
25
25
|
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# `pnpm exec size --write` —
|
|
26
|
+
# The report is not in git? The requirements foresee that too (the report is a derived artifact):
|
|
27
|
+
# then instead of the step «the report agrees with the history» put the build —
|
|
28
|
+
# `pnpm exec size --write` — and that step will check that the report assembles.
|
|
29
29
|
|
|
30
30
|
name: size-report
|
|
31
31
|
|
|
@@ -35,8 +35,8 @@ jobs:
|
|
|
35
35
|
size:
|
|
36
36
|
runs-on: ubuntu-latest
|
|
37
37
|
steps:
|
|
38
|
-
#
|
|
39
|
-
#
|
|
38
|
+
# The whole history is needed: the report is built from the commits, and on a truncated
|
|
39
|
+
# clone the tool refuses to work (code 3) rather than writing a short one.
|
|
40
40
|
- uses: actions/checkout@v7
|
|
41
41
|
with:
|
|
42
42
|
fetch-depth: 0
|
|
@@ -48,21 +48,21 @@ jobs:
|
|
|
48
48
|
node-version: 22
|
|
49
49
|
cache: pnpm
|
|
50
50
|
|
|
51
|
-
- name:
|
|
51
|
+
- name: Setup
|
|
52
52
|
run: pnpm install --frozen-lockfile
|
|
53
53
|
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
- name:
|
|
54
|
+
# The check is the same `size` command without flags: it assembles the report anew
|
|
55
|
+
# and compares it with the file on disk. A consumer needs no test set of its own.
|
|
56
|
+
- name: The report agrees with the history
|
|
57
57
|
run: pnpm exec size
|
|
58
58
|
|
|
59
|
-
- name:
|
|
59
|
+
- name: A snapshot of the contract numbers
|
|
60
60
|
run: pnpm exec size --data > /tmp/size-report-data.json
|
|
61
61
|
|
|
62
|
-
- name:
|
|
62
|
+
- name: A snapshot of numbers without the machine's git settings
|
|
63
63
|
run: pnpm exec size --data > /tmp/size-report-data-null.json
|
|
64
64
|
env:
|
|
65
65
|
GIT_CONFIG_GLOBAL: /dev/null
|
|
66
66
|
|
|
67
|
-
- name:
|
|
67
|
+
- name: The numbers do not depend on the machine's settings
|
|
68
68
|
run: diff -u /tmp/size-report-data.json /tmp/size-report-data-null.json
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"output": "docs/size-report.html",
|
|
3
|
-
"locale": "
|
|
4
|
-
"title": "
|
|
5
|
-
"heading": "
|
|
3
|
+
"locale": "en",
|
|
4
|
+
"title": "File size by commit",
|
|
5
|
+
"heading": "File size by commit",
|
|
6
6
|
"fixCommand": "node node_modules/@vernikr/size-report/bin/size.js --write",
|
|
7
7
|
"metrics": [
|
|
8
8
|
"raw",
|