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
- Implemented
isDeepStrictEqual
innode:util
- Implemented
os.cpus()
on Linux, thanks to @jwhear - Fixed
fs.Dirent
andfs.Stats
not being exported as classes, thanks to @michalwarda - Fixed an issue when importing
node:perf_hooks
usingrequire()
- Fixed an issue when importing WebCrypto from
node:crypto
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
b7c96bf | Fixed "illegal instruction" when using db.prepare() in bun:sqlite |
#2000 | Fixed corner cases with aliases dependencies by @alexlamsl |
#2011 | Fixed issues when hoisting peerDependencies by @alexlamsl |
#2016 | Fixed the latest tag being incorrect on bun install by @alexlamsl |
#2003 | Fixed various bugs in bun-types by @colinhacks |
#1972 | Fixed more bugs in bun-types by @gaurishhs |
#1998 | Exposed fs.Dirent and fs.Stats by @michalwarda |
b12762a | Made fs.Stat functions faster by @Jarred-Sumner |
#1982 | Added types for node:console and node:perf_hooks by @colinhacks |
#1997 | Fixed URL of wasi-js by @TerrorJack |
#1996 | Fixed bug with uWebSockets by @cirospaciari |
#2013 | Fixed incorrect version being printed by @RobViren |