-
fix(vite): update vitest and plugin-react-swc versions for vite 8 compat (#35062)
发布于
2026-03-28 16:28:35 +00:00 Current Behavior
When creating a workspace with
create-nx-workspaceusing presets that
install vitest (react-monorepo with vite bundler, nuxt with vitest, vue,
etc.) and npm as the package manager,npm installfails with
ERESOLVE unable to resolve dependency tree.Root cause: vitest
~4.0.xdepends on@vitest/mocker@4.0.xwhich
has a peer dependency onvite: "^6.0.0 || ^7.0.0"— it does not
support vite 8. Since Nx now defaults to installingvite@^8.0.0, npm
cannot satisfy@vitest/mocker's peer dependency.Additionally,
@vitejs/plugin-react-swc@^3.5.0has a peer dependency on
vite: "^4 || ^5 || ^6 || ^7"(no vite 8 support), and the SWC compiler
path inensure-dependencies.tslacks 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-swcversion is selected based on the installed
vite version (v4.3+ for vite 8, v3.x for older vite)
Changes
- Bump
vitestV4Versionfrom~4.0.0/~4.0.8to~4.1.0in both
@nx/viteand@nx/vitest— vitest 4.1.x's dependencies support vite 8 - Bump
vitestV4CoverageV8Versionand
vitestV4CoverageIstanbulVersionto~4.1.0to match - Update
vitePluginReactSwcVersionfrom^3.5.0to^4.3.0
(first version with vite 8 peer dep support), add
vitePluginReactSwcV3Version = '^3.5.0'for backward compat - Add vite-version detection to the SWC path in
ensure-dependencies.ts(both@nx/viteand@nx/vitest), mirroring
the existing babel path logic
Related Issue(s)
Fixes NXC-4164
下载附件