DEV Community

Cover image for Why use Vite when Bun is also a bundler? - Vite vs. Bun

Why use Vite when Bun is also a bundler? - Vite vs. Bun

Magne on September 19, 2023

You might have heard that Bun is not just a runtime, but also a bundler. So you might wonder: Why do we need Vite or any separate bundler? Couldn'...
Collapse
 
husseinkizz profile image
Hussein Kizz

I think it's just too early to judge bun, it's still new and therefore has a lot of room for improvement, for example what woul bun 5 or 10.0 look like we should ask, let's not judge it now, the idea of having an all in one tool that handles the common js, es complexities is much more exciting for me and needs more exploration!

Collapse
 
eerk profile image
eerk • Edited

Thanks for this article, I was confused by Bun's own page and their statements that Bun can also be used for front-end development and front-end module bundling, while at the same time they don't give any clear examples. Manually adding Bun to Vite seems a bit unnecessary at the moment.

Collapse
 
redbar0n profile image
Magne This is Learning

Thanks. Use Bun with Vite if you want to replace Node.

Collapse
 
redbar0n profile image
Magne This is Learning • Edited

Bun and React Server Components (RSC):

Bun RSC readme: github.com/oven-sh/bun/tree/main/p...

Tweets:

Collapse
 
redbar0n profile image
Magne This is Learning • Edited

Update 2023-10-05:

Rolldown (a Rust based bundler) will replace Rollup and esbuild in Vite.

Update 2024-03-09:

Check out their landing page About section: rolldown.rs/about

Collapse
 
redbar0n profile image
Magne This is Learning • Edited

Collapse
 
redbar0n profile image
Magne This is Learning

Bun has some interesting potential for React Native:

Collapse
 
devinrhode2 profile image
Devin Rhode

Also Bun does not support React Fast Refresh, which is the best way to develop with HMR (github.com/oven-sh/bun/issues/18)

Collapse
 
savyjs profile image
Savy

do you guys get errors too?

I tried it twice, Strapi and Nuxt and both times got error

Collapse
 
ahmedmustafa2201 profile image
Ahmed Mustafa

does bun will replace node.js as expected with Vite without any limitations?

Collapse
 
redbar0n profile image
Magne This is Learning • Edited

It should work, but your experience may vary.

Here is the resolved Vite issue on the Bun repo:

github.com/oven-sh/bun/issues/250

See also the last part of the above article for a mention of Bun’s currently missing support for some Node API’s (like crypto).