Skip to content

Add trailing / to transformIgnorePatterns #146

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

Merged
merged 2 commits into from
Jul 8, 2019
Merged

Add trailing / to transformIgnorePatterns #146

merged 2 commits into from
Jul 8, 2019

Conversation

zackdotcomputer
Copy link
Contributor

Fix a small documentation issue with the transformIgnorePatterns suggested fix for performing proper transformations on the mocks for Jest compatibility. Need to add a trailing / to the regex for the transform ignore, otherwise it will match all packages in node-modules that start with the string react-native!

Fix a small bug with the `transformIgnorePatterns` suggested fix for performing proper transformations on the mocks for Jest compatibility. Need to add a trailing `/` to the regex for the transform ignore, otherwise it will match all packages in `node-modules` that start with the string `react-native`!
@krizzu
Copy link
Member

krizzu commented Jul 2, 2019

Hey @genuinezack , thanks for your contribution!

This looks legit to me, although, I'll ask for a second opinion :) cc @thymikee

@thymikee
Copy link

thymikee commented Jul 2, 2019

@genuinezack this behavior is expected, as the vast majority of react-native-* packages are not compiled to JSC-compatible code, but only expose sources. It's a shame, but this is the reality we live in currently. I don't think we should merge this.

@zackdotcomputer
Copy link
Contributor Author

zackdotcomputer commented Jul 2, 2019

I disagree that this is expected/desirable, @thymikee, for three reasons:

  1. The line before this snippet in the documentation says this line will transform "the whole scope of react-native-community and react-native". I understand (or misunderstand) that to mean those scopes specifically and not all scopes that happen to start with those strings.
  2. Casting a wide net like this is likely to have false positives and negatives, meaning developers will have to edit this line anyways. They'll have an easier time reasoning about which packages are included if this line matches specific packages not string prefixes.
  3. Finally, Jest's recommended pattern for this line does include a trailing slash for packages. Since it's their tool, I'd argue we should agree with them.

That being said, it is a single character in a legacy documentation so no worries if you leave it as-is, I'll still use the package and appreciate you for making and maintaining it.

@thymikee
Copy link

thymikee commented Jul 2, 2019

Casting a wide net like this is likely to have false positives and negatives, meaning developers will have to edit this line anyways.

Never happened to me in 2 years

They'll have an easier time reasoning about which packages are included if this line matches specific packages not string prefixes.

transformIgnorePatterns is one of the worst APIs Jest provides and believe me it causes constant confusion, especially for people starting with React Native.

Fun fact – Metro (the React Native bundler) transpiles all of your dependencies already with the same Babel preset.

I get your point though, it's completely correct. I'm just too tired answering the same questions (I'm a Jest maintainer btw). What would be a nice compromise I guess, is leaving this regex as you like, explain what it does, and how to make it more permissive. It's not quite the scope of this package, but maybe it helps someone :)

@zackdotcomputer
Copy link
Contributor Author

@thymikee - I'm only 9 months into the world of react-native, but we ran into this recently with cavy and @segment/analytics-react-native, both of which needed to be added to this and is why this particular regex is top of mind for me 😅 But, relatedly, 100% agree with your comment that it is a source of constant confusion!

I updated my change with your suggested clarification and will leave the compromise in your court to approve/deny.

(Oh also thanks for maintaining Jest too! I have no idea how y'all open source maintainers deal with hearing the same issues/suggestions/requests all day long, so sorry to add to the din.)

Copy link

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds about right, thanks!

@krizzu
Copy link
Member

krizzu commented Jul 3, 2019

Right, this should resolve any doubts.

Still fighting with CI, why failing randomly.

@krizzu
Copy link
Member

krizzu commented Jul 8, 2019

Can't figure out why Android e2e fails at deps installations, so, for now, I'll go ahead and just merge this.

@krizzu krizzu merged commit c476354 into react-native-async-storage:LEGACY Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants