perf(build): minify bundle and compiled binary#251
Conversation
🦋 Changeset detectedLatest commit: 6ac3b1b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis change enables build minification across the CLI build pipeline. A changeset metadata file documents the patch release for the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Adds `--minify` to `bun build` and `bun build --compile` invocations in `packages/cli-core/package.json` and the cross-platform release builder in `scripts/build.ts`. Reduces the shipped `clerk` binary by ~1 MB across all platforms (63.38 MB → 62.39 MB on darwin-arm64 locally) and the bundled `cli.js` artifact by ~41% (2.37 MB → 1.40 MB). No behavior change: tests, typecheck, lint, format and end-to-end binary smoke (`--version`, `--help`, `apps`, `init --help`, `completion bash`) all pass. Bun applies `--define` substitutions before minification, so `CLI_VERSION` and `CLI_ENV_PROFILES` injection continue to work; the release smoke test (compiled binary `--version`) still matches the injected version.
eeda3f0 to
6ac3b1b
Compare
Summary
--minifyto allbun buildinvocations: thecli.jsbundle, the local--compilebinary, and the cross-platform release build inscripts/build.ts.clerkbinary by ~1 MB on every target (63.38 MB → 62.39 MB on darwin-arm64 measured locally).cli.jsartifact by ~41% (2.37 MB → 1.40 MB).--define-injected values (CLI_VERSION,CLI_ENV_PROFILES) are unaffected because Bun substitutes defines before minification.Why minify only
Reduction beyond
--minifyrequires changing the deploy model (the embedded Bun runtime is ~60 MB of the binary and is fixed). I evaluated and rejected:--target=bun(the default) — grew the bundle: 1.40 MB → 1.63 MB.--sourcemap=noneon--compile— grew the binary by 1.85 MB (Bun quirk; default behavior is smaller).--bytecode— fails oncli.ts's top-levelawait import()for the completion fast path; bytecode also typically increases output size.@inquirer/promptsto per-package imports — tree-shaking already eliminates unused prompts (verified: 360 KB used vs 420 KB ifimport * as).Test plan
bun run buildproducescli.jsof 1,400,498 B (down from 2,372,203 B)bun run build:compileproducesdist/clerkof 62,388,832 B (down from 63,379,552 B)bun run scripts/build.ts --target darwin-arm64 --version 0.0.0-testsucceeds and the binary reports the injected versionbun run typecheckpassesbun run lintpassesbun run format:checkpassesbun run test— all 82 unit + integration tests pass--version,--help,apps --help,init --help,completion bashall behave correctlybun changeset status --since=origin/main(verified locally with staged changeset: exits 0, "clerk: patch")bun run test:e2eagainst the source (not the compiled binary), so minify is not exercised but also not broken