-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(vite): support JSX in .jsx files without React import #7888
Conversation
🦋 Changeset detectedLatest commit: 7aae9b1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hi @hi-ogawa, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
Thanks for the PR! Digging into this myself, it looks like JSX was already supported in To match the Remix compiler, I've also updated your PR to set the |
esbuild.jsx = "automatic"
vite option to support non-ts jsx file on ssr
Thanks for the review!
Right, I couldn't verify this exactly, but my guess is that esbuild is choosing |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Closes: #7885
It seems explicitly setting vite's esbuild option is necessarily to make jsx transpilation work for
.jsx
file.This change also aligns with what vite-plugin-react does here
(The rest of the comment is some extra note from my investigation. It might not be accurate...)
My guess was that JSX transpilation for server module (i.e. transform done via
ssrLoadModule
) is done by vite's esbuild, which reads localtsconfig.json
to configure certain transform options.These are relevant docs:
But, for some reason, this might not the case for
.jsx
file transpilation.I also tested with updating
tsconfig.json
to include**/*.jsx
but this doesn't seem to have any effect.reveal tsconfig.json
Testing Strategy: