-
-
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
fix(hoist-plugin): hoist pure constants to support experimental JSX transform in mocks #10723
Conversation
d0d73fa
to
c07e8e8
Compare
); | ||
|
||
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime"; | ||
var _jsxFileName = ""; |
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.
one thing we could do is to wrap it in a function and replace usage - similar to what we do with _getJestObj
now. then we wouldn't have to move it
c07e8e8
to
3fba372
Compare
3fba372
to
3950686
Compare
@nicolo-ribaudo @jeysal I pushed a commit that replaces the reference with its constant value. It works for this case, but I'd love to add some more tests to ensure it doesn't break other cases. Ideas? And if this approach is dumb, I have zero attachment to it and would love to throw it out if you've got any great ideas 😀 |
41e050e
to
e751fbb
Compare
Through more trial & error than I'd like to admit I think I've gotten a function replacement working. I have no idea if that's a better approach or not. I've rebased and squashed some WIP commits so hopefully it'll be relatively simple for you to review the approaches. Commits are
Again, feedback appreciated on which of 3 or 4 (if either) is the best solution 🙂 |
0998a8b
to
045af2b
Compare
packages/babel-plugin-jest-hoist/src/__tests__/hoistPlugin.test.ts
Outdated
Show resolved
Hide resolved
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
Fixes #10690 (eventually, hopefully, possibly)
Test plan
Note that I don't want this test to actually land. It's a very brute force way of illustrating the bug, but a bad test to add to ensure we don't have regressions in the futurepushed a better test now