-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(react): generate valid Vite + JSX setup for React #27130
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 7113329. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targets
Sent with 💌 from NxCloud. |
The current `@nx/react:app` generator does not take the `--js` option into account. There are two problems: 1. `index.html` includes `main.tsx` not `main.jsx`. 2. `.js` files with JSX are invalid in Vite, and must be named `.jsx`. This PR adds a new option to the `toJS` devkit util to preserve `.jsx` rather than renaming them to `.js`. The vast majority of non-Vite React projects will use `.js` and not `.jsx` (e.g. Next.js, Expo, Remix, etc.) so we just want to apply this change to Vite only for now. In the future we could enhance React generators to support `--jsx`, for example. ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #20810 (cherry picked from commit 45c458e)
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
The current
@nx/react:app
generator does not take the--js
option into account. There are two problems:index.html
includesmain.tsx
notmain.jsx
..js
files with JSX are invalid in Vite, and must be named.jsx
.This PR adds a new option to the
toJS
devkit util to preserve.jsx
rather than renaming them to.js
. The vast majority of non-Vite React projects will use.js
and not.jsx
(e.g. Next.js, Expo, Remix, etc.) so we just want to apply this change to Vite only for now.In the future we could enhance React generators to support
--jsx
, for example.Current Behavior
Expected Behavior
Related Issue(s)
Fixes #20810