Skip to content

Bun は tsconfig.jsonpaths フィールドを読み取ってインポートパスを書き換えます。これはパッケージ名のエイリアス付けや、長い相対パスを回避するのに役立ちます。

json
{
  "compilerOptions": {
    "paths": {
      "my-custom-name": ["zod"],
      "@components/*": ["./src/components/*"]
    }
  }
}

上記の tsconfig.json を使用すると、次のインポートが書き換えられます。

ts
import { z } from "my-custom-name"; // "zod" からインポート
import { Button } from "@components/Button"; // "./src/components/Button" からインポート

Bun で TypeScript を使用する詳細については、ドキュメント > Runtime > TypeScript を参照してください。

Bun by www.bunjs.com.cn 編集