我們正在舊金山招聘系統工程師,共同打造 JavaScript 的未來!
此版本修正了 13 個錯誤(解決了 50 個 👍),並提升了與 Node.js 的相容性。Node.js 測試套件中 82% 的 'streams' 模組測試現在已可在 Bun 中通過。node:crypto 現在實作了 diffieHellman、getCipherInfo 和 X509Certificate。checkServerIdentity 物件現在符合 Node.js 的格式。Bun 的 fs.mkdirSync 方法以及使用查詢字串匯入的功能也進行了錯誤修正。
安裝 Bun
curl -fsSL https://bun.dev.org.tw/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
升級 Bun
bun upgrade
node:stream 相容性改進
node:stream 現在可通過 Node.js 測試套件的 82%。其餘測試失敗的幾個案例是在測試 Bun 中不存在的 Node.js 內部組件。
感謝 @nektro!
node:crypto 改進
X509Certificate
此版本在 node:crypto
中實作了 X509Certificate
。
import { X509Certificate } from "node:crypto";
// Create a new X.509 certificate from a string
const cert = new X509Certificate(
"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
);
// Get the subject of the certificate
console.log(cert.subject); // Outputs the subject's distinguished name
感謝 @dylan-conway!並感謝 @jasnell 提供的 ncrypt
包裝函式庫,Bun、Cloudflare Workers 和 Node.js 均有使用。
diffieHellman
diffieHellman
方法現在已在 node:crypto
中實作。
getCipherInfo
getCipherInfo
方法現在已在 node:crypto
中實作。
Certificate
具有靜態方法 exportPublicKey
、exportChallenge
和 verifySpkac
的 Certificate
類別現在已在 node:crypto
中實作。
checkServerIdentity 修正
由 checkServerIdentity
(用於 node:http、node:tls 以及 fetch
中)傳回的 X509 物件,現在符合 Node.js 中 X509 物件的格式。某些欄位在 Bun 中是字串,而在 Node.js 中是字串陣列,現在在 Bun 中也變為字串陣列。
已修正:node:tls 中涉及 X509 憑證的記憶體洩漏
已修正 node:tls 中涉及 X509 憑證的記憶體洩漏問題。
已修正:fs.mkdir 遞迴迴歸
在 Bun v1.1.44 中引入的迴歸(在處理 node:fs 相容性時),導致當目標目錄已存在時,fs.mkdirSync
會拋出錯誤。此提交修正了此迴歸問題。
it("fs.mkdirSync recursive should not error when the directory already exists, but should error when its a file", () => {
expect(() =>
mkdirSync(import.meta.dir, { recursive: true }),
).not.toThrowError();
expect(() => mkdirSync(import.meta.path, { recursive: true })).toThrowError();
});
已修正:匯入帶有 ?query 字串的重複模組時的卡頓問題
在 Bun v1.1.21 中引入的迴歸,導致 Bun 在匯入 URL 中帶有查詢字串的模組時會卡頓。此提交修正了此迴歸問題。
// This used to hang
import myModule from "./myModule.js";
import myModule2 from "./myModule.js?param=value";
// This did not hang
import myModule3 from "./myModule.js?param=value";
import myModule4 from "./myModule.js";