目录
Bun 1.2 发布:Node.js 兼容性大提升,内置 S3 和 Postgres 支持!
Bun 1.2 迎来了重大更新,带来 Node.js 兼容性、云原生支持和性能提升等多项改进。
一、Node.js 兼容性飞跃
Bun 1.2 开始运行 Node.js 测试套件,修复了数千个 bug,多个 Node.js 模块的测试通过率超过 90%。Bun 团队通过模拟 Node.js 内部 API、调整错误信息和移植测试文件等方式,逐步提高兼容性。
新增支持的 Node.js 模块包括:
node:http2
服务器: 性能是 Node.js 的两倍。
import {
createSecureServer } from "node:http2";
// ...
node:dgram
: 支持 UDP sockets,使 DataDog 的dd-trace
和@clickhouse/client
等包能够在 Bun 中工作。
import {
createSocket } from "node:dgram";
// ...
node:cluster
: 支持多线程,提高吞吐量。
import cluster from "node:cluster";
// ...
node:zlib
: 重写为原生代码,性能提升两倍,并新增 Brotli 支持。
import {
brotliCompressSync } from