bun v0.0.83 #171
Jarred-Sumner
announced in
Announcements
bun v0.0.83
#171
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
To upgrade:
Having trouble upgrading?
You can also try the install script.
curl https://bun.sh/install | bash
Thanks to:
"wrangler@beta"
with"wrangler"
in the examples forbun add
bun:sqlite
bun:sqlite
is a high-performance builtin SQLite module for bun.js.It tends to be around 3x faster than the popular
better-sqlite3
npm packageNote: in the benchmark I tweeted earlier,
better-sqlite3
was returning arrays of values rather than arrays of objects, which was inconsistent with whatbun:sqlite
& deno's x/sqlite were doingUsage
There are more detailed docs in Bun's README
bun:sqlite
's API is loosely based on @joshuawise's better-sqlite3New in
bun:ffi
CFunction
lets you call native library functions from a function pointer.It works like
dlopen
but its for cases where you already have the function pointer so you don't need to open a library. This is useful for:linkSymbols
is likeCFunction
except for when there are multiple functions. It returns the same object asdlopen
exceptptr
is required and there is no pathnew CString(ptr)
should be a little faster due to using a more optimized function for getting the length of a string.require.resolve()
Running
require.resolve("my-module")
in Bun.js will now resolve the path to the module. Previously, this was not supported.In browsers, it becomes the absolute filepath at build-time. In node, it's left in without any changes.
Internally, Bun's JavaScript transpiler transforms it to:
You can see this for yourself by running
bun build ./file.js --platform=bun
"node:module"
module polyfillNode's
"module"
module lets you create require functions from ESM modules.Bun now has a polyfill that implements a subset of the
"module"
module.Normally
require()
in bun transforms statically at build-time to an ESMimport
statement. That doesn't work as well for Node-API (napi) modules because they cannot be statically analyzed by a JavaScript parser (since they're not JavaScript).For napi modules, bun uses a dynamic require function and the
"module"
module exports a way to create those using the same interface as in Node.jsThis is mostly intended for improving Node-API compatibility with modules loaded from ESM.
As an extra thing, you can also use
require()
this way for .json files.Bun.Transpiler – pass objects to macros
Bun.Transpiler
now supports passing objects to macros.Then, in
get-user.js
:That inlines the returned current user into the JavaScript source code, producing output equivalent to this:
Bug fixes
Buffer.from(arrayBuffer, byteOffset, length)
now works as expected (thanks to @kriszyp for reporting)Misc
This discussion was created from the release bun v0.0.83.
Beta Was this translation helpful? Give feedback.
All reactions