> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 重映射导入路径

Bun 读取 `tsconfig.json` 中的 `paths` 字段以重写导入路径。这对于给包名起别名或避免长相对路径很有用。

```json tsconfig.json icon="file-json" theme={null}
{
  "compilerOptions": {
    "paths": {
      "my-custom-name": ["./node_modules/zod"],
      "@components/*": ["./src/components/*"]
    }
  }
}
```

***

使用此 `tsconfig.json`，以下导入将被重写：

```ts tsconfig.ts icon="https://mintcdn.com/span-inc/82N53aP7NFbaCVSl/icons/typescript.svg?fit=max&auto=format&n=82N53aP7NFbaCVSl&q=85&s=787d39d6a7d96d7f9540dc74344eba23" theme={null}
import { z } from "my-custom-name"; // 从 "zod" 导入
import { Button } from "@components/Button"; // 从 "./src/components/Button" 导入
```

***

参见 [TypeScript](/runtime/typescript)。
