← Back to PRs

#6863: feat: add bun runtime support as opt-in feature

by aashishsingla567 open 2026-02-02 04:09 View on GitHub →
scripts
## Summary Adds opt-in support for [Bun](https://bun.sh/) as an alternative runtime to Node.js. Bun offers faster startup times and built-in TypeScript support, which can improve the development experience for openclaw users. ## What is this? This PR enables a "Bun Runtime" opt-in feature for openclaw. Users can now choose to run openclaw with Bun instead of Node.js for potentially faster execution. ## Changes ### New Files - `scripts/run.mjs` - Runtime-agnostic runner that detects OPENCLAW_RUNTIME env var - `scripts/get-runtime.mjs` - Runtime detection utility - `openclaw-bun.mjs` - Bun-optimized entry point ### Modified - `package.json` - Added bun variants of key scripts: - `dev:bun`, `start:bun`, `openclaw:bun` - `gateway:dev:bun`, `tui:bun`, `tui:dev:bun` - Updated existing scripts to use `scripts/run.mjs` (backward compatible) ## Usage ### Opt-in via environment variable: ```bash export OPENCLAW_RUNTIME=bun pnpm run openclaw ``` ### Or use the explicit bun scripts: ```bash pnpm run dev:bun pnpm run start:bun pnpm run openclaw:bun pnpm run gateway:dev:bun pnpm run tui:bun ``` ## Benefits - **Faster startup**: Bun has significantly faster cold start times - **Native TypeScript**: No need for tsx/ts-node for some operations - **Drop-in replacement**: Existing Node.js workflow unchanged (opt-in only) ## Backward Compatibility - Default runtime remains Node.js (no breaking changes) - All existing scripts work exactly as before - Bun is strictly opt-in via `OPENCLAW_RUNTIME=bun` or `*:bun` scripts ## Testing - [x] Format/lint checks pass - [ ] Unit tests pass with Node (default) - running - [ ] Unit tests pass with Bun runtime - [ ] E2E tests pass --- ## 🤖 Prompt to Generate This PR If you want an AI assistant to generate this same PR, use this prompt: ``` I want to add Bun runtime support to openclaw as an opt-in feature. Requirements: 1. Create a runtime-agnostic runner script (scripts/run.mjs) that: - Detects OPENCLAW_RUNTIME=bun environment variable - Defaults to node for backward compatibility - Validates bun is installed when requested - Handles the build process appropriately for each runtime 2. Create scripts/get-runtime.mjs for runtime detection 3. Create openclaw-bun.mjs as a bun-optimized entry point 4. Update package.json to: - Replace node scripts/run-node.mjs with node scripts/run.mjs in existing scripts - Add bun variants: dev:bun, start:bun, openclaw:bun, gateway:dev:bun, tui:bun, tui:dev:bun - Follow existing naming conventions (e.g., gateway:dev:bun pattern) 5. Ensure: - Format checks pass (pnpm run format:fix) - Backward compatible (node remains default) - Clear error message if bun not found but OPENCLAW_RUNTIME=bun is set 6. Create branch feat/bun-runtime-optin, commit, push to fork, create PR against openclaw/openclaw The PR title should be: feat: add bun runtime support as opt-in feature ``" --- **Note for maintainers:** This is a developer-experience improvement. Bun support is opt-in only with no breaking changes to existing Node.js workflows.

Most Similar PRs