# rollup-plugin-typescript-paths

> Rollup plugin to automatically resolve TypeScript path aliases.

Latest version **1.5.0** (published 2023-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-typescript-paths
pnpm add rollup-plugin-typescript-paths
yarn add rollup-plugin-typescript-paths
bun add rollup-plugin-typescript-paths
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2023-12-22 |
| First published | 2019-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Simon Haenisch |
| Maintainers | simonhaenisch |
| Keywords | rollup-plugin, typescript |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-typescript-paths
- Repository: https://github.com/simonhaenisch/rollup-plugin-typescript-paths
- Homepage: https://github.com/simonhaenisch/rollup-plugin-typescript-paths#readme
- Issues: https://github.com/simonhaenisch/rollup-plugin-typescript-paths/issues
- npm.io page: https://npm.io/package/rollup-plugin-typescript-paths

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2023-12-22
- 1.4.0 — 2022-08-12
- 1.3.1 — 2022-02-25
- 1.3.0 — 2021-05-10
- 1.2.3 — 2021-04-21
- 1.2.2 — 2020-02-18
- 1.2.1 — 2020-02-02
- 1.2.0 — 2019-05-29
- 1.1.1 — 2019-05-25
- 1.1.0 — 2019-05-25
- 1.0.0 — 2019-05-21

## README

# rollup-plugin-typescript-paths

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/simonhaenisch/rollup-plugin-typescript-paths/main.yml)](https://github.com/simonhaenisch/rollup-plugin-typescript-paths/actions?query=branch%3Amaster)

Rollup Plugin to automatically resolve path aliases set in the `compilerOptions` section of `tsconfig.json`.

Don't use it if you're already using [rollup-plugin-typescript](https://github.com/rollup/rollup-plugin-typescript). This plugin is only for use cases where your TypeScript code has already been transpiled before `rollup` runs.

For example, if you have

```js
// tsconfig.json
{
  "compilerOptions": {
    // ...
    "baseUrl": ".",
    "paths": {
      "@utils": ["src/helpers/utils"]
    }
  }
}
```

```js
import { something } from '@utils';
```

Then this plugin will make sure that rollup knows how to resolve `@utils`.

## Features

- No config required. 😎
- Wildcards are supported. 💪
- Uses `nodeModuleNameResolver` from the Typescript API. 🤓

## Installation

```
npm install --save-dev rollup-plugin-typescript-paths
```

## Usage

```js
import { typescriptPaths } from 'rollup-plugin-typescript-paths';

export default {
  // ...
  plugins: [typescriptPaths()],
};
```

## Options

- **`absolute`:** Whether to resolve to absolute paths; defaults to `true`.
- **`nonRelative`:** Whether to resolve [non-relative paths](https://www.typescriptlang.org/docs/handbook/module-resolution.html#relative-vs-non-relative-module-imports) based on tsconfig's `baseUrl`, even if none of the `paths` are matched; defaults to `false`.
- **`preserveExtensions`:** Whether to preserve `.ts` and `.tsx` file extensions instead of having them changed to `.js`; defaults to `false`.
- **`tsConfigPath`:** Custom path to your `tsconfig.json`. Use this if the plugin can't seem to find the correct one by itself.
- **`transform`:** If the plugin successfully resolves a path, this function allows you to hook into the process and transform that path before it is returned.

## License

[MIT](/license).

---
_Source: https://npm.io/package/rollup-plugin-typescript-paths · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
