You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This release adds source maps for JS output, several web APIs to bun.js (and HTMLRewriter), parser support for ES2022 syntax, improves parsing speed for long strings, makes bun dev 10% faster on macOS and fixes a lot of crashes.
Note: the WASM build is not quite ready yet, but I'm working on it! The main thing I'm uncertain of is whether to release it with Bun.Transpiler as the API, or with a partially-implemented esbuild-compatible API. So if you would like to use it and have opinions there, do say
bun.js
Thanks to source maps, errors in bun.js show the source code instead of the transpiled code now:
Previously, it looked like this
Note the incorrect line numbers and the missing if (true) branch – bun's transpiler removed the dead code, but that can make it harder to read the code
New APIs:
HTMLRewriter – fast jQuery-like streaming HTML parser API in Cloudflare Workers, powered by LOLHTML (the same parser in cloudflare workers)
Bun.inspect lets you format like console.log but get back a string
Bun.unsafe.arrayBufferToString(buffer) lets you quickly & unsafely cast an ArrayBuffer-like object to a string. Useful when you've already encoded the string.
Misc:
ResolveError.prototype.toString() and BuildError.prototype.toString() work as expected
console.log support for Request, Response, Headers
async node fs functions now have a compatibility wrapper that runs the sync version in the next tick. non-blocking support will come eventually
[microbenchmark] 10% faster at parsing HTML entity codes in JSX
Support for static initialization blocks (ES2022)
Support for private static class fields and methods (ES2022)
Support for private static class brand checks (ES2022)
Support for private identifiers (ES2019)
Fix printing bug in strings that have certain escape sequences and non-ascii characters
Always print escaped Unicode codepoints instead of the original. This more closely matches what Babel & esbuild do
For TypeScript classes, match the semantics of useDefineForClassFields for fields and constructor arguments
Bun.Transpiler:
autoImportJSX flag lets you enable or disable importing auto-importing the jsxImportSource.
allowBunRuntime flag lets you disable importing bun's runtime code. This is useful if you want to use bun as just a transpiler. It is disabled by default, as I would expect people to use Bun.Transpiler mostly for other environments than bun itself
Infrastructural changes
I started using the debug build of mimalloc, bun's memory allocator for the debug builds of bun and that uncovered a few otherwise difficult-to-reproduce crashes
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
To upgrade:
What's new
This release adds source maps for JS output, several web APIs to bun.js (and
HTMLRewriter
), parser support for ES2022 syntax, improves parsing speed for long strings, makesbun dev
10% faster on macOS and fixes a lot of crashes.Note: the WASM build is not quite ready yet, but I'm working on it! The main thing I'm uncertain of is whether to release it with
Bun.Transpiler
as the API, or with a partially-implementedesbuild
-compatible API. So if you would like to use it and have opinions there, do saybun.js
Thanks to source maps, errors in bun.js show the source code instead of the transpiled code now:
Previously, it looked like this
Note the incorrect line numbers and the missing
if (true)
branch – bun's transpiler removed the dead code, but that can make it harder to read the codeNew APIs:
HTMLRewriter
– fast jQuery-like streaming HTML parser API in Cloudflare Workers, powered by LOLHTML (the same parser in cloudflare workers)setTimeout
,setInterval
,clearTimeout
, andclearInterval
Response.clone
,Request.clone
,Request.bodyUsed
,Response.bodyUsed
,Response.headers
atob
,btoa
Blob
, includingBlob.text()
,Blob.slice()
,Blob.arrayBuffer()
andRequest.blob()
,Response.blob()
console.trace()
is now implementedBun.inspect
lets you format likeconsole.log
but get back a stringBun.unsafe.arrayBufferToString(buffer)
lets you quickly & unsafely cast an ArrayBuffer-like object to a string. Useful when you've already encoded the string.Misc:
ResolveError.prototype.toString()
andBuildError.prototype.toString()
work as expectedconsole.log
support forRequest
,Response
,Headers
FetchEvent.respondWith
will automatically await any promises now{time, count, timeEnd, profile, profileEnd, count, countReset}
bun dev
bun install
bun pm cache
prints the cache dir pathbun run
bun create
JavaScript Transpiler
Bun.Transpiler
:autoImportJSX
flag lets you enable or disable importing auto-importing thejsxImportSource
.allowBunRuntime
flag lets you disable importing bun's runtime code. This is useful if you want to use bun as just a transpiler. It is disabled by default, as I would expect people to useBun.Transpiler
mostly for other environments than bun itselfInfrastructural changes
I started using the debug build of mimalloc, bun's memory allocator for the debug builds of bun and that uncovered a few otherwise difficult-to-reproduce crashes
This discussion was created from the release bun v0.0.72.
Beta Was this translation helpful? Give feedback.
All reactions