Registry / web-framework / rollup-plugin-ts-paths

rollup-plugin-ts-paths

JSON →
library1.0.5jsnpmunverified

A Rollup plugin (v1.0.5) that resolves TypeScript path aliases defined in tsconfig.json to their actual file paths during bundling. It allows developers to use TypeScript's paths feature with Rollup, enabling clean imports like `import { Foo } from 'foo'` which maps to a source file path. The plugin is lightweight, has no external runtime dependencies, and must be placed before other Rollup plugins like commonjs to ensure correct resolution. However, it only supports the first entry in a paths array, and it is primarily useful for projects that first compile with tsc and then bundle with Rollup. The package ships TypeScript types and is maintained on GitHub.

npm install rollup-plugin-ts-paths
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-TS-P
R
rollup-plugin-ts-paths
web-frameworkjavascriptv1.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import tsConfigPaths from 'rollup-plugin-ts-paths'
const { tsConfigPaths } = require('rollup-plugin-ts-paths')
Default export; named import does not exist. ESM-only; CommonJS require must use default import pattern.
TypeScript type: Options
import type { Options } from 'rollup-plugin-ts-paths'
TypeScript users can import the Options type for configuration. Not exported as runtime value.

Basic Rollup config using rollup-plugin-ts-paths to resolve TypeScript path aliases, placed before nodeResolve and commonjs plugins.

// rollup.config.js import tsConfigPaths from 'rollup-plugin-ts-paths'; import commonjs from '@rollup/plugin-commonjs'; import { nodeResolve } from '@rollup/plugin-node-resolve'; export default { input: 'src/index.ts', output: { dir: 'dist', format: 'esm' }, plugins: [ tsConfigPaths(), // Must come before other resolvers nodeResolve(), commonjs() ] }
Debug
Known issues
gotchaPlugin only resolves the first entry in a tsconfig paths array; subsequent entries are ignored.
fix
Ensure the first path entry is the intended one, or avoid using multiple fallback paths.
affects: <=1.0.5
gotchaPlace before other Rollup plugins that resolve imports (like nodeResolve or commonjs), otherwise paths may not be resolved.
fix
Order the plugin first in the plugins array.
affects: all
gotchaRequires tsconfig.json to be present; does not support jsconfig.json or alternative config files.
fix
Ensure tsconfig.json exists in the project root or specify tsConfigDirectory option.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'foo'
Plugin not placed before other resolvers or tsconfig paths not configured correctly.
fix
Ensure tsConfigPaths() is first in plugins array and that foo is defined in tsconfig.json paths.
TypeError: tsConfigPaths is not a function
Using named import instead of default import.
fix
Use `import tsConfigPaths from 'rollup-plugin-ts-paths'`.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
rollup-plugin-ts-paths — npm install rollup-plugin-ts-paths · libregistry