-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
@babel/plugin-transform-react-jsx: automatic runtime import is added at the start #12522
Comments
Hey @eps1lon! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite." |
Maybe just injecting it at the end of the file would be enough? |
That's what I thought as well though it would probably a bit harder to find the right injections point in a non-ESM world. Thanks for the quick response! |
In a non-ESM world, we can keep the current behavior. The workaround is really easy: import the polyfills in new entrypoint that only loads
|
Sure, but you're just adding entrypoints upon entrypoints for a really obscure bug. The input code is directly take from the CRA docs: https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill#react-app-polyfill |
All those examples use ES modules, the only problem is when using JSX inside CommonJS files. EDIT: Ok, I was really bad at explaining myself 😅 |
In the REPL code it is missing one important line import React from "react"; without it Hello world will not render. |
The REPL code is only valid if you use |
@eps1lon ohh I got it. Thanks for explaination |
Bug Report
Current behavior
Input Code
Expected behavior
The runtime is not evaluated before the polyfills are applied.
The polyfills contain a polyfill for symbols. However, React uses numbers as fallbacks for its "symbols". Since
react
and its renderer packages don't share the same symbols but rely onSymbol.for
the symbols in the created react elements will use numbers while the renderer expects SymbolsBabel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
See repl
Environment
Possible Solution
Add the import after all the existing imports.
Additional context
Originally reported in facebook/react#20481 (comment)
The text was updated successfully, but these errors were encountered: