Skip to main content

Re-map import paths

还没翻译译自英文(bun.com)本页 4 段都还没译

Bun reads the paths field in your tsconfig.json to re-write import paths. This is useful for aliasing package names or avoiding long relative paths.

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

With this tsconfig.json, Bun re-writes the following imports:

import { z } from "my-custom-name"; // imports from "zod"
import { Button } from "@components/Button"; // imports from "./src/components/Button"

See TypeScript.

译文 © 2026 fanyi.dev · 原文 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)