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

transformIgnorePatterns whitelist #8981

Closed
icywolfy opened this issue Sep 25, 2019 · 2 comments
Closed

transformIgnorePatterns whitelist #8981

icywolfy opened this issue Sep 25, 2019 · 2 comments

Comments

@icywolfy
Copy link

🚀 Feature Proposal

Allow a means to white list transformIgnorePatterns.

Motivation

Currently, we need to transform modules in node_modules, for code that is published as raw ES6, code published as raw TypeScript, or code published as raw React.

Even though transformIgnorePatterns is an array, the moment, we want to whitelist these projects, they must all be specified on one line, as ignoring /node_modules/ will always capture if entered solo; multiple white-lists cannot work as they are non-overlapping ignores, and will incorrectly capture.

transformIgnorePatterns: [
  '/node_modules/(?!(@namespace1/project1|@namespace2/project2/@namespace1/project2|unnamespace-project-1|unnnamepspace-project-2|...))/
]

it's getting to the point of that regex becoming very unwieldly, unintuititive, as needs to whitelist approximately 45 modules. I don't see this becoming easier over time as more and more projects publish uncompiled code.

It would be nice to clean this up and whitelist specific modules more intuitively.

transformIgnorePatterns: [
  '/node_modules/', // ignore by default
  '!/node_modules/@namespace1/project1', // whitelist, with ! magic prefix
  '!/node_modules/@namespace1/project2',  
  '!/node_modules/@namespace2/project2,
  '!/node_modules/unnnamespace-project-1'
]

or even

transformIgnorePatterns: [
  '/node_modules/', // ignore by default
],
// New config:  whitelistPatterns runs first; if match, ok.  ignorePatterns run second, if match not-ok.
transformWhitelistPatterns: [ 
  '/node_modules/@namespace1/project1/',
  '/node_modules/@namespace1/project2/',  
  '/node_modules/@namespace2/project2/,
  '/node_modules/unnnamespace-project-1/'
]

Pitch

Lots of confusion over how to make Jest work with other tooling.
When the correct solution advertised on stackExchange is "migrate to mocha" (which we did for a few projects, and indeed -- it just worked) it implies that a core functionality is lacking.

Specific Use Case:
Jest - Babel - Lerna monorepo - Typescript - React Native.

I wish to avoid migrating all our repositories back to mocha.
Conversion to mocha/chai is a workable solution; but it would be nice to use jest, and have one testing throughout our ecosystem.

@thymikee
Copy link
Collaborator

We're planning configuration revamp and this seems in line with it. See: #7185. Feel free to suggest more adjustments. I'm gonna close this, hope you don't mind :)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants