{"name":"typescript-transform-paths","version":"3.5.3","keywords":["typescript","transform","transformer","plugin","path","paths","virtual directory","import","require"],"license":"MIT","_id":"typescript-transform-paths@3.5.3","maintainers":[{"name":"danielpza","email":"danielpza+npm@protonmail.com"}],"contributors":[{"name":"Daniel Perez"},{"url":"https://twitter.com/Ron","name":"Ron S."}],"homepage":"https://github.com/LeDDGroup/typescript-transform-paths#readme","bugs":{"url":"https://github.com/LeDDGroup/typescript-transform-paths/issues"},"dist":{"shasum":"bb456773abf3382d06a372cca6dce23218a0daed","tarball":"http://registry-npm.ywwl.com/typescript-transform-paths/download/typescript-transform-paths-3.5.3.tgz","fileCount":69,"integrity":"sha512-5y2l2iPKNHKOj08/1i+02+ljBVUhWcXQLXomiOXCmNpiTuSxIkj0dM1LUE7OOAt53+/6KidY+sFTCP781J64Eg==","signatures":[{"sig":"MEUCIQCvcoQXBtCau3iWs/fXBKrEbFZyjk58tzFuirYF/5kcHAIgXbMr93Qbha2lBOaJB215ay4/HeDa0DCgO5OVSL89B70=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/typescript-transform-paths@3.5.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":148130,"size":35101,"noattachment":false,"key":"/typescript-transform-paths/-/typescript-transform-paths-3.5.3.tgz"},"main":"./dist/index.js","type":"commonjs","types":"types/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./register":"./dist/register-entry.js","./nx-transformer":"./dist/plugins/nx-transformer-plugin.js"},"gitHead":"27864491889f1e5cbcb475c92a36ff8b09a9fb17","scripts":{"lint":"prettier --check . && eslint .","test":"yarn test/ test","build":"yarn clean && yarn compile","clean":"rm -rf \"**/dist\"","reset":"yarn clean:all && yarn install && yarn build","format":"prettier --write .","compile":"tsc","prepack":"yarn build","release":"changelogen --release --push","clean:all":"yarn clean && rm -rf node_modules \"**/node_modules\" \"**/yarn.lock\" yarn.lock","--------------":"","-------------- ":""},"_npmUser":{"name":"danielpza","email":"danielpza+npm@protonmail.com"},"prettier":{"plugins":["prettier-plugin-jsdoc"]},"repository":{"url":"git+https://github.com/LeDDGroup/typescript-transform-paths.git","type":"git"},"_npmVersion":"10.9.0","description":"Transforms module resolution paths using TypeScript path mapping and/or custom paths","directories":{},"_nodeVersion":"22.12.0","dependencies":{"minimatch":"^9.0.5"},"_hasShrinkwrap":false,"packageManager":"yarn@4.5.3+sha512.3003a14012e2987072d244c720506549c1aab73ee728208f1b2580a9fd67b92d61ba6b08fe93f6dce68fd771e3af1e59a0afa28dd242dd0940d73b95fedd4e90","devDependencies":{"eslint":"9.x","globals":"^15.9.0","prettier":"^3.3.3","ts-patch":"^3.2.1","@eslint/js":"^9.9.1","typescript":"^5.5.4","@types/node":"^22.5.2","changelogen":"^0.5.5","@types/eslint":"^9","@types/ts-node":"npm:ts-node@^10.9.2","@tsconfig/node18":"^18.2.4","@types/minimatch":"^5.1.2","typescript-eslint":"^8.3.0","@tsconfig/strictest":"^2.0.5","@types/typescript-3":"npm:typescript@3.x","@types/typescript-4.7":"npm:typescript@4.9.x","prettier-plugin-jsdoc":"^1.3.0","@types/ts-expose-internals":"npm:ts-expose-internals@4.9.5"},"peerDependencies":{"typescript":">=3.6.5"},"_npmOperationalInternal":{"tmp":"tmp/typescript-transform-paths_3.5.3_1734852217353_0.5275168315745271","host":"s3://npm-registry-packages-npm-production"},"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":1734852217603,"_cnpm_publish_time":1734852217603,"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"}}