The best feature of Bun is not performance-related
Michał Kuncio
Posted on September 12, 2023
What is Bun?
Oh, you know what it is 😉 Let's skip this SEO filler and get straight to the point. The best feature of Bun is how it handles...
Module resolution
Anyone who has tried using Node.js with ESM or Typescript surely knows what I'm talking about.
- should I use JS or MJS extension?
- if so should I use
type: module
inside package.json? - should I use
node --experimental-modules
flag while running the app? - ok but what about TypeScript? We have
compilerOptions.module
there... - and what If I want to mix ESM and CJS?
The list goes on and on...
In Bun, you can forget about that madness.
- Want to use ESM? Bun handles it
- Want to use CJS? Bun handles it
- Want to use JSX/TSX out of the box? Bun handles it
⭐️ And the most important thing:
You can mix ESM and CJS imports inside a single file! 🤯
import StuffESM from "./some-esm-module";
const StuffCJS = require("./some-cjs-module.cjs");
This can be really handy while using some non-ESM node/express packages.
Summary
I'm excited about the future of Bun. It has many great features that are widely discussed in the tech space right now. I'm happy that we have 3 serious runtimes (Node, Deno, Bun) because the competition between them should be beneficial to everyone. Don't want to make a switch to Bun/Deno? Thanks to that competition, Node will probably be much better in the next versions and you won't have to switch. Exciting times ahead!
⭐ If you like my posts, please follow me on Twitter:
https://twitter.com/michalkuncio
Posted on September 12, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.