feat: add Bun runtime support - #820
Open
N0SAFE wants to merge 1 commit into
Open
Conversation
N0SAFE
force-pushed
the
feat/add-bun-runtime
branch
from
September 8, 2026 19:24
8fa7bc3 to
67cb60c
Compare
Add support for running Vitest tests with the Bun runtime. Bun v1.4 added native Vitest support including --coverage with threads and forks pools. Changes: - Add 'bun' to vitest.runtime configuration enum - Extend WorkerInitMetadata.runtime and VitestPackage.runtime types - Auto-detect Bun projects via bun.lock, bun.lockb, or bunfig.toml - Pass --bun flag to Bun when spawning processes (replaces Node.js APIs) - Support bun in child_process, terminal, and debug modes - Add Bun version guard: require Bun >= 1.4.0 for Vitest support - Add Bun sample project for testing Refs: vitest-dev#473
N0SAFE
force-pushed
the
feat/add-bun-runtime
branch
from
September 8, 2026 19:26
67cb60c to
2e08865
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add support for running Vitest tests with the Bun runtime. Bun v1.4 added native Vitest support including
--coveragewith threads and forks pools (blog post).Closes #473
Changes
'bun'tovitest.runtimeenum ('auto' | 'node' | 'deno' | 'bun')WorkerInitMetadata.runtimeandVitestPackage.runtimetypes to include'bun'guessRuntime()to auto-detect Bun projects by checking forbun.lock,bun.lockb, orbunfig.toml--bunflag when spawning Bun processes (this flag tells Bun to replace Node.js APIs with native implementations)findRuntimeExecutable()to resolve thebunexecutable--bunruntime argument for debugging with Bunsamples/bun/for testingHow it works
When
vitest.runtimeis set to'bun'(or auto-detected), the extension will:bunexecutable on the system PATH--bunflag when spawning the Vitest worker processv8.serializeuses JavaScriptCore's wire format, not V8's format)The
--bunflag is critical — it makes Bun replace Node.js APIs with its native implementations, which is required for Vitest compatibility.v8.serialize/v8.deserialize Note
Bun does have
v8.serializeandv8.deserializefunctions, but they use JavaScriptCore's wire format instead of V8's binary format. This means data serialized with Bun is NOT compatible with Node.js, so we use JSON serialization (same approach as Deno).Testing
pnpm typecheck)pnpm build)References