Bun bun-v0.0.79stable Released May 04, 2022
โš ๏ธ Breaking Change Impact Score: 7/10

bun v0.0.79

Source available โ€” automated, not human-reviewed

Component: bun ยท Channel: stable. Automated analysis, not a compatibility certification. How this works.

Analysis updated: 2026-11-01.

Breaking-change evidence from the source

  • - `Buffer` (like in Node.js) is now a global, but the implementation is incomplete - [see tracking issue](https://github.com/Jarred-Sumner/bun/issues/155). If you import `"buffer"`, it continues to use the browser polyfill so this shouldn't be a breaking change
Read the original context โ†—
Source flags breaking changes โ€” review applicability
๐Ÿ“„ .MD
โšก Executive Summary (TL;DR)

Bun bun-v0.0.79. Source highlight: If you run into any issues with upgrading

Who Does This Impact? (Role-Based Analysis)

๐Ÿ’ป Software Engineers & Devs

Check the source notes against the package and APIs you use before upgrading.

๐Ÿ“Š Product & Engineering Leads

Use the documented changes to assess relevance to your product; release frequency alone is not a quality measure.

โš™๏ธ DevOps & Security

Verify the target version, runtime requirements and rollback procedure in the official documentation.

โš ๏ธ Breaking Changes & Deprecations (1)

  • - `Buffer` (like in Node.js) is now a global, but the implementation is incomplete - [see tracking issue](https://github.com/Jarred-Sumner/bun/issues/155). If you import `"buffer"`, it continues to use the browser polyfill so this shouldn't be a breaking change

โœจ New Features & Capabilities (2)

  • @jameslahm [[node] Add more fs constants](https://github.com/Jarred-Sumner/bun/commit/64a2dda02f7647a506c22057fd4659bd8856ea08)
  • [[bun.js] Add Bun.nanoseconds() to report time in nanos](https://github.com/Jarred-Sumner/bun/commit/69668d49e5ddb5169eae7966d8a30e9ae9e32cea)

๐Ÿ”ง Bug Fixes & Patches (6)

  • 2x faster `TextEncoder` & `TextDecoder` thanks to some fixes to the vectorization (SIMD) code
  • Faster `TypedArray.from`. JavaScriptCore's implementation of `TypedArray.from` uses the code path for JS iterators when it could instead use an optimized code path for copying elements from an array, like V8 does. I have filed an upstream bug with WebKit about this, but I expect to do a more thorough fix for this in Bun and upstream that. For now, Bun reuses `TypedArray.prototype.set` when possible
  • Fixed a reliability bug with `new Response(Bun.file(path))`
  • [[bun.js] Fix bug with readdirSync on folders with less than 32 files](https://github.com/Jarred-Sumner/bun/commit/f2c21b77336b9dcfa90676670877790ee48b31cc)
  • [[bun dev] Fix CSS HMR bug](https://github.com/Jarred-Sumner/bun/commit/1788503892d27027b584542c2966daac06308c93)
  • [[JS Parser] Fix overly-eager CJS -> ESM transform](https://github.com/Jarred-Sumner/bun/commit/ea241fcec7add6187ec915ed0b3983f3be0529f9)
๐Ÿ“„ View Raw Release Notes (Original Developer Log)
To upgrade: ```bash bun upgrade ``` <details><summary>If you run into any issues with upgrading</summary> Try running this: ```bash curl https://bun.sh/install | bash ``` </details> ## Highlights - `"bun:ffi"` is a new bun.js core module that lets you use third-party native libraries written in languages that support the C ABI (Zig, Rust, C/C++ etc). It's like a [foreign function interface](https://en.wikipedia.org/wiki/Foreign_function_interface) API but faster - `Buffer` (like in Node.js) is now a global, but the implementation is incomplete - [see tracking issue](https://github.com/Jarred-Sumner/bun/issues/155). If you import `"buffer"`, it continues to use the browser polyfill so this shouldn't be a breaking change - 2x faster `TextEncoder` & `TextDecoder` thanks to some fixes to the vectorization (SIMD) code - [Faster `TypedArray.from`](https://github.com/Jarred-Sumner/WebKit/commit/def720fd3a13399a54acb86f20145834593e153f). JavaScriptCore's implementation of `TypedArray.from` uses the code path for JS iterators when it could instead use an optimized code path for copying elements from an array, like V8 does. I have filed an upstream bug with WebKit about this, but I expect to do a more thorough fix for this in Bun and upstream that. For now, Bun reuses [`TypedArray.prototype.set` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) when possible - [17x faster `Uint8Array.fill`](https://twitter.com/jarredsumner/status/1517786327550283776) - `Bun.Transpiler` gets an API for removing & replacing exports - `SHA512`, `SHA256`, `SHA128`, and more are now exposed in the `"bun"` module and the `Bun` global. They use BoringSSL's optimized hashing functions. - Fixed a reliability bug with `new Response(Bun.file(path))` - Bun's HTTP server now has a `stop()` function. Before, there was no way to stop it without terminating the process ๐Ÿ˜† - @evanwashere [expose mmap size and offset option](https://github.com/Jarred-Sumner/bun/commit/95aa76b9fae3747a72c2db460d42c38b7faaee2a) - @jameslahm [[node] Add more fs constants](https://github.com/Jarred-Sumner/bun/commit/64a2dda02f7647a506c22057fd4659bd8856ea08) The next large project for bun is a production bundler [Tracking issue](https://github.com/Jarred-Sumner/bun/issues/156) ## New Contributors * @jameslahm made their first contribution in https://github.com/Jarred-Sumner/bun/pull/144 * @lawrencecchen made their first contribution in https://github.com/Jarred-Sumner/bun/pull/151 ## bun:ffi The `"bun:ffi"` core module lets you efficiently call native libraries from JavaScript. It works with languages that support the C ABI (Zig, Rust, C/C++, C#, Nim, Kotlin, etc). Get the locally-installed SQLite version number: ```ts import { dlopen, CString, ptr, suffix, FFIType } from "bun:ffi"; const sqlite3Path = process.env.SQLITE3_PATH || `libsqlite3.${suffix}`; const { symbols: { sqlite3_libversion }, } = dlopen(sqlite3Path, { sqlite3_libversion: { returns: "cstring", }, }); console.log("SQLite version", sqlite3_libversion()); ``` FFI is really exciting because there is no runtime-specific code. You don't have to write a Bun FFI module (that isn't a thing). Use JavaScript to write bindings to native libraries installed with homebrew, with your linux distro's package manager or elsewhere. You can also write bindings to your own native code. FFI has a reputation of being slower than runtime-specific APIs like napi โ€“ but that's not true for `bun:ffi`. ![image](https://user-images.githubusercontent.com/709451/166693732-4cb7105b-8cb2-4b33-a85e-6b538cb3ea45.png) Bun embeds a small C compiler that generates code on-demand and converts types between JavaScript & native code **inline**. A lot of overhead in native libraries comes from function calls that validate & convert types, so moving that to just-in-time compiled C using engine-specific implementation details makes that faster. Those C functions are called [directly](https://github.com/Jarred-Sumner/bun/blob/5cee316d8c21b0264ef200c1abeab2b4b5e446fd/src/javascript/jsc/bindings/JSFFIFunction.cpp#L71-L72) โ€“ there is no extra wrapper in the native code side of things. Some `bun:ffi` usecases: - SQLite client - Skia bindings so you can use Canvas API in bun.js - Clipboard api - Fast ffmpeg recording/streaming - Postgres client (possibly) - Use Pythons `"ndarray"` package from JavaScript (ideally via ndarray's C API and not just embedding Python in bun) Later (not yet), bun:ffi will be integrated with bun's bundler and that will enable things like: - Use hermes to strip Flow types for code transpiled in bun - .sass support ## Buffer A lot of Node.js' [Buffer](https://nodejs.org/api/buffer.html) module is now implemented natively in Bun.js, but it's not complete yet. Here is a comparison of how long various functions take. <img width="629" alt="image" src="https://user-images.githubusercontent.com/709451/166697360-853eebcc-0342-4ddb-a607-40c93581a66c.png"> ## Replace & eliminate exports with `Bun.Transpiler` For code transpiled with `Bun.Transpiler`, you can now remove and/or replace exports with a different value. ```ts const transpiler = new Bun.Transpiler({ exports: { replace: { // Next.js does this getStaticProps: ["__N_SSG", true], }, eliminate: ["localVarToRemove"], }, treeShaking: true, trimUnusedImports: true, }); const code = ` import fs from "fs"; export var localVarToRemove = fs.readFileSync("/etc/passwd"); import * as CSV from "my-csv-parser"; export function getStaticProps() { return { props: { rows: CSV.parse(fs.readFileSync("./users-list.csv", "utf8")) }, }; } export function Page({ rows }) { return ( <div> <h1>My page</h1> <p> <a href="/about">About</a> </p> <p> <a href="/users">Users</a> </p> <div> {rows.map((columns, index) => ( <span key={index}>{columns.join(" | ")} </span> ))} </div> </div> ); } `; console.log(transpiler.transformSync(code)); ``` Which outputs (this is the automatic react transform) ```ts export var __N_SSG = true; export function Page({ rows }) { return jsxDEV("div", { children: [ jsxDEV("h1", { children: "My page" }, undefined, false, undefined, this), jsxDEV("p", { children: jsxDEV("a", { href: "/about", children: "About" }, undefined, false, undefined, this) }, undefined, false, undefined, this), jsxDEV("p", { children: jsxDEV("a", { href: "/users", children: "Users" }, undefined, false, undefined, this) }, undefined, false, undefined, this), jsxDEV("div", { children: rows.map((columns, index) => jsxDEV("span", { children: [ columns.join(" | "), " " ] }, index, true, undefined, this)) }, undefined, false, undefined, this) ] }, undefined, true, undefined, this); } ``` ## More new stuff - `server.stop()` lets you stop bun's HTTP server - [[bun.js] Add Bun.nanoseconds() to report time in nanos](https://github.com/Jarred-Sumner/bun/commit/69668d49e5ddb5169eae7966d8a30e9ae9e32cea) Hashing functions powered by BoringSSL: ```ts import { SHA1, MD5, MD4, SHA224, SHA512, SHA384, SHA256, SHA512_256, } from "bun"; // hash the string and return as a Uint8Array SHA1.hash("123456"); MD5.hash("123456"); MD4.hash("123456"); SHA224.hash("123456"); SHA512.hash("123456"); SHA384.hash("123456"); SHA256.hash("123456"); SHA512_256.hash("123456"); // output as a hex string SHA1.hash(new Uint8Array(42), "hex"); MD5.hash(new Uint8Array(42), "hex"); MD4.hash(new Uint8Array(42), "hex"); SHA224.hash(new Uint8Array(42), "hex"); SHA512.hash(new Uint8Array(42), "hex"); SHA384.hash(new Uint8Array(42), "hex"); SHA256.hash(new Uint8Array(42), "hex"); SHA512_256.hash(new Uint8Array(42), "hex"); // incrementally update the hashing function value and convert it at the end to a hex string // similar to node's API in require('crypto') // this is not wired up yet to bun's "crypto" polyfill, but it really should be new SHA1().update(new Uint8Array(42)).digest("hex"); new MD5().update(new Uint8Array(42)).digest("hex"); new MD4().update(new Uint8Array(42)).digest("hex"); new SHA224().update(new Uint8Array(42)).digest("hex"); new SHA512().update(new Uint8Array(42)).digest("hex"); new SHA384().update(new Uint8Array(42)).digest("hex"); new SHA256().update(new Uint8Array(42)).digest("hex"); new SHA512_256().update(new Uint8Array(42)).digest("hex"); ``` ## Reliability improvements - [[bun.js] Fix bug with readdirSync on folders with less than 32 files](https://github.com/Jarred-Sumner/bun/commit/f2c21b77336b9dcfa90676670877790ee48b31cc) - [[bun dev] Fix CSS HMR bug](https://github.com/Jarred-Sumner/bun/commit/1788503892d27027b584542c2966daac06308c93) - [[JS Parser] Fix overly-eager CJS -> ESM transform](https://github.com/Jarred-Sumner/bun/commit/ea241fcec7add6187ec915ed0b3983f3be0529f9) - [[css] Fix crash on empty files in some cases](https://github.com/Jarred-Sumner/bun/commit/e7251c0d55ed5a40b427c48a8736a8c3707f77ae) - [[TOML] Fix toml parsing with multiple keys in object literal](https://github.com/Jarred-Sumner/bun/commit/98592fb85d6960873a5ef0028f32075978739c5c)