oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73k stars 2.66k forks source link

Feature Request: Embedding Bun within other native applications (like a Rust program) #12017

Open alshdavid opened 2 months ago

alshdavid commented 2 months ago

What is the problem this feature would solve?

Many native projects would like to be able to embed a JavaScript runtime that can leverage the Nodejs ecosystem and Nodejs standard library.

What is the feature you are proposing to solve the problem?

Offer a dynamic C library (or a Rust crate) that allows Bun to be embedded within another native application

What alternatives have you considered?

0xF6 commented 2 months ago

+1 from my side cases: adding bun as a scripting provider to game engines

DoctorGester commented 3 weeks ago

@0xF6 I was looking for that as well.

Basically what I think Bun could do there:

  1. Offer an option to bun build --compile into a shared library instead of an exe, this shouldn't be too complicated.
  2. Extend bun ffi to also work backwards, i.e. define exported C ABI functions from javascript.
bayasdev commented 2 days ago

+1