-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(jest-runtime): share cacheFS between runtime and transformer #10901
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
Conversation
|
Node 14.x Windows, Node 12.x MacOS, Node LTS MacOS and facebook.jest failed but I have no idea what causes it. |
macOS is flaky: #10828 |
SimenB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should pass it in the constructor rather than in the individual transform calls?
|
Btw I could only modify test for |
I tried with constructor. However, when passing through constructor, |
|
What do you mean "updated"? |
For example, a simple project:
|
|
hmm it seems like possible to pass through the constructor. I think I made mistakes somewhere previously |
SimenB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should update https://github.com/facebook/jest/blob/master/docs/CodeTransformation.md as well, other than that this LGTM 👍
docs/CodeTransformation.md
Outdated
| interface Transformer<OptionType = unknown> { | ||
| /** | ||
| * Indicates if the transformer is capabale of instrumenting the code for code coverage. | ||
| * - `cacheFS`: if custom transformers do module resolution and read file, custom transformers should populate this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimenB please check :)
SimenB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
thymikee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
|
Hmm, I wonder if it makes more sense to pass as part of |
|
Passing to On the other hands, this |
|
Right, but |
|
Hmm indeed, seem like we need to pass it as transform options then, unless others have other ideas |
|
Passing into
|
Pass `cacheFS` from `jest-runtime` to `ScriptTransformer`. When `getCacheKey` or `process` is invoked, this `cacheFS` is passed in through transform options If a transformer does module resolution and reads files, it should populate `cacheFS` so that Jest avoids reading the same files again, improving performance. `cacheFS` stores entries of <file path, file contents> Closes #10898
SimenB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
|
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. |
Summary
Pass
cacheFSfromjest-runtimetoScriptTransformer. WhengetCacheKeyorprocessis invoked, thiscacheFSis passed in through transform optionsIf a transformer does module resolution and reads files, it should populate
cacheFSso that Jest avoids reading the same files again, improving performance.cacheFSstores entries of <file path, file contents>Close #10898
Test plan
Added unit test for
jest-transform