Commit 49676cd
authored
perf(cli): lazy-load init-only deps out of the vp startup path (#2490)
## Summary
Apply lazy loading in `init-config.ts` so the JS resources used only by
`vp lint --init` and `vp fmt --init` / `--migrate` (`utils/tsconfig.ts`,
`utils/command.ts` and their dependencies) are loaded on demand instead
of on every `vp` invocation.
## Benchmark
`node dist/bin.js --help` on macOS (Apple Silicon), Node 24, measured
with `hyperfine --warmup 5 --runs 30` against the `main` build and this
branch's build placed side by side.
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `before` (main) | 83.7 ± 0.9 | 82.1 | 85.3 | 1.10 ± 0.02 |
| `after` (this PR) | 76.1 ± 0.9 | 74.2 | 78.0 | 1.00 |
The static import closure of `dist/bin.js` drops from 13 files / 540 KB
to 9 files / 92 KB, so every `vp` invocation parses about 450 KB less
JavaScript. Package size is unchanged.
<img width="1422" height="472" alt="image"
src="https://github.com/user-attachments/assets/e71cd828-389b-46cc-96f6-94a5ee0cfa9b"
/>1 parent ac7c1fe commit 49676cd
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
| 131 | + | |
133 | 132 | | |
134 | 133 | | |
135 | 134 | | |
| |||
223 | 222 | | |
224 | 223 | | |
225 | 224 | | |
| 225 | + | |
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| |||
0 commit comments