-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
gatsby-plugin-mdx: jsxFrag should be set with latest version of @babel-plugin-transform-react-jsx #22500
Comments
Based on babel/babel#11321 (comment) it seems like up until babel/babel@748897b#diff-8c3c9c6362e23bd456da3fb129f49a57L10 mdx-js has been relying on React.Fragment being passed in from preset-react. Since that has now been removed, I think a fix would be to add
Anywhere where Let me know if that makes sense and I'd be happy to do a PR. |
Note: we are restoring the old behavior of not throwing when using the preset, but I recommend enabling the fragment option since we'll re-introduce the error in Babel 8. |
We released a fix in 7.9.4 🎉! |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
This issue is old, but I'm just now seeing these exact errors in our build. Specifically: EDIT: Just now realized the error message is slightly different. Sorry for the noise of this is a separate issue.
Curiously, I can fix this for us by setting a Yarn resolution for |
It's because you (or gatsby) is using the |
Description
I'm getting the following error when compiling mdx files that contain a React fragment,
<></>
on a Gatsby site.The issue is because MDX specifies
/* @jsx mdx */ as the pragma, but never specifies a pragmaFrag which is now a requirement with
babel-plugin-transform-react-jsx@7.9.x`See the note here:
https://babeljs.io/docs/en/next/babel-plugin-transform-react-jsx.html#customizing-with-the-classic-runtime
Steps to reproduce
Unfortunately the code is private so I can't provide it as an example, but let me know if you want me to recreate in a public repo.
Expected behaviour
gatsby-plugin-mdx should set a jsxFrag value when specifying a custom jsx pragma.
So for example, every time
/* @jsx mdx */
is set/* @jsxFrag ... */
should also be set.Alternatively, babel-plugin-transform-react-jsx should use the default React.Fragment if none is specified.
I'm going to open an issue to babel-plugin-transform-react-jsx for default behavior and to mdx-js to add the same as well.
Related issues:
Let me know if there's a fragment pragma that makes sense and I'd be happy to do a PR.
Actual behaviour
babel-plugin-transform-react-jsx throws an error.
The text was updated successfully, but these errors were encountered: