我們正在招募 C/C++ 和 Zig 工程師,一同打造 JavaScript 的未來!
Bun v0.5.1 新增了對 package.json 依賴項別名、在找不到工作區時提供更佳錯誤訊息,以及一些重要的錯誤修復的支援。此版本是 Bun v0.5 的後續版本。
# Install Bun
curl https://bun.dev.org.tw/install | bash
# Upgrade to latest release of Bun
bun upgrade
在 package.json 中設定依賴項別名
bun install
現在支援透過 npm:
前綴設定依賴項別名(感謝 @alexlamsl)
這讓您可以安裝同一個依賴項的多個版本,並將它們放置在 node_modules
中不同的資料夾下。
package.json
:
{
"name": "all-the-lodashes",
"dependencies": {
"lodash": "^4.17.21",
"lodash3": "npm:lodash@3"
}
}
index.ts
:
const lodash3 = require("lodash3");
const lodash4 = require("lodash");
console.log(lodash3.VERSION);
console.log(lodash4.VERSION);
輸出
❯ bun index.ts
3.10.1
4.17.21
npm
、yarn
和其他工具也支援此功能。先前,當 package.json 使用此功能時,bun install
會顯示錯誤訊息,因為它尚未實作。
找不到工作區時提供更佳錯誤訊息
之前
bun install v0.5.0 (2db04ef9)
error: FileNotFound
bun could not find a file, and the code that produces this error is missing a better error.
----- bun meta -----
Bun v0.5.0 (2db04ef9) macOS Silicon 22.2.0
InstallCommand: bunfig
Elapsed: 4ms | User: 5ms | Sys: 9ms
RSS: 14.07MB | Peak: 14.07MB | Commit: 69.22MB | Faults: 12
----- bun meta -----
之後
bun install v0.5.1 (f993975a)
error: Workspace not found "i-dont-exist" in "/private/tmp/bun-bad-workspace"
"workspaces": ["i-dont-exist"]
^
/private/tmp/bun-bad-workspace/package.json:3:18
對於像這樣的 package.json
{
"name": "my-workspace",
"workspaces": ["i-dont-exist"]
}
錯誤修復
此版本修復了一些重要的錯誤
- v0.5.0 中引入的一個回歸錯誤,讀取
"encoding"
字串會導致崩潰 fetch
未正確連接以讀取HTTPS_PROXY
/HTTP_PROXY
環境變數(由 @cirospaciari 修復)- 將
require
賦值給變數,如果多次使用會導致undefined is not an object
錯誤 #1831 - 處理長工作區名稱列表時有時會發生的崩潰
node:fs
中缺少rmdir
(由 @alexlamsl 修復)- 來自 BoringSSL 的錯誤訊息未被正確讀取
- 修復了建構函式中 TypeScript 參數欄位的轉譯器問題。此回歸錯誤是在實作 TypeScript 裝飾器時引入的 #1855(由 @dylan-conway 修復)
PR
#1836 | 由 @colinhacks 提供的 Fix/simplify bun-types release |
---|---|
#1838 | 由 @alexlamsl 提供的 add fs.rmdir & friends |
#1837 | 由 @alexlamsl 提供的 support npm dependency aliasing |
#1844 | 由 @cirospaciari 提供的 fix(fetch:HTTP_PROXY) fix support for HTTP_PROXY/HTTPS_PROXY and NO_PROXY in fetch instances |
#1827 | 由 @gornostay25 提供的 Create new example http-file-extended.ts |
#1848 | 由 @Jarred-Sumner 提供的 Bugfixes to install |
#1850 | 由 @alexlamsl 提供的 use String.from() |