Skip to content

perf(fmt): load stdin formatter on demand - #169

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/lazy-load-fmt-stdin
Aug 4, 2026
Merged

perf(fmt): load stdin formatter on demand#169
chenjiahan merged 1 commit into
mainfrom
chenjiahan/lazy-load-fmt-stdin

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

rs fmt currently loads the stdin formatter, Prettier, and bundled parser support for every invocation, including --help and file-based formatting. This change loads ./stdin.ts only after --stdin-filepath selects stdin mode and emits it as the separate fmtStdin chunk, preserving stdin behavior while avoiding formatter startup work for other modes.

Performance

Measured on macOS arm64 with Node.js v24.12.0 using hyperfine --warmup 5 --runs 30 'node packages/rstack/bin/rs.js fmt --help':

Mean
Before 48.9 ms ± 2.8 ms
After 32.8 ms ± 2.6 ms

This reduces mean startup time by approximately 33%.

Related Links

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: c6893ec
Status: ✅  Deploy successful!
Preview URL: https://e23fb485.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-lazy-load-fmt-std.rstack-cli.pages.dev

View logs

@chenjiahan
chenjiahan merged commit 32c3594 into main Aug 4, 2026
4 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/lazy-load-fmt-stdin branch August 4, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant