@ttsc/paths
v0.15.1
Published
First-party ttsc plugin that rewrites emitted module specifiers from tsconfig paths.
Readme
@ttsc/paths

@ttsc/paths rewrites module specifiers that match compilerOptions.paths into relative JavaScript and declaration imports.
Setup
Install ttsc and TypeScript-Go, then the paths plugin:
npm install -D ttsc @typescript/native-preview
npm install -D @ttsc/pathsRun your normal ttsc command:
npx ttscConfiguration
@ttsc/paths has no separate plugin options. It reads the same compilerOptions.paths, rootDir, and outDir values that ttsc uses for the project.
Configure those fields under compilerOptions:
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"],
"@lib/*": ["./src/modules/*"],
},
"rootDir": "src",
"outDir": "dist",
},
}An import such as import { value } from "@lib/value" becomes a relative JavaScript import such as import { value } from "./modules/value.js". Declaration output follows the same source rewrite.
outDir must be set for the rewrite to run. Without it, @ttsc/paths cannot map a source path to its emitted location and makes no changes. rootDir is optional: when omitted it is derived from the common source directory.
Sponsors
Thanks for your support.
Your donation encourages ttsc development.
References
Inspired by typescript-transform-paths.
