Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat: extract 'createTransformer' and use type predicates #12407
feat: extract 'createTransformer' and use type predicates #12407
Changes from all commits
92ac49f
036349f
d9b03a4
1c7dd1e
c7acd5c
9236882
124fa09
7ccc3d7
b0a7b29
561d1a4
9d310aa
781c2fd
a79850a
940c43d
7ab0df5
3b04ea2
4df400a
42985ea
e5a5011
2cf267c
d62b127
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
why is this needed?
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.
Well, it was either that or
const babelJestTransformer = babelJest.createTransformer();
andbabelJestTransformer.getCacheKey(...)
(or something similar).Since we have no other exports than createTransformer, you would otherwise need to write
babelJest.createTransformer().getCacheKey(...)
in every location that usedbabelJest.getCacheKey(...)
previously.Not sure what you prefer. Since the transformer was not used for anything besides calling its
getCacheKey()
method, I thought removing it and just keeping the method through destructuring was fine.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.
why not
babelJest.getCacheKey
? It should be on the default export, no?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.
Since removing all but the factory method was part of this change.
I can of course revert it, but then those exports would just be for the sake of the tests (AFAIK?); the
jest-transform
package will not touch any of those exports when it seescreateTransformer
and neither will the CLI, so I thought keeping test-only exports did not make sense from that perspective. I might be wrong, of course 😄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.
Hope to have addressed all non-code related feedback. Mostly used your suggested prose, apart from introducing some full stops and minor adjustments to make the sentences shorter and easier to read.
With regards to the code changes you wondered about, which mostly stems from the fact that exports that are not used outside of tests have been removed, I am not sure if you think I should revert any of those or if it made sense.
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! What I'm alluding to here is that
babelJest.getCacheKey
should work fine, there's not need to callcreateTransformer
first (I think!)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.
And I am saying that functionality was removed in this PR 😄 Sorry if being unclear! See https://github.com/facebook/jest/pull/12407/files#diff-5f463bc5dbe428998302335614e9bbed3b4eb3310a6075767e1b432c161d9e71L273
It used to be:
Note the
...createTransformer()
. That is what ensures thatbabelJest.getCacheKey
exists.All of the fields from
...createTransformer()
would be ignored by Jest itself when it seescreateTransformer
. Since they are not used in any actual non-test code, I thought it did not make sense to expose them, since you could always just instantiate a new transformer in the tests. Once their use is gone from tests, no code would use them. So that's the reasoning behind removing them. I could keep them, of course, which would keep the tests unchanged, but what point is there in testing exports that will never be used?