Bun v0.0.40 #33
Jarred-Sumner
announced in
Announcements
Replies: 1 comment
-
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
-
It's been a busy couple weeks.
Important: the
bun-cli
npm package is deprecated. It will not receive updates.Please upgrade Bun by running:
curl bun.sh/install | bash
For future upgrades:
Now the fun part.
bun run
~35x faster package.json
"scripts"
runner, powered by Bun. Instead ofnpm run
, trybun run
.Like
npm run
,bun run
reads"scripts"
in your package.json and runs the script in a shell with the samePATH
changes as npm clients. Unlike npm clients, it's fast.You can use
bun run
in projects that aren't using Bun for transpiling or bundling. It only needs apackage.json
file.When scripts launch a Node.js process,
bun run
still beatsnpm run
by 2x:Why? Because npm clients launch an extra instance of Node.js. With
npm run
, you wait for Node.js to boot twice. Withbun run
, you wait once.For maximum performance, if nested
"scripts"
run other npm tasks,bun run
automatically runs the task with Bun instead. This means adding many tasks won't slow you down as much.bun run
supports lifecycle hooks you expect likepre
andpost
and works when thepackage.json
file is in a parent directory.Two extra things:
bun run
also adds anynode_modules/.bin
executables to the PATH, so e.g. if you're using Relay, you can dobun run relay-compiler
and it will run the version ofrelay-compiler
for the specific project.bun run
has builtin support for.env
. It reads:.env.local
, then.env.development
||.env.production
(respecting yourNODE_ENV
), and.env
in the current directory or enclosing package.json's directoryOh and you can drop the
run
:It's cleaner.
Reliability
Lots of work went into improving the reliability of Bun over the last couple weeks.
Here's what I did:
bun create
to bootstrap the projects..env
loader..env
values are now parsed as strings instead of something JSON-likeThere's still a lot of work ahead, but Bun is getting better.
Sometimes, speed and reliability is a tradeoff. This time, it's not. Bun seems to be about 3% faster overall compared to the last version (v0.0.36). Why? Mostly due to many small changes to the lexer. Inlining iterators is good.
This discussion was created from the release Bun v0.0.40.
Beta Was this translation helpful? Give feedback.
All reactions