bun v0.0.79 #157
Jarred-Sumner
announced in
Announcements
bun v0.0.79
#157
Replies: 1 comment
-
Impressive rate of updates. Do you have any plans to setup a milestone for future work? I saw you're working toward a production bundler, so that might be a handy way to group issues and PRs into a single place. The CloudFlare |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To upgrade:
If you run into any issues with upgrading
Try running this:
curl https://bun.sh/install | bash
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 API but fasterBuffer
(like in Node.js) is now a global, but the implementation is incomplete - see tracking issue. If you import"buffer"
, it continues to use the browser polyfill so this shouldn't be a breaking changeTextEncoder
&TextDecoder
thanks to some fixes to the vectorization (SIMD) codeTypedArray.from
. JavaScriptCore's implementation ofTypedArray.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 realistically I probably will do a more thorough fix for this in Bun and upstream that. For now, Bun reusesTypedArray.prototype.set
when possibleUint8Array.fill
Bun.Transpiler
gets an API for removing & replacing exportsSHA512
,SHA256
,SHA128
, and more are now exposed in the"bun"
module and theBun
global. They use BoringSSL's optimized hashing functions.new Response(Bun.file(path))
stop()
function. Before, there was no way to stop it without terminating the process 😆The next large project for bun is a production bundler Tracking issue
New Contributors
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:
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
.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 – there is no extra wrapper in the native code side of things.
Some
bun:ffi
usecases:"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:
Buffer
A lot of Node.js' Buffer module is now implemented natively in Bun.js, but it's not complete yet.
Here is a comparison of how long various functions take.
Replace & eliminate exports with
Bun.Transpiler
For code transpiled with
Bun.Transpiler
, you can now remove and/or replace exports with a different value.Which outputs (this is the automatic react transform)
More new stuff
server.stop()
lets you stop bun's HTTP serverHashing functions powered by BoringSSL:
Reliability improvements
This discussion was created from the release bun v0.0.79.
Beta Was this translation helpful? Give feedback.
All reactions