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

Css prop no more working with Babel macro #370

Open
philippklodt opened this issue Jan 8, 2022 · 1 comment
Open

Css prop no more working with Babel macro #370

philippklodt opened this issue Jan 8, 2022 · 1 comment

Comments

@philippklodt
Copy link

philippklodt commented Jan 8, 2022

From babel-plugin-styled-components@.>=2.0.0 onwards,
using the css prop with babel macros as described in the docs is no more working:
https://styled-components.com/docs/api#usage-with-the-babel-macro

The webpack build fails with

ReferenceError
styled is not defined

I was able to isolate it in a minimal setup with create-react-app and styled-components.
https://codesandbox.io/s/styled-components-babel-macro-cssprop-issue-sbenl

I also tested it with various versions of react-scripts and styled-components, but it didn't seem to make a difference.
When setting the version of babel-plugin-styled-components back to 1.13.3 in the package.json, it works as expected.

@quantizor
Copy link
Collaborator

It seems like the dynamic component created by the css prop is putting the component declaration too soon in the file...

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

No branches or pull requests

2 participants