github oven-sh/bun bun-v0.0.81
bun v0.0.81

latest releases: bun-v1.1.17, bun-v1.1.16, bun-v1.1.15...
2 years ago

To upgrade:

bun upgrade

Bun.js gets Node-API support

Node-API is 1.75x - 3x faster in Bun compared to Node.js 18 (in call overhead)

Getters & setters:
image

Simple function calls:
image

Just like in Node.js, to load a Node-API module, use require('my-npm-package') or use process.dlopen.

90% of the API is implemented, though it is certainly buggy right now.

Polyfills & new APIs in Bun.js v0.0.81

The following functions have been added:

  • import.meta.resolveSync synchronously run the module resolver for the currently-referenced file
  • import.meta.require synchronously loads .node or .json modules and works with dynamic paths. This doesn't use ESM and doesn't run the transpiler, which is why regular js files are not supported. This is mostly an implementation detail for how require works for Node-API modules, but it could also be used outside of that if you want
  • Bun.gzipSync, Bun.gunzipSync, Bun.inflateSync, and Bun.deflateSync which expose native bindings to zlib-cloudflare. On macOS aarch64, gzipSync is ~3x faster than in Node. This isn't wired up to the "zlib" polyfill in bun yet

Additionally:

  • __dirname is now supported for all targets (including browsers)
  • __filename is now supported for all targets (including browsers)
  • Buffer.byteLength is now implemented

Several packages using Node-API also use detect-libc. Bun polyfills detect-libc because bun doesn't support child_process yet and this improves performance a little.

Bug fixes

  • Fix incorrect error when new.target is referenced outside of a constructor d1ea51e
  • Fix incorrect error with negative numbers in the JSON parser 1232676

Don't miss a new bun release

NewReleases is sending notifications on new releases.