Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Add the ability to specify paths to custom transformers in tsconfig.json #14654

Closed
dsherret opened this issue Mar 14, 2017 · 1 comment
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@dsherret
Copy link
Contributor

dsherret commented Mar 14, 2017

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).

@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2017

As noted in #14419 (comment), we have no plans to do this in the time being.

@mhegazy mhegazy closed this as completed Apr 27, 2017
@mhegazy mhegazy added Suggestion An idea for TypeScript Declined The issue was declined as something which matches the TypeScript vision labels Apr 27, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants