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

Projects
None yet
2 participants
@jamesknelson
Copy link
Contributor

commented Jun 20, 2019

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

@probablyup

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

@jamesknelson can you add a test please?

@jamesknelson

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2019

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?

@probablyup

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

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

@probablyup probablyup added the 4.0 label Jun 20, 2019

@jamesknelson

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2019

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.

@probablyup

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

probablyup added some commits Jun 20, 2019

@probablyup
Copy link
Contributor

left a comment

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

@probablyup probablyup merged commit d088d68 into styled-components:master Jun 20, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@probablyup

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

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
You can’t perform that action at this time.