Bun

Bun v0.5.6


Ashcon Partovi · February 9, 2023

Bun v0.5.6 introduces Bun.sleep, improves Docker support, and makes various improvements to Node.js and npm compatibility.

# Install using curl
curl -fsSL https://bun.sh/install | bash

# Install using npm
npm install -g bun

# Install using Docker (New!)
docker pull oven/bun:latest

# Upgrade
bun upgrade

Bun.sleep

Bun now supports Bun.sleep(). This provides a quick and easy API to defer execution without using setTimeout().

// This:
await Bun.sleep(100);

// Instead of this:
await new Promise((resolve) => {
  setTimeout(resolve, 100);
});

You can also specify a Date, which will sleep until the given date.

const date = new Date(2024, 01, 01);
await Bun.sleep(date); // sleep until next year

Docker image: oven/bun

Bun has a new and improved Docker image: oven/bun The base image is Debian and supports both x64 and arm64 architectures.

Here's an example of a Dockerfile that uses Bun.

FROM oven/bun

ADD src src
ADD package.json package.json
ADD bun.lockb bun.lockb
RUN bun install

CMD bun src/index.js

Node.js compatibility improvements

bun install improvements

  • Fixed issues when hoisting peerDependencies
  • Fixed binaries not being linked when the package was in a workspace
  • Fixed an issue where bun install would download the last modified tag, instead of the latest tag
  • Fixed an issue when installing packages with the npm: prefix
  • Changed workspaces to not resolve recursively (matches what npm does)

Thanks to @alexlamsl fixing these issues!

Changelog

b7c96bfFixed "illegal instruction" when using db.prepare() in bun:sqlite
#2000Fixed corner cases with aliases dependencies by @alexlamsl
#2011Fixed issues when hoisting peerDependencies by @alexlamsl
#2016Fixed the latest tag being incorrect on bun install by @alexlamsl
#2003Fixed various bugs in bun-types by @colinhacks
#1972Fixed more bugs in bun-types by @gaurishhs
#1998Exposed fs.Dirent and fs.Stats by @michalwarda
b12762aMade fs.Stat functions faster by @Jarred-Sumner
#1982Added types for node:console and node:perf_hooks by @colinhacks
#1997Fixed URL of wasi-js by @TerrorJack
#1996Fixed bug with uWebSockets by @cirospaciari
#2013Fixed incorrect version being printed by @RobViren