{"id":13683572,"url":"https://github.com/dropbox/ts-transform-import-path-rewrite","last_synced_at":"2025-04-30T13:31:19.108Z","repository":{"id":33600917,"uuid":"159537896","full_name":"dropbox/ts-transform-import-path-rewrite","owner":"dropbox","description":"TS AST transformer to rewrite import path","archived":false,"fork":false,"pushed_at":"2023-08-07T14:33:25.000Z","size":144,"stargazers_count":128,"open_issues_count":12,"forks_count":15,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-18T15:12:52.272Z","etag":null,"topics":["ast","compiler","import","transform","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dropbox.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}},"created_at":"2018-11-28T17:12:40.000Z","updated_at":"2024-11-05T00:47:17.000Z","dependencies_parsed_at":"2024-01-14T15:26:20.552Z","dependency_job_id":"830aeddf-6c88-422e-92ae-4266db1d26be","html_url":"https://github.com/dropbox/ts-transform-import-path-rewrite","commit_stats":{"total_commits":58,"total_committers":7,"mean_commits":8.285714285714286,"dds":0.6206896551724138,"last_synced_commit":"4eb9fa95c3e9d8fdc7fd0b8b5ea41e28de12cb61"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-import-path-rewrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-import-path-rewrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-import-path-rewrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-import-path-rewrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dropbox","download_url":"https://codeload.github.com/dropbox/ts-transform-import-path-rewrite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372936,"owners_count":21419722,"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":["ast","compiler","import","transform","typescript"],"created_at":"2024-08-02T13:02:15.884Z","updated_at":"2025-04-30T13:31:18.694Z","avatar_url":"https://github.com/dropbox.png","language":"TypeScript","readme":"# ts-transform-import-path-rewrite\n\n![build status](https://travis-ci.org/dropbox/ts-transform-import-path-rewrite.svg?branch=master)\n\nThis is a TypeScript AST Transformer that allows you to rewrite import path in output JS \u0026 `d.ts` files accordingly. The primary use case for this is to mitigate different build system import structure, such as relative vs absolute `import` and aliasing output `import` paths.\n\n## Usage\n\n### ttypescript\nExample for ttypescript usage is in `examples/ttypescript`. Run `npx ttsc`.\n\n### Compiler Wrapper\nFirst of all, you need some level of familiarity with the [TypeScript Compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API).\n\n`compile.ts` \u0026 tests should have examples of how this works. The available options are:\n\n### `projectBaseDir: string`\nThis is the base directory of your project folder. This is primarily used to determine the correct path when rewriting relative `import` to `absolute` import.\n\n### `project?: string`\nProject name to rewrite relative `import` to. For example:\n```ts\nimport foo from './foo'\n// Becomes\nimport foo from 'my-project-name/foo'\n```\n \n### `rewrite?(importPath: string, sourceFilePath: string): string`\nCustom rewrite function to rewrite any `import` path we encounter to any new `import` path.\n\n### `alias?: Record\u003cstring, string\u003e`\nAlias regex map to replace, e.g:\n```json\n{\n    \"^(foo)$\": \"external/$1\"\n}\n```\n\n## License\n\nCopyright (c) 2018 Dropbox, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["TypeScript","Transformers"],"sub_categories":["General transformers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fts-transform-import-path-rewrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdropbox%2Fts-transform-import-path-rewrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fts-transform-import-path-rewrite/lists"}