{"name":"typescript-transform-paths","version":"3.4.0-alpha","description":"Transforms module resolution paths using TypeScript path mapping and/or custom paths","main":"dist/index.js","types":"types/index.d.ts","scripts":{"compile":"tsc","build":"yarn run clean && yarn run compile","test":"jest","release":"standard-version","--------------":"","format":"prettier --write \"{src,test}/**/{*.js,!(*.d).ts}\"","clean":"rimraf dist **/*.tsbuildinfo","clean:all":"yarn run clean && rimraf node_modules **/node_modules test/.yarn-cache","reset":"yarn run clean:all && yarn install && yarn build","-------------- ":"","prebuild":"rimraf dist","install:tests":"cd test && yarn install && cd projects/extras && yarn install","prepare":"yarn run install:tests"},"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 Alvarez","email":"danielpza@protonmail.com"},{"name":"Ron S.","email":"ron@nonara.com"}],"devDependencies":{"@types/jest":"^26.0.24","@types/minimatch":"^3.0.5","@types/node":"^16.4.10","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","standard-version":"^9.3.1","ts-expose-internals":"^4.4.3","ts-jest":"^27.0.4","ts-node":"^10.1.0","ts-patch":"^1.4.4","typescript":"^4.4.3"},"peerDependencies":{"typescript":">=3.6.5"},"dependencies":{"minimatch":"^3.0.4"},"readme":"# typescript-transform-paths\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?style=flat-square)](https://github.com/prettier/prettier)\n![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)\n\nTransform compiled source module resolution paths using TypeScript's `paths` config, and/or custom resolution paths.\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_\n\n#### Example Config\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, 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#### Example result\n\n`core/index.ts`\n```tsx\n// The following transforms path to '../utils/sum'\nimport { sum } from \"@utils/sum\";\n```\n\n### 3. Usage\n\n- **To compile with `tsc`** — Use [ts-patch](https://github.com/nonara/ts-patch)\n\n\n- **To use with ts-node** — Add `typescript-trasnsform-paths/register` to `require` config.  \n   \n    `tsconfig.json`\n  ```jsonc\n  {\n    \"ts-node\": {\n      \"transpileOnly\": true,\n      \"require\": [ \"typescript-transform-paths/register\" ],\n    },\n    \"compilerOptions\" { /* ... */ }\n  }\n  ```\n\n- **To use with node** — Use the register script: `node -r typescript-transform-paths/register src/index.ts`\n\n## Virtual Directories\nTS allows defining\n[virtual directories](https://www.typescriptlang.org/docs/handbook/module-resolution.html#virtual-directories-with-rootdirs)\nvia the `rootDirs` compiler option.  \nTo enable virtual directory mapping, use the `useRootDirs` plugin option.\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```\n- src/\n    - subdir/\n      - sub-file.ts\n    - file1.ts\n- generated/\n    - file2.ts\n```\n\n`src/file1.ts`\n```ts\nimport '#root/file2.ts' // resolves to './file2'\n```\n`src/subdir/sub-file.ts`\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. The `exclude` option allows specifying glob\npatterns to match against resolved file path. \n\nFor an example context in which this would be useful, see [Issue #83](https://github.com/LeDDGroup/typescript-transform-paths/issues/83)\n\nExample:\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 tag\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 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 it has a different value in paths config\n```\n\n## Articles\n\n- [Node Consumable Modules With Typescript Paths](https://medium.com/@ole.ersoy/node-consumable-modules-with-typescript-paths-ed88a5f332fa?postPublishedType=initial) by [oleersoy](https://github.com/oleersoy)\n\n## Project Guidelines for Contributors\n\n- Package Manager: `yarn` (`yarn install`)\n- Commit messages: [Conventional Commit Specs](https://www.conventionalcommits.org/en/v1.0.0/)\n- Format before commit: `prettier` (`yarn run format`)\n- Releases: `standard-version` (`yarn run release`)\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 Alvarez</b></sub></a></td>\n  </tr>\n</table>\n","readmeFilename":"README.md","gitHead":"47e563ed7487477128ec3b81cc8faace9e77960e","_id":"typescript-transform-paths@3.4.0-alpha","_nodeVersion":"16.3.0","_npmVersion":"7.19.1","dist":{"integrity":"sha512-vhe6kcnlRmPul/zbKMITWs0PxQYgTwfdj/dVAzhJMGLPCOm7TSQbSWsWv9+pnxg7imv+mlacTcdORpZIOJrAVQ==","shasum":"1ee17a459db490eb95d56a179bf8123420669028","tarball":"http://registry-npm.ywwl.com/typescript-transform-paths/download/typescript-transform-paths-3.4.0-alpha.tgz","fileCount":32,"unpackedSize":79764,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzKRHtpXumINjBrzFiwtCLxxJqUdnA9AvqcxQgQ8tvEwIhAOlKzM/8REcbRyTjHJBReEpXgqwcLDV1SFs6oLECtxvJ"}],"size":19632,"noattachment":false,"key":"/typescript-transform-paths/-/typescript-transform-paths-3.4.0-alpha.tgz"},"_npmUser":{"name":"nonara","email":"ron@crosstype.org"},"directories":{},"maintainers":[{"name":"danielpanpm","email":"danielpza@protonmail.com"},{"name":"nonara","email":"ron@crosstype.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typescript-transform-paths_3.4.0-alpha_1632007655623_0.2571231102476561"},"_hasShrinkwrap":false,"publish_time":1632007655777,"_cnpm_publish_time":1632007655777,"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"}}