Bun v1.1.16 is here! This release fixes 41 bugs (addressing 221 ๐). lcov code coverage reports in bun test, Install dependencies from private git repositories including Gitlab and Bitbucket. Buffer.from(string, "base64")
gets 6x - 30x faster on large input. Bug fixes to bun patch
, bun install
, N-APi addons, transpiler bugfixes and Node.js compatibility improvements.
We're hiring systems engineers in San Francisco to build the future of JavaScript!
Previous releases
v1.1.14
fixes 63 bugs (addressing 519 ๐). Patch node_modules withbun patch
. ORM-less object mapping inbun:sqlite
. Log allfetch()
calls as acurl
command. Node.js compatibility improvements. bun install bugfixes,bun:sqlite
bugfixes, Windows bugfixes. And more.v1.1.10
fixes 20 bugs. 2x faster uncached bun install on Windows.fetch()
uses up to 2.8x less memory. Several bugfixes to bun install, sourcemaps, Windows reliability improvements and Node.js compatibility improvementsv1.1.0
Bundows. Windows support is here!
To install Bun
curl -fsSL https://bun.sh/install | bash
npm install -g bun
powershell -c "irm bun.sh/install.ps1|iex"
scoop install bun
brew tap oven-sh/bun
brew install bun
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
To upgrade Bun
bun upgrade
LCOV code coverage reporter
When using bun test --coverage
, coverage reports can be exported to the standard lcov format using --coverage-reporter lcov
bun test --coverage --coverage-reporter lcov
By default this outputs a coverage/lcov.info
file. The coverage directory can be changed with --coverage-dir
To always enable coverage reporting, two new options have been added to bunfig.toml
:
[test]
# always enable coverage
coverage = true
# new
coverageReporter = ["text", "lcov"] # default ["text"]
coverageDir = "./path-to-folder" # default "coverage"
Thanks to @exoego for implementing this.
bun install git ssh repositories
bun install now supports authenticating via ssh to install dependencies from private git repositories. These are cloned using your git SSH key via git clone
.
bun i git@github.com:paperclover/secret-utilities.git
installed secret-utilities@git+ssh://git@github.com:paperclover/secret-utilities.git#5a7279074f22e98d64507cb5149633c73897395f
1 package installed [904.00ms]
This makes bun install
easier to use when working with private repositories from Gitlab, Bitbucket, or other git hosting services. GitHub repositories were sometimes impacted by this issue, but less frequently.
Thanks to @Eckhardt-D for implementing this!
Buffer.from(string, "base64")
gets 6x-30x faster on large input
By changing our base64 decoding implementation to using simdutf, using Buffer.from(string, "base64")
is much faster, especially on large input:
In the next version of Bun
โ Jarred Sumner (@jarredsumner) June 19, 2024
Buffer.from(str, "base64") gets 6x - 30x faster on large input, thanks to @lemire's simdutf pic.twitter.com/iFgI0Vv3sQ
Output Source Map URLs in bun build
To tell browser devtools where to find sourcemaps, tooling inserts a //# sourceMappingURL=
comment at the end of files.
Previously, Bun didn't expose a way to link to external, non-inline sourcemaps via this comment.
You can now use --sourcemap=linked
to tell Bun to insert a //# sourceMappingURL=
comment at the end of the bundled file, linking to the external sourcemap.
bun build src/app.tsx --outdir ./dist --sourcemap=linked --minify
This will produce the directory dist
with app.js
and app.js.map
, and the comment //# sourceMappingURL=app.js.map
to load the sourcemap for debugging.
Thanks to @paperclover for implementing this.
console.log
now prints non-indexed properties on arrays
Bun now shows prints non-indexed properties on arrays, for example:
const arr = ['a', 'b', 'c'];
arr['five'] = 5;
console.log(arr);
bun non-indexed-properties.ts
[ "a", "b", "c", five: 5 ]
Fixed: WebSocket connection error
event now includes a message
When a WebSocket connection fails, the error event now includes a message
property with a more detailed error message.
const ws = new WebSocket("ws://localhost:8080");
ws.addEventListener("error", (error) => {
console.log(error.message);
});
// The message previously only was in the "close" event:
ws.addEventListener("close", (close) => {
console.log(close);
});
This prints the following error message:
WebSocket connection to 'ws://localhost:8080/' failed: Failed to connect
Instead of only including relevant information in the close
event, the error
event on connection failure now includes a message
property with an error message.
Fixed: Crash in console.log with WebSocket connection errors
When a WebSocket fails to connect, it emits both the error
and close
events.
const ws = new WebSocket("ws://localhost:8080");
ws.addEventListener("error", (error) => {
// Connection error emitted
});
ws.addEventListener("close", () => {
// Connection did not fully open, but it is still closed
});
Previously, printing console.log(error)
from a WebSocket connection error would sometimes cause a crash. The code incorrectly assumed that an ErrorEvent
always contained a non-null error
. This has been fixed, and our test coverage has been improved to cover this edge case.
Fixed: Bun Shell & bun run with non-ascii cwd on Windows
A bug affecting Bun Shell and bun run
when run in a directory with non-ascii characters has been fixed thanks to @dylan-conway.
Fixed: non-ascii characters in TypeScript enums
An enum with non-ascii keys would get mangled. This has been fixed.
enum X {
a,
b,
รง,
}
console.log(X);
Fixed: Assertion failure with experimental decorator on abstract property
An assertion failure would occur when using an experimental TypeScript decorator on an abstract property. This has been fixed, thanks to @forcefieldsovereign.
Fixed: ZWJ and ZWNJ characters in transpiler
A crash that would occur when a file contained a Zero Width Joiner (ZWJ) or Zero Width Non-Joiner (ZWNJ) character inside of a property name has been fixed.
Fixed: Crash in module.mock
An edge case with using module.mock
on modules that previously failed to load causing a crash has been fixed thanks to @paperclover.
Fixed: process.execArgv
process.execArgv
lets you return arguments passed to the Bun runtime, in comparison to the program arguments in process.argv
. In certain cases, non-runtime parameters were mistakenly included. Thanks to @paperclover for fixing this.
Fixed: Ignore optional dependencies that do not exist
Before, installing the package @laihoe/demoparser2
would fail due to an optional dependency on a package that was never published to NPM. Bun now matches npm
's behavior by simply ignoring these missing packages, since they are declared as optional dependencies.
Thanks to @dylan-conway
Fixed: N-API modules re-assigning module.exports
A bug where Bun incorrectly handled N-API modules that re-assigned module.exports
has been fixed.
Previously, Bun would ignore the return value of the module, causing the module to not be loaded correctly. This has been fixed, and Bun now correctly loads N-API modules that re-assign module.exports
. This waas most noticable when module.exports
was assigned to a function.
Along the way, we've also fixed a potential crash when loading N-API modules that take a long time to initialize.
Fixed: bun:sqlite
's changes
field always 0 in statement.run()
A bug in prepared statements caused db.prepare(...).run(...)
to return 0 in certain cases instead of the number of changes from the statement. db.run(...)
was not affected.
Fixed: bun patch
in workspace packages
Bugs related to bun patch --commit
diffing files in nested node_modules
directories causing patch failures have been fixed.
Thanks to @zackradisic
Internal: Bun updated Zig to version 0.13
In #9965, Bun was upgraded to use the latest release of the Zig compiler. This makes Bun easier to contribute to, as there are a handful of language server, build system, and overall code quality improvements.
Bug fixes within the Zig standard library have fixed some bugs in Bun; most notably the Windows fix for handling WTF-16 (a looser version of UTF-16) within paths and environment. This fixes some rare edge cases where the error InvalidUTF8
was reported with very little context. Thanks to @squeek502.
One important build system improvement for the team and contributors is the ability to ensure that all platforms (Linux, Mac, and Windows) compile successfully without having to wait for CI to finish running. Contributors can now test-compile the code for all targets with bun run zig-check
in the Bun repository.