-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Emotion Babel Macro duplicating nodes #726
Comments
I think we just need to clone the returned node here -
t.clone /t.cloneNode - to keep babel@6 and babel@7 compatibility.
Gonna try to find time to prepare PR for this 2morrow. |
emmatown
pushed a commit
that referenced
this issue
Jun 18, 2018
**Checklist**: <!-- add "N/A" to the end of each line that's irrelevant to your changes --> <!-- to check an item, place an "x" in the box like so: "- [x] Documentation" --> - [ ] Documentation - [x] Tests - [x] Code complete fixes #726
Thanks for the fix @Andarist & also for adding the tests. When do you think the next patch might land on the registry? cheers! |
Just did a release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
emotion
version: 9.2.3react
version: N/ARelevant code.
What you did:
Used emotion/macro and babel-plugin-macros to transform code, together with plugin-transform-modules-commonjs
What happened:
The second reference to
_css
was not replaced with a live reference, causing the output to generate invalid javascript ("_css is not defined" error)Reproduction:
See above code
Problem description:
Unlike the first reference to the macro import ("css"), the second reference is not replaced with a live reference by the commonjs module transform plugin. This is because when the
emotion/macro
runs, it is inserting duplicate nodes in the tree - and the module transform plugin is configured to skip nodes it has already visited.Suggested solution:
Create a new node whenever inserting nodes into the AST, and as an extra verification step, use the
checkDuplicateNodes
helper:https://github.com/babel/babel/blob/d383659ca6adec54b6054f77cdaa16da88e8a171/packages/babel-helper-transform-fixture-test-runner/src/index.js#L128
The text was updated successfully, but these errors were encountered: