Skip to content

perf(typecheck): pin Bun as a devDependency and typecheck with it - #30149

Merged
nwparker merged 3 commits into
mainfrom
nwparker/Orca-TSC-perf
Oct 18, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/Orca-TSC-perf

Conversation

@nwparker

@nwparker nwparker commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​244 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​195

ELI5

pnpm tc is the typecheck every agent runs over and over. With TypeScript's native compiler (tsc), one check of the node project can take about 16 GB of RAM and 100 CPU-seconds, so a few agents checking at once swamp the machine. CI already uses Bun's bun check, which reports the same errors for a fraction of that. This PR pins Bun as a normal devDependency, so every pnpm install gets the exact version, and makes pnpm tc use it.

What Changed

  • Before: pnpm tc and tc:node/tc:web/tc:cli always ran tsc --noEmit with its incremental cache. Bun was something each developer installed by hand to match config/.bun-version. Drift was common: the machine this was measured on had 1.4.2.
  • After:
    • [email protected] is an exact devDependency, and pnpm-workspace.yaml allows its postinstall step, which links the platform binary.
    • The typecheck runner, used by pnpm tc and by CI's typecheck:ci, runs that binary.
    • If the binary is missing (for example after --ignore-scripts), the check fails and says to run pnpm install, instead of quietly running the expensive check.
    • --compiler=native still selects tsc.
    • Local runs check two projects at a time with 4 threads each. CI keeps its explicit settings.
  • A test keeps the devDependency equal to config/.bun-version, which CI's setup-bun still reads.
  • The localization extraction check uses the same pinned binary, through config/scripts/pinned-bun-executable.mjs.

Measured on a 16-core M-series Mac:

node project web project full pnpm tc
tsc, cold 98 CPU-s, 16.6 GB peak 52–68 CPU-s, 9.6 GB ~165 CPU-s, ~26 GB with node and web together
tsc, warm, nothing changed 9 CPU-s, 3.4 GB 8 CPU-s, 2.8 GB ~19 CPU-s
bun check 29 CPU-s, 1.9 GB 34 CPU-s, 1.8 GB 66 CPU-s, 1.9 GB peak, 15.9 s wall

Why

The incremental cache was the reason to keep tsc locally, but in practice it rarely saves the work.

  • These are noEmit builds, so tsc never records each file's declaration signature (its public API). The cache stores the file's content hash in its place: 3 of 18,095 files had real signatures.
  • The first edit to any file after a cold check therefore looks like an API change. TypeScript then re-checks every file that imports it, directly or indirectly.
  • Measured: a comment-only edit to src/shared/constants.ts re-checked the whole node project (104 CPU-s), the same as a cold run.
  • Edits that really add or change exports also re-check that whole chain of importers, by design.
  • Agents start from a cold cache in every new worktree.

So the realistic cost of a tsc run is close to the cold row, while Bun's cost is flat and its memory use is about an eighth.

Why a devDependency rather than asking developers to install Bun: this is how JS repos usually pin binary tools (esbuild, turbo, biome). The lockfile fixes the version per worktree, the pnpm store dedupes the ~67 MB binary across worktrees, and pnpm run puts it on PATH for the other scripts that call bun. The PATH-probe version that came before this left every developer whose Bun didn't match on the expensive path.

Alternatives considered:

  • Emitting declarations so tsc records real signatures. This makes comment- and body-only edits cheap. But API edits still re-check the whole chain at 16 GB, and it writes about 70 MB of .d.ts files per project per worktree.
  • assumeChangesOnlyAffectDirectDependencies: can miss errors.
  • Lowering --checkers: 4 → 2 saves only 11% CPU and 3 GB.

Linked Issue

N/A (maintainer)

Visual Proof

N/A: developer tooling only; no app behaviour changes.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • With only Bun 1.4.2 on PATH: pnpm tc, tc:web and typecheck:ci all check with the 1.4.3 devDependency.

  • Injecting a type error and an unused local gives identical diagnostics and exit 1 from both Bun and tsc.

  • verify:localization-extraction still passes.

  • Runner tests cover: Bun as the default, --project filtering, a missing Bun failing loudly, --compiler=native never probing for Bun, and the devDependency matching config/.bun-version.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • The bun npm package ships binaries for macOS, Linux (glibc and musl) and Windows on x64 and arm64.
  • bun check is cross-platform.
  • Only the current platform's binary is installed.
  • CI is unchanged: it still runs --compiler=bun with explicit concurrency and thread counts.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

