Skip to content
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 css props when using babel macro with babel-plugin-styled-components 1.10.1 #2633

Merged
merged 4 commits into from Jun 20, 2019

Conversation

jamesknelson
Copy link
Contributor

Currently, if you follow the guide to using styled-components with Create React App, css props will not work. This is due to a change introduced in babel-plugin-styled-components 1.10.1.

This fix resolves the issue by switching the macro to use @babel/traverse(path) instead of path.traverse(). For some reason, this makes the Program visitor work, whereas it doesn't with path.traverse().

See styled-components/babel-plugin-styled-components#226 for details

@quantizor
Copy link
Contributor

@jamesknelson can you add a test please?

@jamesknelson
Copy link
Contributor Author

I can't get the tests running on my machine, so can't do so at the moment. I get this when trying to run yarn test:web or jest

 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import styled from '../styled';
SyntaxError: Unexpected identifier "import"

Looks like the tests are not compiling modules to commonjs for some reason. Any ideas?

@quantizor
Copy link
Contributor

@jamesknelson hmm weird, a yarn from the root always works for me

@quantizor quantizor added the 4.0 label Jun 20, 2019
@jamesknelson
Copy link
Contributor Author

I'm not sure what's going on - I've run yarn in the root, tried a bunch of things with a fresh clone, and can't get tests to work locally no matter what I try.

On the other hand, there is a macro test already, and it passes on CI.

@quantizor
Copy link
Contributor

quantizor commented Jun 20, 2019 via email

quantizor
quantizor previously approved these changes Jun 20, 2019
Copy link
Contributor

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for figuring this out! What a weird set of behaviors...

@quantizor quantizor merged commit d088d68 into styled-components:master Jun 20, 2019
@quantizor
Copy link
Contributor

Released as 4.3.2, thanks so much for tackling this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants