Skip to content

perf(fmt): reduce Yuku plugin bundle size - #165

Open
chenjiahan wants to merge 3 commits into
mainfrom
chenjiahan/feat-lightweight-yuku-adapter
Open

perf(fmt): reduce Yuku plugin bundle size#165
chenjiahan wants to merge 3 commits into
mainfrom
chenjiahan/feat-lightweight-yuku-adapter

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

@prettier/plugin-yuku bundles a full copy of Prettier's JavaScript printer into the formatter worker. This replaces it with a local Yuku parser/postprocess adapter that reuses prettier/plugins/estree and mirrors the required Prettier location and pragma behavior locally, without eagerly loading prettier/plugins/babel.

The adapter preserves current official behavior: 230/230 successful official fixture ASTs match exactly, 502 format comparisons have no output or status differences, and the local pragma/location helpers match Prettier's implementations across 5,015 pragma samples and 22 location cases.

Bundle Size

Metric Before (main) After (PR) Reduction
dist/fmtWorker.js 442,932 B 14,874 B 96.6%
npm package (packed) 185,768 B 105,469 B 43.2%
npm package (unpacked) 861,690 B 435,078 B 49.5%

This also removes the @prettier/plugin-yuku dependency and its duplicated bundled code.

Runtime Performance

Compared PR head 01aba4a with main 68c6f25 on the same 145 tracked JavaScript/TypeScript files using Node.js 24.12.0. Results are medians from alternating runs: 40 cold-start samples and 15 samples per warm/CLI variant. The default CLI uses 8 workers.

Metric Main PR Difference
Worker cold load 33.23 ms 32.59 ms 1.9% faster
First format after load 12.67 ms 12.13 ms 4.3% faster
Warm throughput 976.94 files/s 977.01 files/s Equivalent
Full CLI, 1 worker 280.13 ms 281.89 ms 0.6% slower (within noise)
Full CLI, 8 workers 194.47 ms 192.57 ms 1.0% faster
Peak RSS, 1 worker 156.13 MiB 155.11 MiB 1.02 MiB lower
Peak RSS, 8 workers 356.59 MiB 339.19 MiB 17.41 MiB / 4.9% lower

The package-size reduction therefore does not introduce a measurable runtime regression. Removing the eager Babel plugin load also eliminates the earlier parallel-worker startup and memory overhead.

Related Links

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 01aba4a
Status: ✅  Deploy successful!
Preview URL: https://d072c83c.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-feat-lightweight.rstack-cli.pages.dev

View logs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff41c38bcc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/rstack/src/fmt/yukuPlugin.ts
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