-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
New JSX transform doesn't work when using react v17+ #6389
Comments
Do you know if this is safe to turn on by default? Will it break existing projects using the legacy JSX transform? |
The docs of the babel plugins [1] [2] say that the But the babel setup instructions on the announcement page mention something about implementing It looks like both create-react-app and next.js are using a As an easier quick-fix alternative, maybe a note in the parcel v2 docs could be added, mentioning "For new jsx transform in react 17+, add this extra config". Like how Snowpack does for Fast Refresh. Edit: This issue mentions that Babel does not detect the react version so I'm assuming having "automatic" as default runtime might break compatibility with older react versions. |
Ah I see. We could detect the react version and do this automatically I guess. |
I'm having the same issue. |
Are you using the latest nightly release of Parcel? If so it should be automatic. |
Hi @devongovett :) This is also not working when using WordPress/Gutenberg (the new WP editor) loads This is how I aliased them (which shouldn't be a problem):
The error I got when using un-optimized build is: I may create a separate issue for this. But yea, JSX transform doesn't work when using global aliases. |
Does that environment support the new automatic jsx runtime? https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html Disabling that in a jsconfig or tsconfig config might work (so that the traditional |
🐛 bug report
react v17+ removes the need for
import React from "react";
statements but looks like the zero-config of Parcel doesn't work with it.🎛 Configuration (.babelrc, package.json, cli command)
.babelrc: none
CLI command:
"parcel serve ./app/index.html --port 3000"
🤔 Expected Behavior
Below code should work fine when using react v17+
😯 Current Behavior
Nothing is rendered on the screen.
Browser console error says "React is not defined"
💁 Possible Solution
This config works:
https://stackoverflow.com/a/67759434/7435656
🔦 Context
Migrating existing codebase from create-react-app to parcel. Followed the Generic Webapp guide from the docs but it doesn't look like those steps work for projects using the new JSX transform.
💻 Code Sample
Adding
import React from "react";
makes the application work but that shouldn't be required when using react v17+🌍 Your Environment
The text was updated successfully, but these errors were encountered: