Bun v0.2.0 #1318
Jarred-Sumner
announced in
Announcements
Bun v0.2.0
#1318
Replies: 1 comment
-
Damn aarch64 version being less than 15mb, that's pure epik work right there! You can just bundle bun with your app and nobody really would notice anything! |
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:
To install:
curl https://bun.sh/install | bash
If you have any problems upgrading
Run the install script (you can run it multiple times):
curl https://bun.sh/install | bash
Introducing Bun v0.2.0
New:
bun --hot
brings hot reloading & zero-downtime restarts to Bun's JavaScript runtimeBun.spawn
andBun.spawnSync
(process spawning API)Request.body
- incoming HTTP request body streaming withReadableStream
Bun.serve
(HTTP server) andfetch()
(HTTP client)setTimeout
andsetInterval
for better performance and reliabilityBun.serve
and anything usingResponse
objects"imports"
in package.json ("#foo"
imports) works now 21770eb"bun:test"
gets ~300x faster when using http server, websockets, etc 524e48aBun.file(path).writer()
new Blob(["hello world"])
is now 75x faster in Bun than Node - 2c19269Breaking:
bun run
andbun
CLI arguments parsing has been changed so that anything afterbun run <file-or-script>
orbun <file>
is passed through verbatim. This fixes a number of bugs with CLI argument parsing in both bun as a runtime and when used as a package.json"scripts"
runner.# before, server.js wouldn't see the --port argument bun run server.js --port 3000
process.version
now reports a fake Node.js version instead of Bun's version. This is for compatibility with many npm packages that check for Node.js version to enable/disable features. To get Bun's version, useBun.version
orprocess.versions.bun
.Bun.serve().hostname
should return the hostname instead of the origin. This is a breaking change because it affects how URLs may be printed if you were using this getter before. e15fb6bbun --hot
: hot reloads on the serverbun --hot
lets you see code changes immediately, without restarting your server. Unlike popular file watchers like nodemon,bun --hot
preserves some of the state of your app, meaning in-flight HTTP requests don't get interrupted.To use it with Bun's HTTP server (automatic):
server.ts
(vanilla JavaScript works too)Then, run:
You can also use
bun run
:For more information, see
bun --hot
section in Bun's readme.Bun.spawn
spawn processes in BunBun.spawn
efficiently spawns a new process in Bun.Bun.spawn
is flexible.stdin
can be aResponse
,Blob
,Request
,ArrayBuffer
,ArrayBufferView
,Bun.file
,"pipe"
ornumber
.stdout
andstderr
returnReadableStream
s when"pipe"
is used.Request.body & Response.body return a
ReadableStream
This fixes #530
You can read
Request
&Response
objects bodies as a ReadableStream nowReadableStream
now supports async iteratorsThis works now:
Previously, you had to call
getReader()
like this:HTTP request body streaming
Bun.serve
now supports streaming request bodies. This is useful for large file uploads."imports"
support inpackage.json
This release adds support for the
imports
field in package.jsonReduced memory usage for Bun.serve()
Bun wasn't correctly reporting memory usage for
Request
,Response
, andBlob
objects to JavaScriptCore, causing the garbage collector to be unaware of how much memory was really in use for http responses/requests.bun:test performance improvements
An event loop bug in
bun:test
caused the process the idle for awhile. Now bun's own http server tests run > 10x faster.Bug fixes:
ReadableStream
bun:sqlite
Fix crash in Database.deserialize9fd0072
jsxFactory
#1269assert
module as a function #941More changes:
Bun.which(bin)
: find the path to a commandprocess
now extendsEventEmitter
bun:test
output. now it includes "expect calls"bun:test
print test failures at the bottom - c57b32fnavigator.userAgent
andnavigator.hardwareConcurrency
are now globalsrequire("tty").isatty
works nowrequire("fs").rm
works nowconsole.count
andconsole.countReset
- 4060afbfetch()
use 82% less memory (9.8 KB -> 1.8 KB)Bun.version
reports Bun's version numberBun.revision
reports the git commit SHA used at the time Bun was compiledAll the PRs
body
toResponse
andRequest
by @Jarred-Sumner in Addbody
toResponse
andRequest
#1255New Contributors
Full Changelog: bun-v0.1.13...bun-v0.2.0
This discussion was created from the release Bun v0.2.0.
Beta Was this translation helpful? Give feedback.
All reactions