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

"Error: Webpack Compilation Error" with "pragma and pragmaFrag cannot be set when runtime is automatic" when changing Babel configuration with Next.js #14471

Closed
Vadorequest opened this issue Jan 10, 2021 · 2 comments

Comments

@Vadorequest
Copy link

Vadorequest commented Jan 10, 2021

Cross-posting as I don't know whether the bug is due to Cypress or Next.js Babel configuration.

See vercel/next.js#20952

TLDR; A comment in a Cypress file makes E2E Cypress tests fail due to a perfectly fine comment that is interpreted as a JSX pragma. Webpack fails to compile Cypress file since I configured Babel to use automatic runtime with Next.js, only affects Cypress, not Next.js

@Vadorequest Vadorequest changed the title Babel error - "Error: Webpack Compilation Error" with "pragma and pragmaFrag cannot be set when runtime is automatic" tue to false-positive comment "Error: Webpack Compilation Error" with "pragma and pragmaFrag cannot be set when runtime is automatic" when changing Babel configuration with Next.js Jan 11, 2021
@Vadorequest
Copy link
Author

The issue might be Cypress doesn't support automatic mode? Or require some additional configuration for it to work properly?

A similar issue happened with MDX a while ago, basically Emotion provides a way to use JSX "automatic" pragma through Babel config (and avoid writing /* @jsx jsx */ on top of every file using Emotion), but this wasn't properly supported by MDX and led to issues, as explained at mdx-js/mdx#990

I feel like something similar happens here, I changed the babel configuration to make it work with Emotion 11, but it broke Cypress in the process.

@Vadorequest
Copy link
Author

This was a Babel/Webpack/TS configuration issue introduced by changing the babel config required by Emotion 11. It has been explained and fixed at UnlyEd/next-right-now#247

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

1 participant