$ show LeDDGroup/typescript-transform-paths
typescript-transform-paths is a TypeScript transformer plugin that resolves module specifiers using tsconfig path mappings and custom transformation rules. It operates during TypeScript compilation to rewrite import/export paths in emitted JavaScript and declaration files, supporting features like virtual directories (rootDirs), exclusion patterns, and type-only import elision. The architecture centers around a visitor pattern that traverses the AST, resolving module names via TypeScript's resolver and adjusting paths based on compiler options. Key entry points include the main transformer (src/transformer.ts) and an Nx adapter (src/plugins/nx.ts). The tool integrates with ts-patch, ts-node, or build systems to enable path transformation without requiring changes to source code.
The LLM identified 2 files worth highlighting for reuse:
Encapsulates core logic for resolving module specifiers to output paths, handling TypeScript's path mapping, virtual directories (rootDirs), file extensions, index files, and package subpaths. Isolated from visitor logic and reusable in other tools needing similar path resolution (e.g., bundlers, linters) with minimal adaptation.
Provides robust relative path calculation that handles case-insensitive file systems by preserving the casing of the 'target' path. Includes a helper to find matching path portions for case preservation. This solves a non-obvious cross-platform issue and could be extracted for reuse in any file path manipulation utility.