bun-v0.0.69
版本发布时间: 2022-02-07 07:06:24
oven-sh/bun最新发布版本:bun-v1.1.20(2024-07-13 14:04:45)
To upgrade:
bun upgrade
# If you run into problems, try this instead:
curl https://bun.sh/install | bash
bun v0.0.69
Highlights:
- Reliability improvements to bun's https client, which means reliability improvements to
bun install
,fetch()
,bun create
,bun upgrade
, and everything else depending on it -
bunfig.toml
lets you configure bun from a config file instead of only CLI arguments -
import foo from "./file.toml"
is now supported (thanks to bun's new TOML parser) - No longer need to install the
react-refresh
npm package for React Fast Refresh to work - Native support for Node.js
path
module -
bun dev
includes a default favicon, and the favicon becomes a red ⚠️ on build error
HTTPS client
I rewrote the TLS part of bun's https client to match Chromium's behavior.
This fixes many bugs:
- On some websites using TLS 1.3, the https client would infinite loop during handshaking
- On some machines,
bun dev
would crash after 30 seconds due to bugs with the https client. Since it happened in a random interval between 0 and 30 seconds, it appeared to be in many places - On Ubuntu 20.04 when running Linux kernel 5.4 (the default for ubuntu server), sending http requests simply did not work at all. This was due to using io_uring APIs which are only available on Linux Kernel 5.6. Now, bun detects the linux kernel version in use and uses a (slower) fallback if the APIs are unavailable
- In some cases, it was closing socket file descriptors multiple times, leading to strange bugs like files failing to extract files during
bun install
or data corruption - In some cases, it was never closing socket file descriptors. This eventually led to errors about all sockets being busy
- Previously, bun cached the results returned from
getaddrinfo
. On Linux, this sometimes caused it to crash. Now bun does not cache it. This makes it a little slower, but this way of doing DNS resolution needs to be replaced with a non-blocking implementation regardless.
bunfig.toml
bunfig.toml is bun's configuration file.
Everything in it is optional. You don't need a bunfig.toml
to use bun, this exists so you don't have to pass flags to the CLI each time.
Options specific to bun install
will be added in a future release.
# Set a default framework to use
# By default, bun will look for an npm package like `bun-framework-${framework}`, followed by `${framework}`
framework = "next"
logLevel = "debug"
# publicDir = "public"
# external = ["jquery"]
[macros]
# Remap any import like this:
# import {graphql} from 'react-relay';
# To:
# import {graphql} from 'macro:bun-macro-relay';
react-relay = { "graphql" = "bun-macro-relay" }
[bundle]
saveTo = "node_modules.bun"
# Don't need this if `framework` is set, but showing it here as an example anyway
entryPoints = ["./app/index.ts"]
[bundle.packages]
# If you're bundling packages that do not actually live in a `node_modules` folder or do not have the full package name in the file path, you can pass this
"@bigapp/design-system" = true
[dev]
# Change the default port from 3000 to 5000
port = 5000
[define]
# Replace any usage of "process.env.bagel" with the string `lox`.
# The values are parsed as JSON, except single-quoted strings are supported and `'undefined'` becomes `undefined` in JS.
# This will probably change in a future release to be just regular TOML instead. It is a holdover from the CLI argument parsing.
"process.env.bagel" = "'lox'"
[loaders]
# When loading a .bagel file, run the JS parser
".bagel" = "js"
TOML imports
bun now has a custom TOML 1.0 parser, which means you can import .toml files from bun.
Note that parsing dates/timestamps is not implemented yet.
import config from 'my-config-file.toml';
console.assert(config.hi === "hello");
hi = "hello"
A future version might support importing top-level properties instead of only default
. I think supporting both ways would be a better DX.
bun dev
This release improves using bun for static sites. bun dev
now automatically looks for .html
files in the same folder as code. Previously, .html
files needed to be in either public
or static
You no longer need to install the react-refresh
npm package to use React Fast Refresh with bun. bun embeds it into bun's binary and automatically enables it if resolving "react"
(or otherwise, the JSX import source) is successful
bun sets a default favicon so you can more easily see which tab is your dev server:
Path module
bun.js gets native support for Node's path
module. This is a performance improvement, but it's also good for consistency & reliability. It means that resolving file paths in JavaScript is consistent with native code.
// Any of these work
import * as path from "node:path";
import * as path from "path";
const path = require("path");
As part of that work, a bug was fixed when generating relative file paths where, in some cases, it would cut off the first letter if the destination
file path did not have any folders in common with the from
file path
Misc:
- Missing newline in errors in bun install - 1064b9dada6e9920f3f2e241bedb70570de032f5
- Fix JS printing edgecase with nested vars using destructuring - d47e0de1750c9d234febdebeac4415470deea008
- Fix CommonJS <> ESM interop edgecase when
require()
bundled code - 73449bf43373ee3a23f080e3b9ce144bc93db27c - bun.js resolve dynamic imports lazily - https://github.com/Jarred-Sumner/bun/commit/0e0bfe91d050fc7fa645c8a1169db600a2ecd0ed
- Reduced memory usage for object pools. For many things, bun uses object pools to spend less time allocating and deallocating memory. Once allocated, these are never freed. Now object pools have a limit to how many are kept alive in the pool. 213960a04a22bed4d0ffb3cdc9e20439bd1dcc10
- Use a special heap for the https client
Thanks to:
- @minkbazink for the idea to call bun's config bunfig.toml and @robpalmer2
- @alexkuz for making it a little easier compile debug builds on mac https://github.com/Jarred-Sumner/bun/commit/aad33c2611ae08d142a68213ece0eeb072621113
1、 bun-darwin-aarch64.dSYM.tar.gz 15.7MB
2、 bun-darwin-aarch64.zip 10.07MB
3、 bun-darwin-x64.dSYM.tar.gz 112.85MB
4、 bun-darwin-x64.zip 11.77MB
5、 bun-linux-x64.zip 23.8MB