Movatterモバイル変換


[0]ホーム

URL:


Bun logoBunBun
Bun v1.2.7
Bun.CookieMap is a Map-like API for getting & setting cookies. Bun's TypeScript type declarations have been rewritten to eliminate conflicts wit...
Bun v1.2.6
Faster, more compatible node:crypto. `timeout` option in Bun.spawn. Support for `module.children` in `node:module`. Connect to PostgreSQL via un...
Bun v1.2.5
Improvements to the frontend dev server, CSS modules support, a full rewrite of Node-API, faster `Sign`, `Verify`, `Hash`, `Hmac` from `node:cry...
Bun v1.2.4
Up to 60% faster Bun.build on macOS, codesigning support for single-file executables on macOS, dev server stability improvements, fixes a regres...
Bun v1.2.3
Bun gets a full-featured frontend development toolchain with incredibly fast hot reloading and bundling. Built-in routing for Bun.serve() makes ...
Bun v1.2.2
JavaScript idle memory usage drops by 10–30%. Fixes regression impacting vite build. Reliability improvements to Bun.SQL, Bun.S3Client, Bun's CS...

Bun v1.0.22


Ashcon Partovi ·January 9, 2024

Bun v1.0.22 fixes 29 bugs (addressing 118 👍 reactions), fixesbun install issues on Vercel, addsperformance.mark() APIs, addschild_process support for extra pipes, makesBuffer.concat faster, addstoBeEmptyObject andtoContainKeys matchers, fixesconsole.table width using emojis, and support forargv andexecArgv options inworker_threads, and supports Brotli infetch.

Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager — all in one. In case you missed it, here are some of the recent changes to Bun:

  • v1.0.21 - Fixes 33 bugs (addressing 80 👍 reactions).console.table() support.Bun.write, Bun.file, and bun:sqlite use less memory. Large file uploads with FormData use less memory. bun:sqlite error messages get more detailed. Memory leak in errors from node:fs fixed. Node.js compatibility improvements, and many crashes fixed.
  • v1.0.20 - Reduces memory usage infs.readlink,fs.readFile,fs.writeFile,fs.stat andHTMLRewriter. Fixes a regression where setTimeout caused high CPU usage on Linux.HTMLRewriter.transform now supports strings andArrayBuffer.fs.writeFile() andfs.readFile() now supporthex &base64 encodings.Bun.spawn shows how much CPU & memory the process used.
  • v1.0.19 - Fixes 26 bugs (addressing 92 👍 reactions). Use @types/bun instead of bun-types. Fixes --frozen-lockfile bug. bcrypt & argon2 packages now work. setTimeout & setInterval get 4x higher throughput. module mocks in bun:test resolve specifiers. Optimized spawnSync() for large stdio on Linux. Bun.peek() gets 90x faster, expect(map1).toEqual(map2) gets 100x faster. Bugfixes to NAPI, bun install, and Node.js compatibility improvements.

To install Bun:

curl
npm
brew
docker
curl
curl -fsSL https://bun.sh/install| bash
npm
npm install -g bun
brew
brew tap oven-sh/bun
brew install bun
docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun

To upgrade Bun:

bun upgrade

Fixed: Issues withbun install on Vercel

In a recent release of Bun, we introduced changes tobun install to make lifecycle scripts run faster by running them in parallel. When doing this, we also changed the how Bun sets the current working directory for lifecycle scripts, and started to use theposix_spawn_file_actions_addchdir_np C-standard library function.

Bun was not properly checking if that function failed. The function was introduced in glibc 2.29, but Vercel uses glibc 2.26. Therefore, when runningbun install on Vercel, the function would fail, andbun install would not handle that failure.

The fix was to implement aposix_spawn-like polyfill for Linux.

New:performance.mark() APIs

You can now useuser-timings APIs, which includeperformance.mark() andperformance.measure(). This is useful for measuring the performance of your code.

performance.mark("start");while (true) {// ...}performance.mark("end");performance.measure("task","start","end");

You can also use thePerformanceObserver API to listen for performance events.

const observer=newPerformanceObserver((list)=> {for (const entryof list.getEntries()) {if (entry.entryType==="mark") {      console.log(entry);// { name: "start", startTime: 0 }    }elseif (entry.entryType==="measure") {      console.log(entry);// { name: "task", startTime: 0, duration: 1000 }    }  }});observer.observe({ entryTypes: ["mark","measure"] });

Thanks to@gvilums for submitting a PR to add this to Bun, and thanks to theWebKit team for their implementation of these APIs.

New:child_process support for extra pipes

You can now pass extra pipes tochild_process functions. This is useful for passing data between processes. For example, you can pass a pipe to a child process, and then write to that pipe from the parent process.

parent.js
child.js
parent.js
import { spawn }from"node:child_process";const child=spawn(process.argv0, ["child.js"], {  stdio: ["inherit","inherit","inherit","pipe"],});const pipe= child.stdio[3];pipe.on("data", (data)=> {  console.log(data.toString());// "hello!"});
child.js
import { createWriteStream }from"node:fs";const stream=createWriteStream(null, { fd:3 });stream.on("ready", ()=> {  stream.write("hello!");});

Coming soon: Playwright support

These changes were necessary to supportPlaywright, which uses extra pipes to communicate with the browser process. However, there is still oneoutstanding PR that needs to be merged to get Playwright working with Bun.

Thanks to@nektro for implementing this missing API.

New: Brotli support forfetch

You can now usefetch to make requests with thebr encoding. This is useful for making requests to servers that support Brotli compression.

const response=awaitfetch("https://example.com", {  headers: {"Accept-Encoding":"br",  },});

We also changed brotli support to be statically-linked in Bun, instead of dynamically-linked. This fixed issues with certain Linux distros and older macOS releases that did not have the nessary libraries.

New:toBeEmptyObject andtoContainKeys matchers

You can now useexpect().toBeEmptyObject() to check if an object is empty.

expect({}).toBeEmptyObject();expect({ a:1 }).not.toBeEmptyObject();

You can also useexpect().toContainKeys() orexpect().toContainAnyKeys() to check if an object contains certain keys.

expect({ a:1, b:2 }).toContainKeys(["a","b"]);expect({ a:1, b:2 }).not.toContainKeys(["c"]);
expect({ foo:"bar" }).toContainAnyKeys(["foo","baz"]);expect({ foo:"bar" }).not.toContainAnyKeys(["baz"]);

Thanks to@coratgerl for implementing this feature.

New: 15% to 400% fasterBuffer.concat

UsingBuffer.concat is now 15% to 400% faster, depending on the size of the buffers being concatenated.

In the next version of Bun

Buffer.concat gets 15% - 400% faster, depending on the input size.pic.twitter.com/hdC1mqhF51

— Jarred Sumner (@jarredsumner)January 8, 2024

We also fixed a bug whereBuffer.concat would crash when concatenating a large number of buffers. This was caused by an out-of-memory error not being handled correctly.

New: 10% to 15% fasternew Headers(object)

Usingnew Headers(object) andnew URLSearchParams(object) with an object is now 10% to 15% faster.

In the next version of Bun

new Headers(myObject) gets 10% fasterpic.twitter.com/JLSeFDvq8A

— Jarred Sumner (@jarredsumner)January 7, 2024

Fixed:console.table width using emojis

In Bun v1.0.21, we added support forconsole.table. However, we did not properly handle emojis, and the table would be misaligned if there were emojis or unicode characters in the table. This has been fixed by using the official Unicodedataset to determine the width of each character.

Before (Bun v1.0.21)After (Bun v1.0.22)

Thanks to@otgerrogla for implementingconsole.table, and following up to fix this bug.

New:argv andexecArgv options forworker_threads

Bun did not support theargv andexecArgv options forworker_threads. This has been fixed.

index.js
worker.js
index.js
import { Worker }from"node:worker_threads";const worker=newWorker("./worker.js", {  argv: ["--foo","bar"],  execArgv: ["--inspect"],});worker.on("message", (data)=> {  console.log(data);// { argv: [ "--foo", "bar" ], execArgv: [ "--inspect" ] }});
worker.js
postMessage({  argv: process.argv,  execArgv: process.execArgv,});

Thanks to@otgerrogla for fixing this missing functionality.

Fixed: Binding to0.0.0.0 would bind to IPv6 as well

There was a bug wherecreateServer would bind to both IPv4 and IPv6 when binding to0.0.0.0. This has been fixed thanks to@Hanaasagi.

Fixed: HTTP method casing innode:http

In Bun v1.0.10, we introduced a bug where thePURGE andOPTIONS headers were not being properly transformed to uppercase. This caused problems with Fastify and CORS pre-flight requests. This has been fixed thanks to@asomethings.

Fixed: Partial consume onBufferList

There was a bug where multiple, partial consumes onBufferList would not increment theoffset properly. This causedcbor to not work properly, and has been fixed thanks to@hborchardt.

Fixed:bun build --compile withcompiled:// URL

We fixed a bug wherebun build --compile would not work withcompiled:// URLs. This has been fixed by changingcompiled:// URLs to use a special prefix that Bun recognizes.

New:assert.doesNotMatch

You can now useassert.doesNotMatch to check if a string does not match a regular expression.

assert.doesNotMatch("I will not match",/match/);

Thanks to@markusn for implementing this missing API.

Thanks to 22 contributors!

Thank you to all the contributors to this release of Bun, including the new 13 contributors who submitted their first pull request!

You can also read thefull changelog.


Bun v1.0.21

Bun v1.0.23


[8]ページ先頭

©2009-2025 Movatter.jp