-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Load jsx-runtime
after existing imports
#12546
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
Load jsx-runtime
after existing imports
#12546
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/36813/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f59e3ce:
|
Thanks @babel-bot 😄 I don't have a windows pc to regenerate those fixtures and your help is welcome! (ref) |
53e2752
to
b981bc3
Compare
f9bef2e
to
c34234e
Compare
[skip ci] Co-authored-by: Brian Ng <bng412@gmail.com>
With the
classic
runtime, it's easy to import polyfills needed by React: you first import the polyfill, and then React itself. However, with theautomatic
runtime, thereact/jsx-runtime
import is always injected at the top and thus it's not possible to manually control the imports order.This PR changes it so that
react/jsx-runtime
imports always come last: imports are hoisted so it's not a problem if they are injected after the actual usage. However, it's a problem with commonjs sincerequire
calls are not hoisted and not always statically analyzable: when using CJS with theautomatic
runtime, you'll need to load the polyfills in an entry point that doesn't contain JSX code.This PR adds a new feature to
@babel/helper-module-imports
, so we might want to release this in a minor version.cc @babel/react