Bun v1.0.3 fixes numerous bugs, adds support for metadata reflection via TypeScript's emitDecoratorMetadata
, improves fetch
compatibility, unblocks private registries like Azure Artifacts and Artifactory, bunx bugfix, console.log() depth 8 -> 2, Node.js compatibility improvements, and more.
Thank you for reporting issues. We are working hard to fix them as quickly as possible.
Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager — all in one. We've been releasing a lot of changes to Bun recently. Here's a recap of the last few releases. In case you missed it:
v1.0.0
- Bun's first stable release!v1.0.1
- Named imports for .json & .toml files, bugfixes to bun install, node:path, Bufferv1.0.2
- Make--watch
faster, plus bug fixes
To install Bun:
curl -fsSL https://bun.sh/install | bash
npm install -g 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
emitDecoratorMetadata
(used by Nest.js, TypeORM, and more)
Bun now supports metadata reflection via TypeScript's emitDecoratorMetadata
. This means that you can use Nest.js with Bun, and it will work out of the box.
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}
The emitDecoratorMetadata
is a TypeScript compiler option that enables the generation of metadata for decorators via reflect-metadata.
Improved Nest.js support
The addition of emitDecoratorMetadata
dramatically improves Nest.js support, as it relies on custom "Reflectors" to attach metadata and middleware to route handlers.
@Post()
@Roles(['admin']) // custom authentication decorator
async create(@Body() createCatDto: CreateCatDto) {
this.catsService.create(createCatDto);
}
module.parent
support
In Node, the CommonJS module.parent
getter is a reference to the parent module that required the current module. This is useful for determining whether a module was run directly or required by another module.
if (module.parent) {
// this module was required by another module
} else {
// this module was run directly
}
Bun now supports module.parent
in the same way that Node does.
For ES modules, you can use import.meta.main
to find out if the current module started the Bun process.
Bugfixes for private npm registries
Improvements to fetch
unblock the usage of bun install
with popular private package registries like Azure Artifacts and JFrog Artifactory.
You can configure a private registry using bunfig.toml
instead of .npmrc
. Provide values for url
, username
, and password
under the [install.registry]
section of your bunfig.toml
file.
[install.registry]
url = "https://pkgs.dev.azure.com/my-azure-artifacts-user/_packaging/my-azure-artifacts-user/npm/registry"
username = "my-azure-artifacts-user"
# Bun v1.0.3+ supports using an environment variable here
password = "$NPM_PASSWORD"
Alternatively, specify a token instead of a username and password. This is useful for Artifactory.
[install.registry]
url = "https://my-artifactory-server.com/artifactory/api/npm/npm-virtual"
token = "$NPM_TOKEN"
For more complete information, refer to our new guides:
[0.5ms] env
message is now silent by default
Many people asked for this, so @colinhacks made it happen. The [0.5ms] env loaded
message is now silent by default. You can still see it by setting logLevel
to "debug"
in bunfig.toml
in the next version of bun
— Jarred Sumner (@jarredsumner) September 22, 2023
[0.1ms] ".env" is silenced by default pic.twitter.com/F7V6hGZvrV
Node.js compatiblity improvements
The work on Node.js compatibility continues. Here are some of the improvements in this release:
Implement console.Console
constructor
The Node.js console.Console
constructor has been implemented.
import { Console } from "console";
import { createWriteStream } from "fs";
const writer = new Console({ stdout: createWriteStream("log.txt") });
writer.log("hello");
writer.log("world", { x: 2 });
This fixes vitest
and webpack's ts-loader
when executed with the Bun runtime—though consider using bun test
and bun build
instead! Of course, there are a lot of tools and codebases that rely on these technologies which will now work with Bun.
Empty environment variables now appear as an empty string (""
)
In process.env
and Bun.env
, empty environment variables appeared as undefined
instead of an empty string. This is fixed, thanks to @liz3.
dns.lookupService
is now implemented
The node:dns
function dns.lookupService
is now implemented. Thanks to @Hanaasagi.
console.log() depth is now 2 instead of 8
8 was nice, but caused issues with large objects filling up your terminal screen. Thanks to @JibranKalia. This aligns the behavior with Node.js.
node_api_create_external_string_latin1 and node_api_create_external_string_utf16
The node_api functions node_api_create_external_string_latin1
and node_api_create_external_string_utf16
are now implemented
listen() in node:http
callback bugfix
The error event was not emitting to the event listener correctly. Thanks to @SuperAuguste for fixing this.
Bugfixes
Crash in request.json()
fixed
A crash that could occur when calling request.json()
was fixed. It was caused by incorrect exception handling in native code.
bun pm rm cache
now works
The bun pm rm cache
command now deletes the cache directory. Thanks to @WingLim.
Max redirect URL length is now 8192 instead of 4096
This fixes an issue with certain private npm registries.
bunx choosing version from $PATH instead of @version tag bugfix
A bug causing bunx
to choose the version of the executable from $PATH
instead of the @version
tag was fixed
in the next version of bun
— Jarred Sumner (@jarredsumner) September 20, 2023
bunx foo@tag will always load the @tag version when a @tag is present, instead of choosing the version in $PATH pic.twitter.com/eCMVa0gSxF
Full changelog
#4652 | VSCode Extension Bunlock Syntax-Highlighting and Docs Improvements by @JeremyFunk |
#5451 | docs(runtime): fix some typo. by @zongzi531 |
#5531 | Update development.md by @sonyarianto |
#5525 | fix(corking) uncork if needed by @cirospaciari |
#5503 | fix(request) handle undefined/null/empty signal on request by @cirospaciari |
#5521 | fix(bundler): Add a space before minified require by @davidmhewitt |
#5505 | fix(node/fs.watch): Check first char before trimming event filenames by @davidmhewitt |
#5535 | webkit upgrade by @dylan-conway |
#5555 | Follow-up for workspace docs #5379 and #5229 by @bdenham |
#5579 | fix: ArrayBufferConstructor type signature by @52 |
#5580 | fix: array-buffer.test-d.ts test by @52 |
#4693 | fix: node compatibility with empty path string (stat, exist, ...) by @coratgerl |
#5603 | Make error message when importing a node: module in a browser bundle clearer by @Jarred-Sumner |
#5576 | docs: fix typo in lockflie nav by @Vilsol |
#5593 | Docs: path aliases fix by @e253 |
#5496 | fix(fetch) handle 100 continue by @cirospaciari |
#5387 | feat(encoding): TextDecoder support undefined by @WingLim |
#5481 | fix(child_process) unref next tick so exit/close event can be fired before application exits by @cirospaciari |
#5529 | Implement VSCode tasks for bun by @JeremyFunk |
#5610 | fix(install): Return NotSupported when errno == XDEV by @pan93412 |
#5510 | Fix ZLS commit hash in the document by @shinichy |
#5628 | Added .DS_Store to gitignore-for-init by @Cilooth |
#5615 | Workaround #5604 by @Jarred-Sumner |
#5626 | Fix a TypeError in the documentation by @LapsTimeOFF |
#5656 | Add a way to disable the GC timer by @Jarred-Sumner |
#5660 | Remove hardcoded references to zig in Makefile by @xbjfk |
#5595 | feat(console.log): Print anonymous when class name is unknown by @JibranKalia |
#5572 | feat(test): Implement arrayContaining by @WingLim |
#5655 | In bun:sqlite , make sure we set the number tag correctly when creating the JSValue by @Jarred-Sumner |
#5662 | fix(config): support for registry url without trailing slash by @Hanaasagi |
#5685 | fix(docs): update formatting by @rauny-brandao |
#5638 | docs: add missing options from bun init by @jumoog |
#5594 | change circles for color-blinds by @Hamcker |
#5689 | Fix HTTP listen behavior being non-compliant with node by @paperdave |
#5448 | feat(runtime): Implement console.Console by @paperdave |
#5675 | Implement node_api_create_external_string_latin1 by @Jarred-Sumner |
#5699 | fix(runtime/node): Allow new Buffer.alloc() + Upgrade WebKit by @paperdave |
#5684 | fix: remove unneeded branch in toJSONWithBytes by @liz3 |
#5696 | update llvm version from 15 to 16 in makefile by @nithinkjoy-tech |
#5679 | fix: provide empty string to 0 length process environment variables by @liz3 |
#5025 | bun run fix missing script error on empty file by @Parzival-3141 |
#5444 | Add navigator type definition by @ruihe774 |
#5716 | Encode slashes in package names in the registry manifest request by @Jarred-Sumner |
#5726 | Make bun install --verbose more verbose by @Jarred-Sumner |
#5730 | Fixes #3712 by @Jarred-Sumner |
#5729 | Align fetch() redirect behavior with spec by @Jarred-Sumner |
#5744 | Get artifactory to work by @Jarred-Sumner |
#5702 | docs: Update Remix guide by @brookslybrand |
#5620 | Added react installation to react.md by @jt3k |
#5597 | remind users of the latest version by @jumoog |
#5562 | docs: update net node documentation by @weyert |
#5513 | docs(development): typo which would lead to wrong llvm installation by @sum117 |
#5759 | Doc updates by @colinhacks |
#4571 | fix(cli): bun pm cache rm command not work by @WingLim |
#5762 | fix(Makefile) by @cirospaciari |
#5775 | Fixes #5769 by @Jarred-Sumner |
#5447 | add warning to Ensure correct placement of the '--watch' flag by @a4addel |
#5456 | Updated modules.md to address issue #5420 by @h2210316651 |
#4810 | docs: add Qwik guide by @sanyamkamat |
New contributors
Thanks to Bun's newest contributors!
- @52 made their first contribution in https://github.com/oven-sh/bun/pull/5579
- @a4addel made their first contribution in https://github.com/oven-sh/bun/pull/5447
- @AaronDewes made their first contribution in https://github.com/oven-sh/bun/pull/4779
- @bdenham made their first contribution in https://github.com/oven-sh/bun/pull/5555
- @brookslybrand made their first contribution in https://github.com/oven-sh/bun/pull/5702
- @Brooooooklyn made their first contribution in https://github.com/oven-sh/bun/pull/5788
- @Cilooth made their first contribution in https://github.com/oven-sh/bun/pull/5628
- @coratgerl made their first contribution in https://github.com/oven-sh/bun/pull/4693
- @ggobbe made their first contribution in https://github.com/oven-sh/bun/pull/5786
- @h2210316651 made their first contribution in https://github.com/oven-sh/bun/pull/5456
- @Hamcker made their first contribution in https://github.com/oven-sh/bun/pull/5594
- @igorshapiro made their first contribution in https://github.com/oven-sh/bun/pull/5873
- @ImBIOS made their first contribution in https://github.com/oven-sh/bun/pull/5885
- @JeremyFunk made their first contribution in https://github.com/oven-sh/bun/pull/4652
- @JibranKalia made their first contribution in https://github.com/oven-sh/bun/pull/5595
- @jonahsnider made their first contribution in https://github.com/oven-sh/bun/pull/5104
- @jt3k made their first contribution in https://github.com/oven-sh/bun/pull/5620
- @jumoog made their first contribution in https://github.com/oven-sh/bun/pull/5638
- @liz3 made their first contribution in https://github.com/oven-sh/bun/pull/5684
- @nithinkjoy-tech made their first contribution in https://github.com/oven-sh/bun/pull/5696
- @pan93412 made their first contribution in https://github.com/oven-sh/bun/pull/5610
- @rauny-brandao made their first contribution in https://github.com/oven-sh/bun/pull/5685
- @ruihe774 made their first contribution in https://github.com/oven-sh/bun/pull/5444
- @sanyamkamat made their first contribution in https://github.com/oven-sh/bun/pull/4810
- @shinichy made their first contribution in https://github.com/oven-sh/bun/pull/5510
- @sum117 made their first contribution in https://github.com/oven-sh/bun/pull/5513
- @Vilsol made their first contribution in https://github.com/oven-sh/bun/pull/5576
- @weyert made their first contribution in https://github.com/oven-sh/bun/pull/5562
- @xbjfk made their first contribution in https://github.com/oven-sh/bun/pull/5660
- @yadav-saurabh made their first contribution in https://github.com/oven-sh/bun/pull/5270