fix(vite): add support for Vite 8#34850
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
|
Hi team! The Vercel deployment check is showing as failed, but this PR only touches files in Also, the Netlify deploy previews are pending review (expected for fork PRs). Thanks! |
|
View your CI Pipeline Execution ↗ for commit 51041b9
☁️ Nx Cloud last updated this comment at |
bcf6844 to
6abd70f
Compare
6abd70f to
0478f45
Compare
|
Hi @rsidzinkaloopme , thanks for the PR. I'll check on the CI blocker. |
d343386 to
9e42add
Compare
|
Hi @jaysoo I was trying to add support for Vite 8, but I think it requires more effort than I initially though, because Vite 8 started using rolldown, currently I don't have time to work on this issue, hope someone can pick this up. |
|
@rsidzinkaloopme I'll update this PR so we can release it in a patch release. It'll handle the peer dep changes, and any potential fork in logic we need for Vite 8 and prior versions. In a follow-up PR we will do the migrate/package update, AI migrations, etc. needed to bring everyone to Vite 8. |
6c39dd3 to
98faec5
Compare
a6b103d to
4bea10b
Compare
4bea10b to
5f03973
Compare
5f03973 to
742f28f
Compare
20dc607 to
90e914e
Compare
f948969 to
2090b20
Compare
88fbde9 to
718e0db
Compare
718e0db to
f611dde
Compare
The `@nx/vite` plugin only supports Vite 5, 6, and 7. Add Vite 8 support: - Update peer deps to include ^8.0.0 - Bump @vitejs/plugin-react to ^6.0.0 (Vite 8 compat) - Handle rolldownOptions alongside rollupOptions (Vite 8 renamed rollup to rolldown) - Fix build executor environments API to preserve env-specific config - Add useViteV7 flag for backward compatibility - Fix type imports for Vite 8's ESM-only .d.mts declarations - Add e2e tests for both Vite 7 and Vite 8 React apps - Update docs to list ^8.0.0 as supported Fixes nrwl#34849
f611dde to
51041b9
Compare
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
Since the failure was identified as flaky, the solution is to rerun CI. Because this branch comes from a fork, it is not possible for us to push directly, but you can rerun by pushing an empty commit:
git commit --allow-empty -m "chore: trigger rerun"
git push
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
The `@nx/vite` plugin only supports Vite 5, 6, and 7. Users on Vite 8
get peer dependency errors:
```
peer vite@"^5.0.0 || ^6.0.0 || ^7.0.0" from @nx/vite
```
Full Vite 8 support for new and existing workspaces:
**Nx plugin support:**
- Update peer deps to include `^8.0.0` in `@nx/vite` and `@nx/vitest`
- Default new workspaces to Vite 8 (`viteVersion = '^8.0.0'`)
- Bump `@vitejs/plugin-react` to `^6.0.0` (required for Vite 8, uses Oxc
instead of Babel)
- Add `useViteV7` backward compatibility flag (follows existing
`useViteV5`/`useViteV6` pattern)
**Rolldown migration (Vite 8 replaced Rollup with Rolldown):**
- Handle both `rollupOptions` (Vite <8) and `rolldownOptions` (Vite >=8)
in build executor and plugin detection
- Fix build executor environments API to preserve env-specific
`rolldownOptions` config
- Update e2e tests for Rolldown's different module counts
**Type fixes for Vite 8's ESM-only declarations:**
- Vite 8 ships `.d.mts` type declarations not resolvable under
`moduleResolution: "node"`
- Fix `typeof import('vite')` and `import type` usages across
`@nx/vite`, `@nx/vitest`, `@nx/cypress`, `@nx/react`, `@nx/angular`,
`@nx/remix` with inline casts
- All fixes have `TODO(jack)` comments to remove when switching to
`moduleResolution: "nodenext"`
**Plugin compatibility:**
- `@vitejs/plugin-react@^6.0.0` only supports Vite 8; `^4.2.0` for Vite
<=7
- `ensure-dependencies` detects installed vite version and picks the
correct plugin-react version
- Cypress CT does not support Vite 8 yet — e2e test downgrades to Vite 7
**Angular vitest fix:**
- `@angular/build` depends on `rolldown` which injects
`@oxc-project/runtime` helpers at transform time without declaring it as
a dependency
- Add `@oxc-project/runtime` as an explicit devDependency in the Angular
vitest generator
**Docs:**
- Updated supported versions table to include `^8.0.0`
- Added `rolldownOptions.input` to buildable project detection docs
**E2E coverage:**
- New Vite 8 + React build/test e2e test
- New Vite 7 + React backward compat e2e test (downgrades vite +
plugin-react)
- Updated environments API test for Vite 8 `rolldownOptions`
- Updated incremental build test for Rolldown's module counts
- Cypress CT e2e downgrades to Vite 7 (Cypress doesn't support Vite 8
yet)
We'll do a follow-up PR to include migrations for 22.7.0. This PR's
scope is only to ensure peer deps and our generators work for workspaces
that are already using Vite 8.
Fixes #34849
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
(cherry picked from commit c699048)
|
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. |
Current Behavior
The
@nx/viteplugin only supports Vite 5, 6, and 7. Users on Vite 8 get peer dependency errors:Expected Behavior
Full Vite 8 support for new and existing workspaces:
Nx plugin support:
^8.0.0in@nx/viteand@nx/vitestviteVersion = '^8.0.0')@vitejs/plugin-reactto^6.0.0(required for Vite 8, uses Oxc instead of Babel)useViteV7backward compatibility flag (follows existinguseViteV5/useViteV6pattern)Rolldown migration (Vite 8 replaced Rollup with Rolldown):
rollupOptions(Vite <8) androlldownOptions(Vite >=8) in build executor and plugin detectionrolldownOptionsconfigType fixes for Vite 8's ESM-only declarations:
.d.mtstype declarations not resolvable undermoduleResolution: "node"typeof import('vite')andimport typeusages across@nx/vite,@nx/vitest,@nx/cypress,@nx/react,@nx/angular,@nx/remixwith inline castsTODO(jack)comments to remove when switching tomoduleResolution: "nodenext"Plugin compatibility:
@vitejs/plugin-react@^6.0.0only supports Vite 8;^4.2.0for Vite <=7ensure-dependenciesdetects installed vite version and picks the correct plugin-react versionAngular vitest fix:
@angular/builddepends onrolldownwhich injects@oxc-project/runtimehelpers at transform time without declaring it as a dependency@oxc-project/runtimeas an explicit devDependency in the Angular vitest generatorDocs:
^8.0.0rolldownOptions.inputto buildable project detection docsE2E coverage:
rolldownOptionsOther notes
We'll do a follow-up PR to include migrations for 22.7.0. This PR's scope is only to ensure peer deps and our generators work for workspaces that are already using Vite 8.
Related Issue(s)
Fixes #34849