dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.
MIT License
1.8k stars 100 forks source link

transformers support #219

Open rifler opened 2 years ago

rifler commented 2 years ago

Hello!

As you probably know, TypeScript has Compiler API, which allows to create "transformers" - functions in which you get control over AST and change it as you wish. Unfortunately, to use this transformers you should completely duplicate the whole tsc command yourself. It is inconvenient. Feature request to implement support for transformers right into tsconfig.json - https://github.com/microsoft/TypeScript/issues/14419

Fortunately, there are some solutions, which patch tsc command and make it to respect transformers defined it tsconfig.json. So they are executed at build time. I guess the most popular tool is ttypescript.

Also, there are several packages quite similar to tsconfig-paths, which provides ttypescript support for build-time paths transformations, for instance: https://github.com/OniVe/ts-transform-paths https://github.com/zerkalica/zerollup/tree/master/packages/ts-transform-paths https://github.com/LeDDGroup/typescript-transform-paths

But they are not so popular, tested and maintained as tsconfig-paths.

I suppose it would be great to export ready transformer from tsconfig-paths. This would allow to dramatically cut off entropy and produce path's transformations during build time.