rollup-plugin-dts-path-alias

raw JSON →
0.0.3 verified Mon Apr 27 auth: no javascript

A Rollup plugin that resolves TypeScript path aliases and baseUrl in .d.ts files, converting them to relative paths. Current version 0.0.3 (2024), stable but early-stage. Designed for individual .ts file builds (not bundled .d.ts). Key differentiator: works with @rollup/plugin-typescript, not rollup-plugin-dts. Supports monorepos and auto-discovers tsconfig.json. Helps ensure type declaration portability across projects.

error Error: Cannot find module 'rollup-plugin-dts-path-alias'
cause Package not installed or import path incorrect.
fix
npm install rollup-plugin-dts-path-alias --save-dev
error TypeError: dtsPathAlias is not a function
cause Named import used instead of default import.
fix
import dtsPathAlias from 'rollup-plugin-dts-path-alias';
error Error: Could not find tsconfig.json
cause tsconfig.json not found in cwd or parent directories.
fix
Ensure tsconfig.json exists or provide cwd option.
breaking Plugins order matters: dtsPathAlias() must be placed before typescript() to apply transformations on emitted .d.ts files.
fix Place dtsPathAlias() before typescript() in the plugins array.
gotcha Does not work with rollup-plugin-dts (rollup-plugin-dts bundles .d.ts). Use with @rollup/plugin-typescript or similar.
fix Use @rollup/plugin-typescript for individual file builds.
deprecated No deprecated features in version 0.0.3.
fix No action needed.
npm install rollup-plugin-dts-path-alias
yarn add rollup-plugin-dts-path-alias
pnpm add rollup-plugin-dts-path-alias

Typical Rollup config using @rollup/plugin-typescript and dtsPathAlias to compile TypeScript and resolve path aliases in .d.ts files.

import typescript from '@rollup/plugin-typescript';
import dtsPathAlias from 'rollup-plugin-dts-path-alias';

export default {
  input: 'src/index.ts',
  output: {
    dir: 'dist',
    format: 'es',
  },
  plugins: [
    dtsPathAlias(),
    typescript(),
  ],
};