Bun v0.6.0

Jarred Sumner · May 16, 2023

We're hiring C/C++ and Zig engineers to build the future of JavaScript! See job listings →

This is the biggest release of Bun yet.

Bun now has a built-in JavaScript and TypeScript bundler and minifier. Use it to bundle frontend apps or bundle your code into a standalone executable.

We've also been busy improving performance and fixing bugs as-per usual: writeFile() gets up to 20% faster on Linux, lots of bug fixes to Node.js compatiblity and Web API compatiblity, support for TypeScript 5.0 syntax, and various fixes to bun install.

Bun's new JavaScript bundler & minifier

The focus of this release is Bun's new JavaScript bundler, but 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.

It can be used using the bun build CLI command or the new Bun.build() JavaScript API.

  entrypoints: ["./src/index.tsx"],
  outdir: "./build",
  minify: true,
  // ...
bun build ./src/index.tsx --outdir ./build --minify

To learn more, check out our blog post introducing the Bun bundler.

Standalone executables

You can now create standalone executables with bun build.

bun build --compile ./foo.ts

This lets you distribute your app as a single executable file, without requiring users to install Bun.


You can also minify it to improve startup performance for large apps:

bun build --minify --compile ./three.ts
  [32ms]  minify  -123 KB (estimate)
  [50ms]  bundle  456 modules
 [107ms] compile  three

This is powered by Bun's new JavaScript bundler and minifier.


You can now use import.meta.main to check if the current file is the entry point that started bun. This is useful for CLIs to determine if the current file is what started the app.

For example, if you have a file called index.ts:


And you run it:

$ bun ./index.ts

But if you import it:

import "./index.ts";

And run it:

$ bun ./other.ts

Improvements to bun test

  • bun test now reports time taken to run tests
  • describe.skip has been implemented (thanks to _yogr)

  • expect().toBeEven() and expect().toBeOdd() has been implemented (thanks to will-richards-ii)

Faster fs.writeFile on Linux

Transpiler improvements

This release also introduces many improvements to the transpiler. Here are some of the highlights:

  • Parser support for TypeScript 5.0.
  • Parser support for import attributes.
  • Some npm packages threw "ReferenceError: Cannot access uninitialized variable" errors on import due to a bug with cyclical imports in Bun's transpiler. This has been fixed.
  • Support for // @jsx, // @jsxImportSource, and // @jsxFragment comments.
  • Dead code elimination for unused global constructor function calls like new Set().
  • String template literal concatenation like foo${1}${"2"}${'3'} -> foo123.
  • Parser bugfixes for the deprecated ES5 with statement.

A big thanks to @kzc for many helpful bug reports.

Node.js compatibility

  • tls.Server has basic support (previously, not implemented)
  • fs.promises.constants is now exported correctly (previously, it was missing)
  • node:http's server module now (correctly) accepts a callback argument
  • Timer.refresh() now works as expected
  • Fixed mkdtemp and mkdtempSync errors

Web API compatibility

  • new Request("http://example.com", otherRequest).url would previously return the url of otherRequest instead of "http://example.com". This has been fixed.
  • Bun.file(path).lastModified has been added, which is similar to the File API's lastModified property
  • Supported redirect: "error" in fetch()
  • Fixed fetch.bind, fetch.call, and fetch.apply not working


#2556Implemented import.meta.main by @Jarred-Sumner
#2561Removed Object.prototype from node:path exports by @privatenumber
#2557Fixed Bun.deepEquals() with accessors and holed arrays by @dylan-conway
#2554Fixed issues with fetch({ proxy }) by @cirospaciari
#2491Implemented BunFile.lastModified by @zhongweiy
#2567Fixed constants export from node:fs/promises by @paperdave
#2552Implemented basic support for tls.Server by @cirospaciari
#2593Implemented support for TypeScript 5.0 syntax by @Jarred-Sumner
#2652Improved performance of crypto.createHash() by @paperdave
#2661Fixed a bug where expect().toBeFalsy() did not increment assertions by @will-richards-ii
#2673Implemented support for axios by @Jarred-Sumner
9e1745eFixed a bug with path.dirname() would return the wrong path for the root by @Jarred-Sumner
#2728Fixed bun add <github> by @alexlamsl
3c4f092remove by @Jarred-Sumner
5353d41Fixed incorrect value for modulo with negative operands by @Jarred-Sumner
#2748Fixed crash with invalid JavaScript by @Jarred-Sumner
#2759Improved performance of open() and writeFileSync() by @Jarred-Sumner
#2761Fixed incorrect output from Hash.copy() by @silversquirl
396416aFixed crash from invalid input in fetch() by @Jarred-Sumner
#2780Fixed a bug with repeated bun install of a GitHub dependency by @alexlamsl
#2781Fixed a bug where devDependencies did not resolve from a local dependency by @alexlamsl
#2754Implemented expect().toBeEven() and expect().toBeOdd() by @will-richards-ii
c43c1b5Implemented ClientRequest.setNoDelay() by @Electroid
f95a81eFixed a crash in napi_create_external_buffer by @Jarred-Sumner
c7c5dc1Implemented BunFile.name by @Jarred-Sumner
#2834Fixed a bug where bun install --cwd was not working correctly by @alexlamsl
#2841Changed bun add to ignore invalid workspaces by @alexlamsl
#2843Fixed a crash during WebSocket.close() by @cirospaciari
#2842Fixed fetch.bind is not a function by @cirospaciari
#2845Implemented fetch({ redirect: "error" }) by @cirospaciari
#2836Implemented describe.skip() by @blackmann
5ffee94Added timings to each test in bun test by @Jarred-Sumner
#2846Implemented dns.lookup({ all: true }) by @cirospaciari
#2851Fixed suprious errors with mkdtemp() and mktempSync() by @cirospaciari
5c08200Changed node:http to handle errors better from fetch() by @Jarred-Sumner
#2850Fixed Bun.spawn() with a large stdout by @cirospaciari
#2869Fixed node:path for Windows by @paperdave
#2879Implemented support for generating standalone Bun executables by @Jarred-Sumner
#2866Implemented Uint8Array support for Bun.spawn() stdout by @cirospaciari
#2881Fixed bug where Request.url was incorrect by @Jarred-Sumner


And finally, thank you to all the contributors from the community that helped improve Bun this release: @privatenumber, @Lawlzer, @jakeboone02, @zhongweiy, @xHyroM, @rmorey, @marktani, @Kruithne, @will-richards-ii, @simon04, @alexlamsl, @flakey5, @MaanuVazquez, @Plecra, @silversquirl, @beeburrt, @aquapi, @blackmann, @Fire-The-Fox