32 lines
738 B
Plaintext
32 lines
738 B
Plaintext
---
|
|
title: Re-map import paths
|
|
sidebarTitle: Re-map import paths
|
|
mode: center
|
|
---
|
|
|
|
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.
|
|
|
|
```json tsconfig.json icon="file-json"
|
|
{
|
|
"compilerOptions": {
|
|
"paths": {
|
|
"my-custom-name": ["./node_modules/zod"],
|
|
"@components/*": ["./src/components/*"]
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
With this `tsconfig.json`, Bun re-writes the following imports:
|
|
|
|
```ts tsconfig.ts icon="/icons/typescript.svg"
|
|
import { z } from "my-custom-name"; // imports from "zod"
|
|
import { Button } from "@components/Button"; // imports from "./src/components/Button"
|
|
```
|
|
|
|
---
|
|
|
|
See [TypeScript](/runtime/typescript).
|