-
-
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
[Documentation]: Missing documentation for @jest/create-cache-key-function #12004
Comments
PR very much welcome! Example usage is here: https://github.com/facebook/react-native/blob/61e1b6f86cf98d8a74eeb9353143fe0c624fe6e6/jest/preprocessor.js#L186-L190 What is essentially does is hash the file to be transformed, pluss the content of the file(s) passed to easily invalidate if any of the files changes.
It should return a string (usually a hash, but that doesn't really matter) that changes if the file to transform would transform into a different result. E.g. different options or (more likely) changed content of the file. Might also include version of whatever tool you use to transform (like Original PR might help: #10587 |
What's the benefit of |
It's to handle if files outside of your tests (such as babel config or version) change (which are "global", instead of related directly to the file under transformation).
I linked to react native which uses it in the comment above yours |
…e of the jest-create-cache-key-function package (jestjs#12004)
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. |
🚀 Feature Proposal
The
@jest/create-cache-key-function
package has no documentation. Even though the https://jestjs.io/docs/next/code-transformation page says that transformer authors should use it to create cache keys, there's no information on how the function should be actually used. The source code doesn't contain any documentation comments neither. It would be great to have some examples.Motivation
It's currently unclear how to use the
@jest/create-cache-key-function
package. It's also unclear what thegetCacheKey()
function on a transformer should return.Personally, I just ended up using this code:
which is surely an awful idea.
Example
No response
Pitch
The official Jest documentation (https://jestjs.io/docs/next/code-transformation) recommends using
@jest/create-cache-key-function
, but there's no information at all on HOW to use it.The text was updated successfully, but these errors were encountered: