Bun 1.6 is out with new JavaScript/TypeScript bundler and ability to compile standalone executables

Bun 1.6 is out with new JavaScript/TypeScript bundler and ability to compile standalone executables

The team behind the Bun JavaScript runtime – led by Jarred Sumner – has released version 0.6, including a new JavaScript and TypeScript bundler and minifier, along with the ability to create standalone executables.

According to Sumner, “the bundler is just the beginning of a larger project. In the next couple months, we’ll be announcing Bun.App — a ‘super-API’ that stitches together Bun’s native-speed bundler, HTTP server, and file system router into a cohesive whole.” The bundler includes a plugin API that can also be used at runtime.

Sumner’s pitch is that “today, bundlers are a source of immense complexity in the JavaScript ecosystem. By bringing bundling into the JavaScript runtime, we think we can make shipping frontend and full-stack code simpler and faster.”

Sumner claims that the Bun bundler is “1.75x faster than esbuild, 150x faster than Parcel 2, 180x times faster than Rollup + Terser, and 220x times faster than Webpack” – though note that it does not have feature equivalence. The bundler has two target types: “browser” which transpiles TypeScript and JSX (React components) to JavaScript, and “bun” which leaves Bun and Node.js APIs untounched. A third target type, “node”, will in future polyfill Bun APIs for running with Node.js. Other bundler features include tree shaking (removing unused code) and minifying.

Bun 0.6 with new commands including build for standalone executables

The bun test command now shows the length of time for each test and highlights slow tests in yellow. The parser has added support for TypeScript 5.0.

Bun is based on Apple’s JavaScriptCore, in contrast to Node.js and Deno which use Google’s V8 engine. Another key difference is that Bun is written in Zig, a small language which features manual memory management and fast native code compilation.

We tried using Bun’s new build command to compile a Hello World TypeScript file to a standalone executable. It worked, but the executable is about 90MB, because of the inclusion of the Bun runtime – bigger than most alternatives for this type of bundling, but it is early days.

How will Bun be monetized? “The plan is JavaScript edge hosting focused on fast cold starts and being extremely inexpensive, using lots of custom infrastructure,” said Sumner on Hacker News.

Bun is still in development and impresses with its speed and simplicity, though it does not appear to be usable yet. “I deployed a small non critical service with bun. So far constant (but slow) memory leaks and an 80% chance of segfault when starting up. Will try a few more versions of bun then move it to node for a while until bun matures a bit,” observed one developer. No Windows support yet, though it runs fine in WSL (Windows Subsystem for Linux).