Bun v0.5.9

Ashcon Partovi · April 4, 2023

Bun v0.5.9 introduces watch mode using bun --watch, adds support for tarball dependencies in bun install, and fixes lots of bugs to improve stability and compatibility.

curl -fsSL https://bun.sh/install | bash
npm install -g bun
brew tap oven-sh/bun
brew install bun
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun

bun upgrade

Watch mode

Bun now supports watch mode using bun --watch, which auto-restarts your application when you make a change to your files. This is useful in development to quickly see changes you've made to your code. It's a builtin replacement for nodemon that is noticeably faster.

Run a file with bun --watch

Run tests with bun test --watch

Bun still supports bun --hot, which attempts to reload your application code without restarting the whole process. This is particularly useful when developing a server with Bun.serve, especially one long-lived connections like WebSockets. But in most cases --watch is a better general purpose tool.

Tarball dependencies

You can now use tarball dependencies in your package.json. Bun will download and install the package from the specified tarball URL, rather than from npm (or whichever package registry you have configured).

  "dependencies": {
    "zod": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz"

Use tarball URLs to include a dependency that is not in a registry or privately hosted.

Squashed bugs

We fixed a lot of bugs this release, here are a few interesting highlights.

  • The url.origin property is to "null" when the protocol is non-HTTP.
test("url.origin is null when protocol is non-http", () => {
  expect(new URL("https://example.com")).toHaveProperty(
  expect(new URL("file://path/to/file")).toHaveProperty("origin", "null");
  expect(new URL("about:blank")).toHaveProperty("origin", "null");
  • Set-Cookie headers are no longer de-duplicated.
test("headers can handle duplicate set-cookie headers", () => {
  const headers = new Headers([["Set-Cookie", "foo=bar"]]);
  headers.append("set-Cookie", "foo=baz");
    ["set-cookie", "foo=bar"],
    ["set-cookie", "foo=baz"],
  • An invalid Date now console.log() as "Invalid Date".
test("invalid date inspects as 'Invalid Date'", () => {
  expect(Bun.inspect(new Date("hello world"))).toBe("Invalid Date");
  • Node.js' util.isError() function now works for objects that are "Error-like".
test("util.isError() works for non-native errors", () => {
  const actual = util.isError({ name: "Error", message: "an error occurred" });
  • We also improved the Error messages when you import a Node.js module that has not been implemented yet in Bun, like node:http2 and node:vm.

Looking ahead

A new JavaScript bundler is coming, including builtin support for server components.


#2425Improved zsh completions to include directories by @JacksonKearl
#2429Updated moduleResolution to be "bundler" in tsconfig.json by @johnnyreilly
#2414Improved types for EventEmitter to be type-safe by @gaurishhs
58a5c2aFixed crash with export namespace ns { export class F {} } by @Jarred-Sumner
#2458Fixed various failing tests by @dylan-conway
#2459Fixed tests for undici by @ThatOneBro
#2463Fixed issue with npm registries that end with a "/" by @Jarred-Sumner
#2490Fixed incorrect port with HTTPS requests from http.request() by @cirospaciari
#2497Implemented tarball URL support in bun install by @alexlamsl
#2486Fixed more bugs, including escapeHTML() and util.isError() by @Jarred-Sumner
#2500Implemented watch mode: bun --watch by @Jarred-Sumner
#2501Fixed a crash from request.json() with a FormData body by @Jarred-Sumner
#2506Improved compatibility of yarn lockfile printer by @Validark
#2474Fixed bug with "Invalid Date" format by @adrien-zinger
#2519Fixed bug when re-installing a git dependency using bun install by @alexlamsl
#2534Added stubs for various unimplemented node modules, including v8, trace_events, repl, inspector, http2, diagnostics_channel, dgram, and cluster by @Jarred-Sumner
#2536Reduced concurrent HTTP connections during bun install by @alexlamsl


And finally, thank you to all the contributors from the community that helped improve Bun this release: @jq170727, @JacksonKearl, @johnnyreilly, @gaurishhs, @Fire-The-Fox, @bnzone, @JokerQyou, @andres039, @Validark, @adrien-zinger, @jakeboone02