{"name":"typescript-transform-paths","version":"4.0.0","description":"Transforms module resolution paths using TypeScript path mapping and/or custom paths","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./plugins/nx":"./dist/plugins/nx.js"},"scripts":{"compile":"tsc","build":"yarn clean && yarn compile","test":"yarn test/ test","release":"changelogen --release --push","--------------":"","format":"prettier --write .","lint":"prettier --check . && eslint .","clean":"rm -rf \"**/dist\"","clean:all":"yarn clean && rm -rf node_modules \"**/node_modules\" \"**/yarn.lock\" yarn.lock","reset":"yarn clean:all && yarn install && yarn build","-------------- ":"","prepack":"yarn build"},"keywords":["typescript","transform","transformer","plugin","path","paths","virtual directory","import","require"],"homepage":"https://github.com/LeDDGroup/typescript-transform-paths#readme","bugs":{"url":"https://github.com/LeDDGroup/typescript-transform-paths/issues"},"repository":{"type":"git","url":"git+https://github.com/LeDDGroup/typescript-transform-paths.git"},"license":"MIT","contributors":[{"name":"Daniel Perez"},{"name":"Ron S.","url":"https://twitter.com/Ron"}],"devDependencies":{"@eslint/js":"^9.39.2","@tsconfig/bases":"^1.0.16","@types/eslint":"^9","@types/minimatch":"^5.1.2","@types/node":"^24.10.4","@types/ts-expose-internals":"npm:ts-expose-internals@4.9.5","changelogen":"^0.6.2","eslint":"9.x","globals":"^16.5.0","prettier":"^3.7.4","prettier-plugin-jsdoc":"^1.8.0","ts-patch":"^3.3.0","typescript":"^5.9.3","typescript-eslint":"^8.51.0"},"peerDependencies":{"typescript":">=5"},"dependencies":{"minimatch":"^10.1.1"},"prettier":{"plugins":["prettier-plugin-jsdoc"]},"engines":{"node":">=22"},"packageManager":"yarn@4.12.0+sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8","gitHead":"0e7f37d089573bec206520efb4edeaf48a6542ce","_id":"typescript-transform-paths@4.0.0","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-cQ5MbIFApCsQ2dWL9bkjLJCaV+QnKmkm5thu6yRCmZEkXBmQRIWcwXFDA5kBIUiA5p2tZSweNaE34a7WlHdBsw==","shasum":"4da369c967de69ea9390d03e4db9d6b5cfbdb341","tarball":"http://registry-npm.ywwl.com/typescript-transform-paths/download/typescript-transform-paths-4.0.0.tgz","fileCount":40,"unpackedSize":118377,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGvIckue8vJREVo2EBXFWfJEFcQrGhg6WKz2QT44VcuaAiBgt7ujm35Ck9d03ixJZkQQW+eVmD/OdrQB9ZAYAIrCww=="}],"size":29016,"noattachment":false,"key":"/typescript-transform-paths/-/typescript-transform-paths-4.0.0.tgz"},"_npmUser":{"name":"danielpza","email":"danielpza+npm@protonmail.com"},"directories":{},"maintainers":[{"name":"danielpza","email":"danielpza+npm@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-transform-paths_4.0.0_1779049918939_0.5740469085026385"},"_hasShrinkwrap":false,"readme":"<h1 align=\"center\">typescript-transform-paths</h1>\n<p align=\"center\">Transform compiled source module resolution paths using TypeScript's <code>paths</code> config, and/or custom resolution paths</p>\n<div align=\"center\">\n\n[![npm version](https://img.shields.io/npm/v/typescript-transform-paths.svg)](https://www.npmjs.com/package/typescript-transform-paths)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FLeDDGroup%2Ftypescript-transform-paths%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/LeDDGroup/typescript-transform-paths/goto?ref=master)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\n</div>\n\n> [!TIP]  \n> Upgrading from v3 to v4? See the [migration](./docs/migrating-to-v4.md) documentation.\n\n> [!IMPORTANT]  \n> We are [looking for maintainers][issue-439].  \n> Explore [alternatives][issue-438].\n\n## Setup Steps\n\n### 1. Install\n\n```sh\n<yarn|npm|pnpm> add -D typescript-transform-paths\n```\n\n### 2. Configure\n\nAdd it to `plugins` in your `tsconfig.json` file.\n\n#### Example Configuration\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"baseUrl\": \"./\",\n    // Configure your path mapping here\n    \"paths\": {\n      \"@utils/*\": [\"utils/*\"],\n    },\n    // Note: to transform paths for both the output .js and .d.ts files,\n    //       you need both of the below entries\n    \"plugins\": [\n      // Transform paths in output .js files\n      { \"transform\": \"typescript-transform-paths\" },\n\n      // Transform paths in output .d.ts files (include this line if you output declarations files)\n      { \"transform\": \"typescript-transform-paths\", \"afterDeclarations\": true },\n    ],\n  },\n}\n```\n\n#### Example Result\n\n`core/index.ts`\n\n```ts\n// The following import path is transformed to '../utils/sum'\nimport { sum } from \"@utils/sum\";\n```\n\n### 3. Use\n\n- Compile with **`tsc`** — Use [ts-patch][ts-patch].\n- Run with **`ts-node`** — See the [Wiki][ts-node-wiki].\n- Integrate with **Nx** — Add the `typescript-transform-paths/plugins/nx` transformer to the project configuration.\n\n  `project.json`\n\n  ```jsonc\n  {\n    /* ... */\n    \"targets\": {\n      \"build\": {\n        /* ... */\n        \"options\": {\n          /* ... */\n          \"transformers\": [\n            {\n              \"name\": \"typescript-transform-paths/plugins/nx\",\n              \"options\": { \"afterDeclarations\": true },\n            },\n          ],\n        },\n      },\n    },\n  }\n  ```\n\n## Virtual Directories\n\nTypeScript allows defining [Virtual Directories][virtual-directories] via the `rootDirs` compiler option.  \nTo enable Virtual Directory mapping, use the `useRootDirs` plugin option.\n\n`tsconfig.json`\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"rootDirs\": [\"src\", \"generated\"],\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"#root/*\": [\"./src/*\", \"./generated/*\"],\n    },\n    \"plugins\": [\n      { \"transform\": \"typescript-transform-paths\", \"useRootDirs\": true },\n      { \"transform\": \"typescript-transform-paths\", \"useRootDirs\": true, \"afterDeclarations\": true },\n    ],\n  },\n}\n```\n\n#### Example\n\n```text\n├src/\n├─ subdir/\n│  └─ sub-file.ts\n├─ file1.ts\n├generated/\n├─ file2.ts\n```\n\n`src/file1.ts`\n\n```ts\nimport \"#root/file2.ts\"; // Resolves to './file2'\n```\n\n`src/subdir/sub-file.ts`\n\n```ts\nimport \"#root/file2.ts\"; // Resolves to '../file2'\nimport \"#root/file1.ts\"; // Resolves to '../file1'\n```\n\n## Custom Control\n\n### Exclusion Patterns\n\nYou can disable transformation for paths based on the resolved file path.  \nThe `exclude` option allows specifying Glob patterns to match against those resolved file paths.\n\nFor an example context in which this would be useful, see [issue #83][issue-83].\n\n`tsconfig.json`\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"sub-module1/*\": [\"../../node_modules/sub-module1/*\"],\n      \"sub-module2/*\": [\"../../node_modules/sub-module2/*\"],\n    },\n    \"plugins\": [\n      {\n        \"transform\": \"typescript-transform-paths\",\n        \"exclude\": [\"**/node_modules/**\"],\n      },\n    ],\n  },\n}\n```\n\n```ts\n// This path will NOT be transformed\nimport * as sm1 from \"sub-module1/index\";\n```\n\n### @transform-path\n\nUse the `@transform-path` tag to explicitly specify the output path for a single statement.\n\n```ts\n// @transform-path https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js\nimport react from \"react\"; // Output path will be the URL defined above\n```\n\n### @no-transform-path\n\nUse the `@no-transform-path` tag to explicitly disable transformation for a single statement.\n\n```ts\n// @no-transform-path\nimport \"normally-transformed\"; // This will remain 'normally-transformed' even though\n//                                it has a different value in paths config\n```\n\n## Version Compatibility\n\n| typescript-transform-paths | TypeScript            | Node.js |\n| -------------------------- | --------------------- | ------- |\n| ^4.0.0                     | >=5.x                 | >=22    |\n| ^3.5.2                     | >=3.6.5, >=4.x, >=5.x | >=18    |\n\n## Project Guidelines for Contributors\n\n- Package Manager: `yarn` (`yarn install`)\n- Format and lint the code before commit: `prettier` (`yarn format && yarn lint`)\n- Commit messages: [Conventional Commit Specs](https://www.conventionalcommits.org/en/v1.0.0/)\n- Releases: `changelogen` (`yarn release`)\n\n```shell\nGH_TOKEN=$(gh auth token) yarn release\n```\n\n## Alternatives\n\n- [Node.js Subpath imports][subpath-imports]\n- [Yarn Link Protocol][yarn-link-protocol]\n\n## Maintainers\n\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align=\"center\"><a href=\"https://github.com/nonara\"><img src=\"https://avatars0.githubusercontent.com/u/1427565?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Ron S.</b></sub></a></td>\n    <td align=\"center\"><a href=\"https://github.com/danielpza\"><img src=\"https://avatars2.githubusercontent.com/u/17787042?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Daniel Perez</b></sub></a></td>\n  </tr>\n</table>\n\n[ts-patch]: https://github.com/nonara/ts-patch\n[ts-node-wiki]: https://github.com/LeDDGroup/typescript-transform-paths/wiki/Integration-with-ts%E2%80%90node\n[virtual-directories]: https://www.typescriptlang.org/docs/handbook/module-resolution.html#virtual-directories-with-rootdirs\n[issue-83]: https://github.com/LeDDGroup/typescript-transform-paths/issues/83\n[issue-438]: https://github.com/LeDDGroup/typescript-transform-paths/issues/438\n[issue-439]: https://github.com/LeDDGroup/typescript-transform-paths/issues/439\n[subpath-imports]: https://nodejs.org/api/packages.html#subpath-imports\n[yarn-link-protocol]: https://yarnpkg.com/protocol/link\n","publish_time":1779049919125,"_cnpm_publish_time":1779049919125,"dist-tags":{"alpha":"3.4.0-alpha","beta":"4.0.0-beta.2","beta1":"2.1.0-beta1","beta2":"2.1.0-beta2","latest":"4.0.0","test":"3.5.3-20241222-065611-bce1be7","testing":"3.4.10-1723087060.2b01c26"}}