bun v0.0.68 #109
Jarred-Sumner
announced in
Announcements
bun v0.0.68
#109
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To upgrade:
bun v0.0.68
This release is mostly focused on bun.js, bun's JavaScript runtime environment. Fixes to
bun install
will be part of the next release, but the infrastructure work from this release will help withbun install
in the next release.TLDR:
Bun.Transpiler
lets you run Bun's JS/TSX transpiler from bun.jsprocess
objectBun.Transpiler
- API access to BunBun.Transpiler
part of Bun's JavaScript & TypeScript transpiler from native code to JavaScript, and it's fast.End-to-end, transpiling this JSX file inside JavaScript via
Bun.Transpiler
runs:See benchmark code
Bun.Transpiler
supports JavaScript plugins with AST access via macros. Macros are not entirely done yet, but simple ones work. There will be docs on this.Bun.Transpiler
is builtin to bun.js, there's nothing extra to import or install. Eventually there will be a WASM build for some of this, but not sure whenHowever, how can a transpiler API be useful if you can't read or write files? Designing a new filesystem API sounds like fun (for me), but I think JS developers already spend too much time on incompatibility issues
Node.js
fs
module implementationYou can now use most of the sync functions from Node.js'
fs
module inside bun.js. These are implemented from scratch in Zig & exposed to JS.Buffer
& streams are not implemented yet, but you can pass aUint8Array
orArrayBuffer
where Node accepts aBuffer
. The async versions of the functions will come in a future release (this already was a lot of stuff for one release), but generally sync outperforms async for local file access.fs.realpathSync
is about 7x faster in bun.js (50,000 iterations)fs.existsSync
runs about 30% faster in bun.js (100,000 iterations)fs.readFileSync
runs about 3x faster in bun.js (100 iterations)The following functions are implemented:
fs.accessSync
fs.appendFileSync
fs.chmodSync
fs.chownSync
fs.closeSync
fs.copyFileSync
fs.existsSync
fs.fchmodSync
fs.fchownSync
fs.fstatSync
fs.fsyncSync
fs.ftruncateSync
fs.futimesSync
fs.lchmodSync
fs.lchownSync
fs.linkSync
fs.lstatSync
fs.lutimesSync
fs.mkdirSync
fs.openSync
fs.readdirSync
fs.readFileSync
fs.readlinkSync
fs.readSync
fs.realpathSync
fs.renameSync
fs.statSync
fs.symlinkSync
fs.truncateSync
fs.unlinkSync
fs.utimesSync
fs.writeFileSync
fs.writeSync
Bun also includes an implementation of Node's
SystemError
with pretty printing. Note that since source maps are not implemented yet, sometimes the line:column will be off by a little.This is what the same error looks like in Node
Node.js
process
objectbun.js has more support for the
process
object from Node.js.More stuff
import.meta
in bun.js returns an object withfile
anddir
queueMicrotask
is implemented./
to run a script with bun.js, e.g. instead ofbun ./foo.js
,bun foo.js
works now.mjs
or.mts
files now and treats them as ESM. Before it was reading them but ignoring the extensionBun.gc(force)
lets you manually run the garbage collectorBun.shrink()
runs a JavaScriptCore VM function that attempts to shrink the amount of memory used by JavaScriptCoreBun.generateHeapSnapshot()
returns a heap snapshot in a format I'm not entirely sure how to visualize yetIf you look hard enough, you'll also find a new subcommand for a very incomplete but fast Jest-like test runner. Hopefully will talk more about that next release or the one after.
Thanks
This discussion was created from the release bun v0.0.68.
Beta Was this translation helpful? Give feedback.
All reactions