Closed
Description
Background
#13940 adds customTransformers
to Program.emit()
that "run custom transformations before and after the main transformation pipeline".
So the code to do this looks like the following:
const transformers: ts.CustomTransformers = {
before: [transformFactory, otherTransformFactory],
after: [someAfterTransformFactory]
};
const program = ts.createProgram(...);
program.emit(...etc...., transformers);
Problem
In order to apply a custom transformation, the compiler api must be used. It's takes a bit of work to set this up and most people won't do this for the sake of custom transformations.
It would be nice if there was an easy way to be able to apply custom transformations so that they could be easily shared with others.
Potential Solution
Add the ability so specify paths to custom transformers in tsconfig.json.
So for example:
{
"compilerOptions": {
"customTransformers": {
before: ["node_modules/sometransformfactorypackage"],
after: ["myTransformFactories/customTransformFactory"]
}
}
}
This would most likely use the default export from the package or file specified (requiring it to export a TransformerFactory<SourceFile>
object).