🚧 UNDER HEAVY CONSTRUCTION BECAUSE WORKERS UNIONIZED 🚧

Trying out Bun 1.0 - All-in-one JavaScript runtime & toolkit

Sunday, 10 September 2023 at 14.42
(Edited: 20/09/2023, 16.31)
Worth the hype? Weeeeeeell...
3 minute read
0 views

I use Windows :(

Yes, you can bully me 😓. I play vidya, I like them to work. I like to play kinda obscure older games and indies from itch.io, that don't always run on Linux.

I have dual boot Manjaro installed on my laptop, but it's basically broken. Machine is old, from like 2014, it can barely run a modern browser. I have not bothered setting up a dual boot on my desktop. But Windows is not completely terrible as it has:

Bun on WSL

So before I talk about Bun, I want to mention what I had to do to get it working properly in WSL 2.

  1. First thing I noticed: Hot reload was not working.

    1. Currently, inotify, the Linux API used by hot reload, is not supported in WSL2 on 9P filesystem drives (e.g. Windows drives mounted into WSL2).

    2. I fixed this by moving the project files into the ext4 filesystem in WSL2: /home/projects/

    3. Another fix would've been to use WSL 1

  2. In Windows Explorer, I could access this by typing this into the path bar:\\wsl.localhost\Ubuntu\home\{username}

    1. I changed my Github desktop location here too for the project.

    2. Oh, and if you are not using Github desktop: WHAT ARE YOU DOING?! 🤬 It removes like 99% of my problems when using git. I'm more of a visual guy, I struggle to keep tabs on a command line...

  3. bun --hot run dev working like a charm now! 😘

  4. No other issues encountered so far.

    1. Bun also seemingly fixed this bug I had, where @tailwindcss/typography kept uninstalling itself(?)



What is Bun?

Bun is an All-in-one Javascript runtime & toolkit. It can build your thing, bundle your thing, setup servers, do data fetching, do sqlite, you name it!

Their core philosophies are to increase speed and decrease complexity of the development tools people are using. Bun is a Webkit written in Zig.

It can completely replace Node.js for example. Like you don't need Nodemon as it has built-in watch mode. You also don't need dotenv or cross-env as Bun reads .env files by default. You can replace transpilers like babel. It is significantly faster at bundling compared to esbuild or webpack. And it even has an npm-compatible package manager, which can replace npm, yarn and pnpm. It caches the packages like pnpm, so your hard drives won't fill up on node_modules.

Bun even has stupid stuff like Auto-install, like listen to this:

If no node_modules directory is found in the working directory or higher, Bun will abandon Node.js-style module resolution in favor of the Bun module resolution algorithm.

Under Bun-style module resolution, all imported packages are auto-installed on the fly into a global module cache during execution (the same cache used by bun install).

Source

And it's fast AF.

fast af bun watch

bun bundling

bun memory benchmark

But is it true tho?

Well, I think Bun-team strategically picked what benchmarks to show, which focus almost solely on "development startups" and such.

Check this video by strager who did some actual benchmarking with using Bun in places where you actually care:

Needless to say: Bun has growing pains. Node is still FASTER than Bun in many of the use cases that matter. So while Bun isn't terrible, it's not as amazing as it is marketed as being.

Why Bun for Kire-web?

Bun supports Astro right out of the gate. That is cool & good!

Although, as my project is small, Bun is only like 1-2 seconds faster than npm. It's not super noticeable, but I think it's a good idea to keep using it, seeing how stable it truly is.

I also see potential in the "overarching" principle of Bun, the "1 tool for most things" sounds nice.


Please login to comment.

Comments: 0


Be the first to commment :)

Refresh counter test =
0