refactor(cli): migrate local parsers to usage-rs - #2534
Closed
fengmk2 wants to merge 4 commits into
Closed
Conversation
Contributor
CLI artifact sizes (
|
| Artifact | Format | Base | PR | Change |
|---|---|---|---|---|
packages/cli/dist |
Directory total | 1.59 MiB | 1.59 MiB | 0 B (0.00%) |
packages/core/dist |
Directory total | 3.91 MiB | 3.91 MiB | 0 B (0.00%) |
| Combined package dist | Directory total | 5.50 MiB | 5.50 MiB | 0 B (0.00%) |
vp (Linux x64) |
Binary | 10.74 MiB | 10.77 MiB | +24.00 KiB (+0.22%) |
vp (Linux x64) |
gzip -9 | 4.65 MiB | 4.66 MiB | +11.75 KiB (+0.25%) |
| NAPI (Linux x64) | Binary | 32.39 MiB | 32.17 MiB | -224.06 KiB (-0.68%) |
| NAPI (Linux x64) | gzip -9 | 12.76 MiB | 12.69 MiB | -71.86 KiB (-0.55%) |
vp (macOS ARM64) |
Binary | 8.03 MiB | 8.05 MiB | +16.11 KiB (+0.20%) |
vp (macOS ARM64) |
gzip -9 | 4.06 MiB | 4.07 MiB | +11.89 KiB (+0.29%) |
| NAPI (macOS ARM64) | Binary | 39.93 MiB | 39.84 MiB | -92.66 KiB (-0.23%) |
| NAPI (macOS ARM64) | gzip -9 | 17.05 MiB | 16.95 MiB | -95.55 KiB (-0.55%) |
vp (Windows x64) |
Binary | 8.64 MiB | 8.66 MiB | +23.50 KiB (+0.27%) |
vp (Windows x64) |
gzip -9 | 3.77 MiB | 3.78 MiB | +8.08 KiB (+0.21%) |
| NAPI (Windows x64) | Binary | 27.20 MiB | 26.92 MiB | -283.00 KiB (-1.02%) |
| NAPI (Windows x64) | gzip -9 | 10.82 MiB | 10.74 MiB | -81.98 KiB (-0.74%) |
| Trampoline (Windows x64) | Binary | 214.00 KiB | 214.00 KiB | 0 B (0.00%) |
| Trampoline (Windows x64) | gzip -9 | 103.20 KiB | 103.20 KiB | -1 B (-0.00%) |
| Installer (Windows x64) | Binary | 4.50 MiB | 4.50 MiB | +512 B (+0.01%) |
| Installer (Windows x64) | gzip -9 | 2.11 MiB | 2.11 MiB | +725 B (+0.03%) |
Member
Author
|
Closing this experiment for now. usage-rs makes little difference to the final NAPI binary size. Replacing clap requires a major refactor, so we will not consider this migration now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The complete plan is in
rfcs/usage-rs-local-cli.md. The Vite Task change is in vite-task#694.This draft is stacked on #2523. It replaces all
clapparsers in the local NAPI binary withusage-rs. The globalvpbinary continues to useclap.Design
The command call graph stays the same:
The local dependency graph now has one parser framework:
Completion uses the selected local Vite+ package:
One typed Rust grammar supplies parsing, help, diagnostics, and completion data. The implementation keeps strict errors, aliases, negated flags, repeated-option rules, and
--forwarding.Completion supports Bash, Zsh, Fish, Nu, and PowerShell. Dynamic completion includes task names, package names, package filters, and the
vprview.Performance
The parser benchmarks ran on macOS ARM64 with Node.js 22.22.0.
mriclapusage-rsvp --versionvp staged --helpThe successful parser is 84% faster than
clap. Full CLI latency does not improve measurably because Node.js startup controls the result.Artifact size
Paired local release builds produced these macOS ARM64 NAPI sizes:
clapusage-rsgzip -9__textThe JavaScript files do not change after #2523. The canonical Linux artifact totals are:
mriclapusage-rspackages/cli/distpackages/core/dist, without.nodeThe binary reduction is real but small. Binary size alone does not justify this migration. The main benefits are one grammar, completion support, and lower parser cost.
usage-rsis experimental. This draft pins an exact reviewed revision from the experiment fork. A dependency update must repeat the compatibility, performance, and size checks.