Repository navigation
Description
Goal
Spike, not a migration. Measure whether moving parts of Octane's toolchain to Bun is worth doing, and produce numbers plus a go/no-go per area. Nothing here should be merged as a migration until the measurements exist.
Three separable areas, in increasing order of risk:
- Node scripts to Bun (low risk)
- TypeScript transpilation to Bun (medium)
- Vitest/Playwright to
bun test+Bun.WebView(high, likely a partial at best)
Why this is worth measuring
CI wall-clock is the motivation, so it is worth being precise about where time actually goes. From a recent heavy integration (package builds, eval corpus, runtime loaders, Astro) run, total 89s, the slowest items were:
rspeedy-pluginpacked-consumer build: 16.0srspeedy-plugindemo (dev command + bundle): 9.6svite-pluginclient-reference chunk mapping: 7.8srspeedy-plugin-browserweb-host: 5.1s
Those are esbuild/Rspack/Vite builds and browser launches, not test-runner overhead. The test shard (Node 24, 1-4/4) jobs finished at 10m38s / 10m33s / 8m38s / 8m35s, so there is also ~2min of idle tail from shard imbalance.
Hypothesis to falsify: runner startup overhead is a small fraction of Octane's CI time, so a runner swap yields far less than rebalancing shards or reusing builds. The spike should either confirm this and close the door, or produce numbers that contradict it.
Current surface (measured on main @ 27abffc26)
Test/runner coupling:
| Metric | Count |
|---|---|
vitest.config.js |
9,426 lines |
| Vitest projects | 393 |
Projects using the octane() Vite plugin |
278 |
resolve.alias blocks |
264 |
globalSetup hooks |
72 |
testExecution groups (react-parity sharding) |
220 |
Test files importing vitest |
1,961 |
.tsrx source files |
2,533 |
Files using vi.fn/vi.spyOn |
518 |
Files using vi.mock |
44 |
| Files using fake timers | 43 |
Files using expect.poll |
24 |
| Files using snapshots | 22 |
| Vitest browser-mode projects | 2 |
| Patched Vitest packages | 2 (@vitest/browser, @vitest/mocker) |
| Environments | 211 jsdom, 176 node, 2 happy-dom |
Runtime/transpile surface:
engines.node:>=22.22.2; CI pinsnode-version: 24;packageManager:[email protected]- 66 of 102 root scripts invoke
nodeornode --testdirectly - 67
scripts/*.mjs, of which 26 containnode:testsuites - Transpile-adjacent deps:
esbuild,typescript,@typescript/native-preview,@babel/core,@rolldown/plugin-babel,babel-plugin-react-compiler,babel-plugin-inferno,@tsrx/typescript-plugin,vite,vitest
Area 1 — Node scripts to Bun (low risk, start here)
The 67 scripts/*.mjs are plain ESM with few dependencies. scripts/reconcile-github-releases.mjs needs only semver. The 26 node:test suites are the interesting part: Bun implements a node:test shim, but coverage is not total.
Tasks:
- Run all 26
node --testsuites underbun --bun node --testand underbun test, record pass/fail/skip deltas - Time
node scripts/<x>.mjsvsbun scripts/<x>.mjsfor the 10 most-invoked scripts - Note any
node:API gaps hit (worker_threads, vm, async_hooks, perf hooks)
Exit criteria: a table of per-script timings and a list of incompatibilities. This area can likely land independently of the others.
Area 2 — TypeScript transpilation to Bun (medium risk)
The blocker is that .tsrx is not TypeScript. 2,533 .tsrx files are compiled by Octane's own compiler through its Vite plugin (packages/octane/src/compiler/vite.js), used by 278 of 393 projects. Bun's transpiler has no hook for a custom language, so bun build/bun test cannot consume .tsrx without a plugin that shells into the Octane compiler.
The differential tests raise the bar further: tests/differential/_setup.ts files compile each fixture twice, once for Octane and once with octane → react rewritten, so real React acts as a byte-level oracle. That dual-compile is the project's core correctness evidence and must not silently degrade.
Tasks:
- Prototype a Bun plugin (
Bun.plugin/bunfigpreload) that routes.tsrxthrough the existing compiler, and see whetherbun buildcan produce a working artifact for one small package - Compare
esbuildvsBun.buildon one package's build step, wall-clock and output size - Assess whether
@typescript/native-preview(already a dep) overlaps or competes with this - Explicitly evaluate: is
bun --bunin front of the existing Vite builds (example apps, website) a cheaper win than replacing the transpiler? This is the same trick already used elsewhere and carries no test-correctness risk.
Exit criteria: either a working .tsrx Bun plugin with a build-time comparison, or a written statement of exactly what blocks it.
Area 3 — Vitest/Playwright to bun test + Bun.WebView (high risk)
Expect a partial result. Known blockers, each needs a decision rather than a workaround:
- No Vite plugin pipeline in
bun test. 278 projects depend onoctane()running as a Vite plugin. This is the same blocker as Area 2 and gates almost everything. expect.pollhas no Bun equivalent (24 files).- Module mocking differs. 518 files use
vi.fn/vi.spyOn, 44 usevi.mock, 43 use fake timers. Bun'smock/jest.fnare close but not identical. - No per-project DOM environment. 211 jsdom + 2 happy-dom projects switch via config; Bun needs a
preloadregistering a global DOM instead. - Browser mode has no analogue. 2 projects run through
@vitest/browser-playwright, plus 2 local patches. Bun.WebViewis documented as experimental and cannot replace Playwright for Octane's cases:- No request interception.
packages/vite-plugin-octane/tests/production.test.tsusespage.route()to hold a module in flight and prove early SSR input survives; that gating is the test. webkitbackend is macOS-only and throws elsewhere. CI is Ubuntu, so every WebView run there is Chrome, losing the WebKit coverage that surfaced test(vite-plugin): fix webkit operation-completion poll flake #1240.- On Linux it still drives an installed Chrome over CDP, so the saving is the Playwright browser download, not the browser launch.
- No request interception.
Where WebView plausibly does fit: simple load-and-evaluate probes such as packages/syntax-highlighter/tests/browser/rendering.browser.test.ts (waitForFunction(() => Boolean(window.__syntaxHighlighterBrowser))), and the colorful/popper browser suites.
Tasks:
- Port one
environment: 'node'project with nooctane()plugin and no.tsrxfixtures tobun test; report wall-clock and any API gaps - Port one simple browser probe to
Bun.WebView; measure against the Playwright equivalent on Linux, not just macOS - Decide whether a mixed world (Bun for leaf unit projects, Vitest for compiler/differential/browser) is acceptable, or whether split tooling costs more than it saves
Exit criteria: two ported projects with numbers, plus a recommendation on partial adoption. Do not convert 1,961 files in this spike.
Non-goals
- Replacing pnpm. The workspace uses a catalog and
patchedDependencies; package management is a separate discussion. - Landing any migration. This issue produces measurements and a recommendation only.
- Dropping WebKit coverage to make WebView viable.
Deliverable
A comment on this issue with:
- A timing table per area (before/after, same hardware)
- An explicit go/no-go per area
- For any no-go, the specific blocker
- If total projected CI saving is under ~10%, say so plainly and recommend shard rebalancing and build reuse instead
Prior context
Timings and the WebKit interception dependency come from investigating the production.test.ts WebKit flake fixed in #1240.
Activity