Skip to content

fix(vite): update vitest and plugin-react-swc versions for vite 8 compat#35062

Merged
jaysoo merged 1 commit into
masterfrom
NXC-4164
Mar 28, 2026
Merged

fix(vite): update vitest and plugin-react-swc versions for vite 8 compat#35062
jaysoo merged 1 commit into
masterfrom
NXC-4164

Conversation

@jaysoo

@jaysoo jaysoo commented Mar 28, 2026

Copy link
Copy Markdown
Member

Current Behavior

When creating a workspace with create-nx-workspace using presets that install vitest (react-monorepo with vite bundler, nuxt with vitest, vue, etc.) and npm as the package manager, npm install fails with ERESOLVE unable to resolve dependency tree.

Root cause: vitest ~4.0.x depends on @vitest/[email protected] which has a peer dependency on vite: "^6.0.0 || ^7.0.0" — it does not support vite 8. Since Nx now defaults to installing vite@^8.0.0, npm cannot satisfy @vitest/mocker's peer dependency.

Additionally, @vitejs/plugin-react-swc@^3.5.0 has a peer dependency on vite: "^4 || ^5 || ^6 || ^7" (no vite 8 support), and the SWC compiler path in ensure-dependencies.ts lacks the vite-version detection logic that the babel path already has.

Expected Behavior

  • Workspaces using vite 8 + vitest install successfully with npm
  • @vitejs/plugin-react-swc version is selected based on the installed vite version (v4.3+ for vite 8, v3.x for older vite)

Changes

  1. Bump vitestV4Version from ~4.0.0/~4.0.8 to ~4.1.0 in both @nx/vite and @nx/vitest — vitest 4.1.x's dependencies support vite 8
  2. Bump vitestV4CoverageV8Version and vitestV4CoverageIstanbulVersion to ~4.1.0 to match
  3. Update vitePluginReactSwcVersion from ^3.5.0 to ^4.3.0 (first version with vite 8 peer dep support), add vitePluginReactSwcV3Version = '^3.5.0' for backward compat
  4. Add vite-version detection to the SWC path in ensure-dependencies.ts (both @nx/vite and @nx/vitest), mirroring the existing babel path logic

Related Issue(s)

Fixes NXC-4164

@jaysoo jaysoo requested a review from a team as a code owner March 28, 2026 13:32
@jaysoo jaysoo requested a review from leosvelperez March 28, 2026 13:32
@netlify

netlify Bot commented Mar 28, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 95ecfb3
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c7f53c30ff22000806a50e
😎 Deploy Preview https://deploy-preview-35062--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 28, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 95ecfb3
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c7f53c2173550008bb3603
😎 Deploy Preview https://deploy-preview-35062--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 95ecfb3

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 42m 47s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 8s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded 40s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-28 16:23:43 UTC

@jaysoo jaysoo force-pushed the NXC-4164 branch 3 times, most recently from 1150242 to 084797a Compare March 28, 2026 14:08

@FrozenPandaz FrozenPandaz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update vitest in the root package.json too right?

When creating a workspace with `create-nx-workspace` using presets that
install vitest (react-monorepo with vite bundler, nuxt with vitest, vue,
etc.) and npm as the package manager, `npm install` fails with ERESOLVE
errors.

This happens because vitest 4.0.x depends on `@vitest/mocker` which has
a peer dependency on `vite: "^6 || ^7"` (no vite 8 support), while Nx
installs `vite@^8.0.0` by default.

Additionally, `@vitejs/plugin-react-swc@^3.5.0` has a peer dependency on
`vite: "^4 || ^5 || ^6 || ^7"` (no vite 8), and the SWC compiler path
in ensure-dependencies lacks version detection unlike the babel path.

- vitest 4.1.x is installed, which supports vite 8 through its
  dependencies (`@vitest/[email protected]` includes `vite@^8` in peer deps)
- `@vitejs/plugin-react-swc` version is selected based on the installed
  vite version (v4.3+ for vite 8, v3.x for older)

Fixes NXC-4164
@jaysoo jaysoo merged commit c9253fb into master Mar 28, 2026
24 checks passed
@jaysoo jaysoo deleted the NXC-4164 branch March 28, 2026 16:28
FrozenPandaz pushed a commit that referenced this pull request Mar 31, 2026
…pat (#35062)

When creating a workspace with `create-nx-workspace` using presets that
install vitest (react-monorepo with vite bundler, nuxt with vitest, vue,
etc.) and **npm** as the package manager, `npm install` fails with
`ERESOLVE unable to resolve dependency tree`.

**Root cause:** vitest `~4.0.x` depends on `@vitest/[email protected]` which
has a peer dependency on `vite: "^6.0.0 || ^7.0.0"` — it does **not**
support vite 8. Since Nx now defaults to installing `vite@^8.0.0`, npm
cannot satisfy `@vitest/mocker`'s peer dependency.

Additionally, `@vitejs/plugin-react-swc@^3.5.0` has a peer dependency on
`vite: "^4 || ^5 || ^6 || ^7"` (no vite 8 support), and the SWC compiler
path in `ensure-dependencies.ts` lacks the vite-version detection logic
that the babel path already has.

- Workspaces using vite 8 + vitest install successfully with npm
- `@vitejs/plugin-react-swc` version is selected based on the installed
vite version (v4.3+ for vite 8, v3.x for older vite)

1. **Bump `vitestV4Version`** from `~4.0.0`/`~4.0.8` to `~4.1.0` in both
`@nx/vite` and `@nx/vitest` — vitest 4.1.x's dependencies support vite 8
2. **Bump `vitestV4CoverageV8Version` and
`vitestV4CoverageIstanbulVersion`** to `~4.1.0` to match
3. **Update `vitePluginReactSwcVersion`** from `^3.5.0` to `^4.3.0`
(first version with vite 8 peer dep support), add
`vitePluginReactSwcV3Version = '^3.5.0'` for backward compat
4. **Add vite-version detection** to the SWC path in
`ensure-dependencies.ts` (both `@nx/vite` and `@nx/vitest`), mirroring
the existing babel path logic

Fixes NXC-4164

(cherry picked from commit c9253fb)
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants