{"id":14341850,"url":"https://github.com/justkey007/tsc-alias","last_synced_at":"2025-05-13T18:12:10.262Z","repository":{"id":37470774,"uuid":"185137297","full_name":"justkey007/tsc-alias","owner":"justkey007","description":"Replace alias paths with relative paths after typescript compilation","archived":false,"fork":false,"pushed_at":"2025-05-05T09:32:00.000Z","size":532,"stargazers_count":991,"open_issues_count":26,"forks_count":72,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T12:04:54.515Z","etag":null,"topics":["absolute-path","alias","compilation","paths","relative-path","tsc","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justkey007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.paypal.com/donate/?hosted_button_id=FPRE4VERGHZ3E","https://www.buymeacoffee.com/justkey007"]}},"created_at":"2019-05-06T06:33:14.000Z","updated_at":"2025-05-12T08:54:53.000Z","dependencies_parsed_at":"2024-05-09T16:28:48.777Z","dependency_job_id":"4e97e25c-193e-4aa1-bed0-d0e3cbfae2e9","html_url":"https://github.com/justkey007/tsc-alias","commit_stats":{"total_commits":189,"total_committers":25,"mean_commits":7.56,"dds":0.6666666666666667,"last_synced_commit":"fe88bf697f59496c4b44f4b9003ec0cbd21ee4c6"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkey007%2Ftsc-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkey007%2Ftsc-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkey007%2Ftsc-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkey007%2Ftsc-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justkey007","download_url":"https://codeload.github.com/justkey007/tsc-alias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253943551,"owners_count":21988288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["absolute-path","alias","compilation","paths","relative-path","tsc","typescript"],"created_at":"2024-08-26T14:01:49.139Z","updated_at":"2025-05-13T18:12:10.223Z","avatar_url":"https://github.com/justkey007.png","language":"TypeScript","readme":"# tsc-alias\n\nReplace alias paths with relative paths after typescript compilation. You can add aliases that reference other projects outside your tsconfig.json project by providing a relative path to the baseUrl.\n\n[![npm version](https://badge.fury.io/js/tsc-alias.svg)](https://badge.fury.io/js/tsc-alias)\n[![License](https://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=FPRE4VERGHZ3E)\n\n## Comparison to [tsconfig-paths](https://github.com/dividab/tsconfig-paths)\n\n\\+ Compile time (no runtime dependencies)\n\n## Getting Started\n\nFirst, install tsc-alias as devDependency using npm.\n\n```sh\nnpm install -g tsc-alias\n```\n\n```\nnpm install --save-dev tsc-alias\n```\n\n## Add it to your build scripts in package.json\n\n```json\n\"scripts\": {\n  \"build\": \"tsc --project tsconfig.json \u0026\u0026 tsc-alias -p tsconfig.json\",\n}\n```\n\nor\n\n```json\n\"scripts\": {\n  \"build\": \"tsc \u0026\u0026 tsc-alias\",\n  \"build:watch\": \"tsc \u0026\u0026 (concurrently \\\"tsc -w\\\" \\\"tsc-alias -w\\\")\"\n}\n```\n\n## Issues\n\nIf you have an issue, please create one. But, before:\n\n- try to check the [FAQ.](https://github.com/justkey007/tsc-alias/discussions/110)\n- try to check if there exits alike issues.\n- try to run with `--debug` and check if config is correctly loaded and all sourcefiles are found.\n\n## API\n\n### Installation\n\n```sh\nnpm install tsc-alias\n```\n\n### Usage\n\n```typescript\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nreplaceTscAliasPaths(options?);\n```\n\nHere are all the available options:\n\n\u003ctable\u003e\n  \u003cthead\u003e\n  \u003ctr\u003e\n    \u003cth\u003eOption\u003c/th\u003e\n    \u003cth\u003eDescription\u003c/th\u003e\n    \u003cth\u003eDefault Value\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eproject, p\u003c/td\u003e\n      \u003ctd\u003epath to tsconfig.json\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e'tsconfig.json'\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003ewatch\u003c/td\u003e\n      \u003ctd\u003eObserve file changes\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoutDir\u003c/td\u003e\n      \u003ctd\u003eRun in a folder leaving the \"outDir\" of the tsconfig.json (relative path to tsconfig)\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003etsconfig.compilerOptions.outDir\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003edeclarationDir\u003c/td\u003e\n      \u003ctd\u003eWorks the same as outDir but for declarationDir\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003etsconfig.compilerOptions.declarationDir\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eresolveFullPaths\u003c/td\u003e\n      \u003ctd\u003eAttempt to replace incomplete import paths (those not ending in \u003ccode\u003e.js\u003c/code\u003e) with fully resolved paths (for ECMAScript Modules compatibility)\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eresolveFullExtension\u003c/td\u003e\n      \u003ctd\u003eAllows you to specify the extension of incomplete import paths, works with \u003ccode\u003eresolveFullPaths\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e'.js' | '.mjs' | '.cjs'\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003esilent\u003c/td\u003e\n      \u003ctd\u003eReduced terminal output. This is a deprecated option and no longer has any effect.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003etrue\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003everbose\u003c/td\u003e\n      \u003ctd\u003eAdditional information is output to the terminal\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003edebug\u003c/td\u003e\n      \u003ctd\u003eDebug information is send to the terminal\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003ereplacers\u003c/td\u003e\n      \u003ctd\u003eFiles to import as extra replacers \u003ca href=\"https://github.com/justkey007/tsc-alias/discussions/73\"\u003eMore info\u003c/a\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e[]\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoutput\u003c/td\u003e\n      \u003ctd\u003eThe output object tsc-alias will send logs to.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003enew Output(options.verbose)\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003efileExtensions\u003c/td\u003e\n      \u003ctd\u003eOverwrite file extensions tsc-alias will use to scan and resolve files.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eundefined\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n### Configuration via `tsconfig.json` Example\n\n```json\n{\n  \"compilerOptions\": {\n    ...\n  },\n  \"tsc-alias\": {\n    \"verbose\": false,\n    \"resolveFullPaths\": true,\n    \"replacers\": {\n      \"exampleReplacer\": {\n        \"enabled\": true,\n        \"file\": \"./exampleReplacer.js\"\n      },\n      \"otherReplacer\": {\n        \"enabled\": true,\n        \"file\": \"./otherReplacer.js\"\n      }\n    },\n    \"fileExtensions\": {\n      \"inputGlob\": \"{js,jsx,mjs}\",\n      \"outputCheck\": [\"js\", \"json\", \"jsx\", \"mjs\"]\n    }\n  }\n}\n```\n\n### Single file replacer\n\nWe can use tsc-alias in a single file, with a function that returns the modified contents.\n\nWe prepare the replacer with `prepareSingleFileReplaceTscAliasPaths()`, passing the same options that we would pass to `replaceTscAliasPaths()`. That will return a promise of a function that receives the file contents and path, and returns the transformed contents, synchronously.\n\n```typescript\nimport { prepareSingleFileReplaceTscAliasPaths } from 'tsc-alias';\n\nconst runFile: SingleFileReplacer = await prepareSingleFileReplaceTscAliasPaths(options?);\n\nfunction treatFile(filePath: string) {\n  const fileContents = fs.readFileSync(filePath, 'utf8');\n  const newContents = runFile({fileContents, filePath});\n  // do stuff with newContents\n}\n```\n","funding_links":["https://www.paypal.com/donate/?hosted_button_id=FPRE4VERGHZ3E","https://www.buymeacoffee.com/justkey007"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustkey007%2Ftsc-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustkey007%2Ftsc-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustkey007%2Ftsc-alias/lists"}