Add support for bun #5036
Replies: 4 comments 6 replies
-
|
I used bun to set up a project and install dependencies with Haven't looked into what would be required to swap node with bun though. |
Beta Was this translation helpful? Give feedback.
-
|
What's the status of this? Bun is now way more stable and way more compatible with Node.js ecosystem, yet there are some questions. We did some analysis and so far (AI) says: Details● Based on the exploration, here's what would be required to switch from Node to Bun: Key Node-specific Dependencies The develop command relies heavily on these Node APIs:
What Would Need to Change for Bun
Bun supports child_process.fork() but with some differences. You'd need to test IPC communication compatibility.
Bun does not support the cluster module. You'd need to:
Bun uses a different module system. Instead of require.cache, you'd use:
Bun has native Bun.FileSystemWatcher which could replace chokidar. Practical Path Forward The simplest approach: Bun can run Node apps with compatibility modebun --bun packages/medusa/src/commands/develop.ts However, for full Bun optimization, you'd need to modify:
Production Start - Node Dependencies The start command (packages/medusa/src/commands/start.ts) still uses:
Running Production with Bun Without clustering - Should work: or if medusa CLI is availablebun medusa start With clustering (--cluster flag) - Won't work due to cluster module. Quick Test You could try it now on an existing build: Build normallyyarn medusa build Try running with Buncd .medusa/server The main unknowns would be:
If you're not using --cluster, there's a good chance it works out of the box. Want me to check if there are any other Node-specific APIs in the core framework loaders that might cause issues? |
Beta Was this translation helpful? Give feedback.
-
|
I'm running medusa with bun and so far it's working well. The only thing is that you have to setup your project manually. |
Beta Was this translation helpful? Give feedback.
-
|
Since the version 2.13.0, MedusaJS is not working well with Bun anymore (in a monorepo). The breaking change with zod did something... Even with the isolated mode : Edit: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bun has recently launched with the goal to create a more user friendly js/ts development experience. It could also be a lot faster and more memory efficient, e.g., i sometimes run out of memory on my 8gb m1 macbook pro when i am running the backend and frontend both in development mode at the same time.
Installations of packages should be a lot faster as well with bun which is especially nice for deployments.
In general bun should give a much cleaner and less complex development experience and i think medusa could profit from this.
Has anyone already tried running medusa with bun?
Beta Was this translation helpful? Give feedback.
All reactions