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

Allow ast transformer to specify options #1942

Closed
longlho opened this issue Sep 12, 2020 · 1 comment · Fixed by #1966
Closed

Allow ast transformer to specify options #1942

longlho opened this issue Sep 12, 2020 · 1 comment · Fixed by #1966
Labels
🚀 Feature Request new suggested feature

Comments

@longlho
Copy link
Contributor

longlho commented Sep 12, 2020

🚀 Feature Proposal

Right now ast transformers only take in a path to the transformer factory but not further options. Our transformer has a lot of options but we have no idea how to pass those in other than creating a wrapper

Motivation

Example

// jest.config.js
module.exports = {
  // [...]
  globals: {
    'ts-jest': {
      astTransformers: {
        before: [{
			path: '@formatjs/ts-transformer',
			options: {}
		}],
      },
    }
  }
};
@longlho longlho added the 🚀 Feature Request new suggested feature label Sep 12, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 12, 2020

At the moment, ts-jest only cares about the factory function which is passed in by users, see https://github.com/kulshekhar/ts-jest/blob/master/src/config/config-set.ts#L440 . When user defines the transformer path, ts-jest simply performs require on the path and then call factory. It doesn’t know anything about the context inside factory.

I think it is not possible now to have a feature like you request. Do you see other ways to apply your feature request by looking at the current codes ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature Request new suggested feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants