feat(jest-runtime): share cacheFS between runtime and transformer#10901
feat(jest-runtime): share cacheFS between runtime and transformer#10901SimenB merged 2 commits intojestjs:masterfrom ahnpnl:share-cachefs
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.
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.
this should update https://github.com/facebook/jest/blob/master/docs/CodeTransformation.md as well, other than that this LGTM 👍
| 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 |
|
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
|
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