feat(runtime): add Bun runtime compatibility#459
Merged
Conversation
Add runtime-detect.ts module that detects whether opencli is running under Bun or Node.js via globalThis.Bun check. Includes helper functions for version string and label formatting. Add corresponding unit tests that work correctly under both runtimes.
- doctor: show runtime label (e.g. 'node v22.13.0') in diagnostic output - package.json: add dev:bun, start:bun, test:bun convenience scripts - E2E helpers: support OPENCLI_TEST_RUNTIME env var for runtime selection
- ci.yml: add bun-test job using oven-sh/setup-bun@v2 - README.md: update Prerequisites to mention Bun, add Runtime Support section with usage examples for dev:bun, start:bun, test:bun
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.
Summary
Add dual-runtime support for opencli — both Node.js and Bun are now supported as JavaScript runtimes.
Changes
Phase 1: Runtime Detection Module
src/runtime-detect.ts— detects whether opencli runs under Bun or Node.js viaglobalThis.BundetectRuntime(),getRuntimeVersion(), andgetRuntimeLabel()helpersPhase 2: CLI Integration
node v22.13.0orbun 1.1.42) in diagnostic outputdev:bun,start:bun,test:bunconvenience scriptsOPENCLI_TEST_RUNTIMEenv var — run E2E tests under Bun withOPENCLI_TEST_RUNTIME=bun npm run test:e2ePhase 3: CI/CD + Documentation
bun-testjob usingoven-sh/setup-bun@v2to catch Bun compatibility regressionsTesting
npx tsc --noEmit— typecheck cleannpm test)bun vitest run --project unit)OPENCLI_TEST_RUNTIME=bun)npm run build)Why Bun?
tsccompilation needed for development