The Bun team has declared its JavaScript/TypeScript runtime stable with the release of version 1.0, staking strong claims for speed, integration and compatibility.
“Bun is a complete toolkit for building, running testing and debugging JavaScript and TypeScript, from a small script to a full stack server-side rendered application,” said creator Jarred Sumner in a video presentation. It is designed to be compatible with Node.js, though with plenty of limitations currently, such that its claim of being a “drop in replacement” is questioned by developers; but many commands and APIs do work. Unlike Node.js, Bun uses Apple’s JavaScriptCore engine and is built with Zig.
Bun can run TypeScript as well as JavaScript, but does so without typechecking, defeating much of the purpose of using TypeScript. However developers can continue to use tsc, the TypeScript compiler, alongside Bun.
One of the distinctive Bun features is that it supports both ES (EcmaScript) modules, which have direct browser support, as well as CommonJS, the older module system. The team argues that CommonJS is so deeply ingrained in the ecosystem that it is wrong not to support it. “We will never hit a point where all packages can be expected to use ES modules,” he said.
The Bun developers make bold claims for speed. The release post states that bun installs packages 29 times faster than npm (Node Package Manager); that it is 13 times faster than Jest for JavaScript testing; and 1.75 times faster than esbuild for bundling.
Newly introduced at the launch of Bun is a Windows build, described as “highly experimental”. Until now, Bun has only worked on Mac, Linux, and within Windows Subsystem for Linux (WSL). That said, “only the JavaScript runtime is supported; the package manager, test runner, and bundler have been disabled until they are more stable,” according to the team.
Supported frameworks now include Next.js, Astro and Nest.js. Other frameworks that work with Bun include Nuxt, SvelteKit and Vite.
Bun has joined Deno as an attempt to build a better runtime than Node.js, the established incumbent. A Node-based development environment tends to involve a collection of different tools such that it becomes hard to manage, and both Bun and Deno simplify this. Bun has leaned more towards compatibility with both Node.js and CommonJS, than Deno has, which is a plus for many developers. “We’re a full-stack TypeScript shop, and I manage ~50 internal libs and ~500K LOC of TS. Last month I tested out both Deno and Bun as alternative runtimes for us. TLDR: for any semi-complex codebase we have, Bun almost always works, Deno almost never works,” remarked one developer.
That said, despite the 1.0 label, Bun is new and some feel it is too early to rely on it. The performance claims too are not as good as they first appear under scrutiny, though most still find that Bun performs well, and overall this first release has been well received.