-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-haste-map: deprecate functional ignorePattern and use it in cache key #4063
Conversation
df95e56
to
11c7b18
Compare
Please run prettier before merging. |
Codecov Report
@@ Coverage Diff @@
## master #4063 +/- ##
==========================================
- Coverage 60.42% 60.41% -0.01%
==========================================
Files 196 196
Lines 6764 6766 +2
Branches 6 6
==========================================
+ Hits 4087 4088 +1
- Misses 2674 2675 +1
Partials 3 3
Continue to review full report at Codecov.
|
You can call |
|
Non-pure functions suck :( |
Well afaik. it is not related to function purity in that case, because the |
(this is getting academic 😄). A pure function is one which returns the same output for the same input. Having some global state (such as using But I agree that just not supporting functions are way easier! |
…e key (jestjs#4063) I plan to revert `ignorePattern` to only being a strict `RegExp`, after removing the function use case from React Native and Metro bundler. The reason for getting rid of the function use case is that `ignorePattern` should be part of the cache key, and a function is not analysable at runtime. If it can only be a `RegExp`, then we can use `ignorePattern.toString()` as part of the cache key. The reason it needs to be part of the cache key is because the cache needs to be discarded—or at least reevaluated—when the ignore pattern changes. Otherwise, we can be missing some new modules that should be included, or the reverse, we can be including modules that should now be ignored. I have observed considerable trouble caused by this issue. For example, in React Native, people would reload a project and it wouldn't find a module, or, duplicates modules would be detected while in fact one of them should have been ignored. This changeset add a deprecation notice for the functional use case (so that we can release this as a minor/revision), and starts using the string representation of the ignore pattern in the cache key (so that we can get a correct behavior as soon as possible for callsites that do already use a `RegExp`). See also jestjs#2957, that introduced `ignorePattern` as a function. Alternatively, we could require callsites to provide their own cache key if they do want to use a function, but this makes it more complicated and I'm not sure there's really any other callsites than React Native that does that, that we will fix ourselves as well.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I plan to revert
ignorePattern
to only being a strictRegExp
, after removing the function use case from React Native and Metro bundler. The reason for getting rid of the function use case is thatignorePattern
should be part of the cache key, and a function is not analysable at runtime. If it can only be aRegExp
, then we can useignorePattern.toString()
as part of the cache key.The reason it needs to be part of the cache key is because the cache needs to be discarded—or at least reevaluated—when the ignore pattern changes. Otherwise, we can be missing some new modules that should be included, or the reverse, we can be including modules that should now be ignored. I have observed considerable trouble caused by this issue. For example, in React Native, people would reload a project and it wouldn't find a module, or, duplicates modules would be detected while in fact one of them should have been ignored.
This changeset add a deprecation notice for the functional use case (so that we can release this as a minor/revision), and starts using the string representation of the ignore pattern in the cache key (so that we can get a correct behavior as soon as possible for callsites that do already use a
RegExp
).See also #2957, that introduced
ignorePattern
as a function.Alternatively, we could require callsites to provide their own cache key if they do want to use a function, but this makes it more complicated and I'm not sure there's really any other callsites than React Native that does that, that we will fix ourselves as well.