Bun 會讀取 tsconfig.json
中的 paths
欄位,以重新撰寫匯入路徑。這對於建立套件名稱別名或避免使用長相對路徑很有用。
{
"compilerOptions": {
"paths": {
"my-custom-name": ["zod"],
"@components/*": ["./src/components/*"]
}
}
}
使用上述 tsconfig.json
,將會重新撰寫下列匯入
import { z } from "my-custom-name"; // imports from "zod"
import { Button } from "@components/Button"; // imports from "./src/components/Button"
請參閱 文件 > 執行時期 > TypeScript,以取得有關如何將 TypeScript 與 Bun 搭配使用的更多資訊。