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
Uh oh!
There was an error while loading. Please reload this page.
-
To upgrade:
bun v0.0.68
This release is mostly focused on bun.js, bun's JavaScript runtime environment. Fixes to
bun installwill be part of the next release, but the infrastructure work from this release will help withbun installin the next release.TLDR:
Bun.Transpilerlets you run Bun's JS/TSX transpiler from bun.jsprocessobjectBun.Transpiler- API access to BunBun.Transpilerpart 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.Transpilerruns:See benchmark code
Bun.Transpilersupports JavaScript plugins with AST access via macros. Macros are not entirely done yet, but simple ones work. There will be docs on this.Bun.Transpileris 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
fsmodule implementationYou can now use most of the sync functions from Node.js'
fsmodule inside bun.js. These are implemented from scratch in Zig & exposed to JS.Buffer& streams are not implemented yet, but you can pass aUint8ArrayorArrayBufferwhere 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.realpathSyncis about 7x faster in bun.js (50,000 iterations)fs.existsSyncruns about 30% faster in bun.js (100,000 iterations)fs.readFileSyncruns about 3x faster in bun.js (100 iterations)The following functions are implemented:
fs.accessSyncfs.appendFileSyncfs.chmodSyncfs.chownSyncfs.closeSyncfs.copyFileSyncfs.existsSyncfs.fchmodSyncfs.fchownSyncfs.fstatSyncfs.fsyncSyncfs.ftruncateSyncfs.futimesSyncfs.lchmodSyncfs.lchownSyncfs.linkSyncfs.lstatSyncfs.lutimesSyncfs.mkdirSyncfs.openSyncfs.readdirSyncfs.readFileSyncfs.readlinkSyncfs.readSyncfs.realpathSyncfs.renameSyncfs.statSyncfs.symlinkSyncfs.truncateSyncfs.unlinkSyncfs.utimesSyncfs.writeFileSyncfs.writeSyncBun also includes an implementation of Node's
SystemErrorwith 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
processobjectbun.js has more support for the
processobject from Node.js.More stuff
import.metain bun.js returns an object withfileanddirqueueMicrotaskis implemented./to run a script with bun.js, e.g. instead ofbun ./foo.js,bun foo.jsworks now.mjsor.mtsfiles 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