bun check (Bun 1.4.3, TypeScript 7.0.2 parity, already used by CI) checks the
node project in ~29 CPU-s / ~2 GB peak vs tsc's ~98 CPU-s / ~16.6 GB. tsc's
incremental cache rarely helps agents: noEmit builds store no declaration
signatures, so the first edit to any file after a cold check re-checks every
transitive importer (a comment in src/shared/constants.ts re-checks all 18k files).

pnpm tc / tc:node / tc:web / tc:cli now pick the Bun from config/.bun-version when
it is on PATH and fall back to tsc with a one-line hint otherwise;
--compiler=native forces tsc. The pinned-Bun probe is shared with the
localization extraction check.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b599ee21-5011-4928-817a-c254e7b94e99
📥 Commits

Reviewing files that changed from the base of the PR and between bba90e7 and 864e917.

⛔ Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 7
  • .github/CONTRIBUTING.md
  • .github/actions/install-node-dependencies/action.yml
  • config/scripts/pinned-bun-executable.mjs
  • config/scripts/run-typecheck-projects-in-parallel.mjs
  • config/scripts/run-typecheck-projects-in-parallel.test.mjs
  • package.json
  • pnpm-workspace.yaml
📝 Walkthrough

The typecheck runner now selects Bun automatically when the pinned Bun executable is available and the selected projects use the supported TypeScript version. Otherwise, it uses native TypeScript and prints a notice. The runner supports project filtering and explicit compiler choices. Localization extraction uses the shared pinned Bun resolver, with a Node fallback. Project-specific typecheck scripts and contributor guidance now reflect the runner’s behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to bba90

The change is mergeable, but an integration test should protect the new automatic Bun path against future regressions.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main changes: pinning Bun as a development dependency and using it for typechecking. It is concise and specific.
Description check Passed The description includes all required sections and provides clear before-and-after behavior, rationale, testing details, scope notes, and checklist status. It identifies the linked issue as not applic…
Full details: Description check

Explanation

The description includes all required sections and provides clear before-and-after behavior, rationale, testing details, scope notes, and checklist status. It identifies the linked issue as not applicable for a maintainer and explains that remaining checks may be covered by CI.

Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments: 1
config/scripts/run-typecheck-projects-in-parallel.test.mjs: 1

148-164: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

The repository tests do not cover the CLI handoff from automatic compiler selection to the spawned Bun process. The selector test checks only the returned bunExecutable, while the runner tests do not reach Bun spawning or use the native compiler path. A localized integration assertion for the CLI-to-spawn boundary would protect this new behavior, but the evidence does not show a current production failure.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f3c892a-4e0a-4d83-98e2-3220712acb01
📥 Commits

Reviewing files that changed from the base of the PR and between 33e6785 and bba90e7.

📒 Files selected for processing: 6
  • .github/CONTRIBUTING.md
  • config/scripts/pinned-bun-executable.mjs
  • config/scripts/run-typecheck-projects-in-parallel.mjs
  • config/scripts/run-typecheck-projects-in-parallel.test.mjs
  • config/scripts/verify-localization-extraction.mjs
  • package.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

The PATH probe left anyone without the exact pinned Bun (including a 1.4.2
global) on tsc's expensive path. [email protected] is now a devDependency, its
postinstall is allowed, and pnpm tc / typecheck:ci run that binary. A missing
binary is an error pointing at pnpm install rather than a silent fallback;
--compiler=native still selects tsc. A test keeps the devDependency equal to
config/.bun-version.
@nwparker nwparker changed the title perf(typecheck): pnpm tc uses the pinned Bun checker when available perf(typecheck): pin Bun as a devDependency and typecheck with it Oct 18, 2026
--ignore-scripts leaves node_modules/.bin/bun as bun's postinstall stub, so the
typecheck runner found no binary and any pnpm-run script calling bun would hit
the stub before setup-bun's copy. pnpm rebuild bun runs only that allowed build.
@nwparker
nwparker merged commit dcfe8c9 into main Oct 18, 2026
57 checks passed
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