Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Bun Runtime #462

Open
Barzi-Ahmed opened this issue Jan 29, 2025 · 2 comments
Open

Support Bun Runtime #462

Barzi-Ahmed opened this issue Jan 29, 2025 · 2 comments

Comments

@Barzi-Ahmed
Copy link

Currently, when trying to run a One project using Bun runtime via this command "bun run --bun dev" (without using --bun, Bun will use Node.js implicity, that is how it's built, unfortunately). This is the output and error message:

mypc@My-Mac-mini myap % bun run --bun dev
$ one dev
Failed to find Response internal state key

 ⚡ Million Lint v1.0.14
 ✓ Ready in 0.04ms

[one] Scanning node_modules to auto-optimize...
[one] Enabled babel plugins: Reanimated

    ➡ [tamagui] built config and components (142ms)
[vite] connected.

Server running on ⪢

  ➜  Local:   http://localhost:8081/
  ➜  Network: http://192.168.100.201:8081/

› Press ow │ open web
› Press oi │ open app in iOS Simulator
› Press oa │ open app in Android Emulator
› Press oe │ open editor
› Press qr │ show Expo Go QR code
› Press dt │ open React Native DevTools
› Press ?  │ show this menu

 ⓵  [ssr] http://localhost:8081/ resolved to app/index.web.tsx
thread '<unnamed>' panicked at napi/src/threadsafe_function.rs:235:57:
called `Result::unwrap()` on an `Err` value: Error { status: InvalidArg, reason: "expect Function, got: Object", maybe_raw: 0x0 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: script "dev" was terminated by signal SIGABRT (Abort)
zsh: abort      bun run --bun dev
mypc@My-Mac-mini myapp % 
@natew
Copy link
Collaborator

natew commented Jan 31, 2025

Is Bun compat with SWC? That's the only Rust I know we have in our codebase. It was working at some point too so wonder when it regressed. We should get Bun tests into CI, if you want to help with that.

@redbar0n
Copy link

— Did a bit of research with Grok, here’s the gist:

  • Bun Plugin with SWC: There’s a community project, bun-plugin-swc, which allows you to use SWC as a transpiler within Bun for specific use cases. For instance, as of September 2023, Bun didn’t support ‘emitDecoratorMetadata’, a TypeScript feature critical for frameworks like NestJS. The bun-plugin-swc plugin addressed this by using SWC to transpile TypeScript code and then passing it to Bun’s JavaScript loader.

  • Custom Workflows: You could also use SWC independently to compile your code (e.g., with @swc/core) and then run the resulting JavaScript with Bun. This is less common since Bun’s built-in transpiler is already very fast, but it’s an option if SWC’s feature set better suits your project.

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

No branches or pull requests

3 participants