Skip to content

fix(vite): add support for Vite 8#34850

Merged
jaysoo merged 1 commit into
nrwl:masterfrom
robert-sidzinka:feat/vite-8-support
Mar 25, 2026
Merged

fix(vite): add support for Vite 8#34850
jaysoo merged 1 commit into
nrwl:masterfrom
robert-sidzinka:feat/vite-8-support

Conversation

@robert-sidzinka
Copy link
Copy Markdown
Contributor

@robert-sidzinka robert-sidzinka commented Mar 16, 2026

Current Behavior

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

Expected Behavior

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)

Other 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

@robert-sidzinka robert-sidzinka requested a review from a team as a code owner March 16, 2026 09:48
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 16, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 51041b9
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c3f07316c25a6a45a42d9e
😎 Deploy Preview https://deploy-preview-34850--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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 16, 2026

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 51041b9

@FrozenPandaz FrozenPandaz requested a review from jaysoo March 16, 2026 21:45
@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label Mar 16, 2026
@robert-sidzinka
Copy link
Copy Markdown
Contributor Author

Hi team! The Vercel deployment check is showing as failed, but this PR only touches files in packages/vite/ and packages/vitest/ — no docs or site changes. Could a maintainer check if the Vercel failure is unrelated to this PR?

Also, the Netlify deploy previews are pending review (expected for fork PRs).

Thanks!

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Mar 17, 2026

View your CI Pipeline Execution ↗ for commit 51041b9

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

☁️ Nx Cloud last updated this comment at 2026-03-25 15:03:17 UTC

@robert-sidzinka robert-sidzinka requested a review from a team as a code owner March 17, 2026 14:07
@robert-sidzinka robert-sidzinka force-pushed the feat/vite-8-support branch 2 times, most recently from bcf6844 to 6abd70f Compare March 17, 2026 17:12
@robert-sidzinka robert-sidzinka requested a review from a team as a code owner March 17, 2026 17:12
@jaysoo jaysoo added priority: high High Priority (important issues which affect many people severely) and removed priority: medium Medium Priority (not high, not low priority) labels Mar 23, 2026
@jaysoo
Copy link
Copy Markdown
Member

jaysoo commented Mar 23, 2026

Hi @rsidzinkaloopme , thanks for the PR. I'll check on the CI blocker.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch from d343386 to 9e42add Compare March 23, 2026 13:56
@jaysoo jaysoo requested a review from a team as a code owner March 23, 2026 13:56
@robert-sidzinka
Copy link
Copy Markdown
Contributor Author

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.

@jaysoo
Copy link
Copy Markdown
Member

jaysoo commented Mar 23, 2026

@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.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch 2 times, most recently from 6c39dd3 to 98faec5 Compare March 23, 2026 17:46
nx-cloud[bot]

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch 2 times, most recently from a6b103d to 4bea10b Compare March 23, 2026 20:05
nx-cloud[bot]

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch from 4bea10b to 5f03973 Compare March 23, 2026 21:50
nx-cloud[bot]

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch from 5f03973 to 742f28f Compare March 23, 2026 22:30
nx-cloud[bot]

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch 2 times, most recently from 20dc607 to 90e914e Compare March 24, 2026 11:41
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch 4 times, most recently from f948969 to 2090b20 Compare March 24, 2026 18:20
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the feat/vite-8-support branch 5 times, most recently from 88fbde9 to 718e0db Compare March 25, 2026 12:47
@jaysoo jaysoo changed the title feat(vite): add support for Vite 8 fix(vite): add support for Vite 8 Mar 25, 2026
@jaysoo jaysoo force-pushed the feat/vite-8-support branch from 718e0db to f611dde Compare March 25, 2026 13:10
nx-cloud[bot]

This comment was marked as outdated.

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
@jaysoo jaysoo force-pushed the feat/vite-8-support branch from f611dde to 51041b9 Compare March 25, 2026 14:04
Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

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

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

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@jaysoo jaysoo merged commit c699048 into nrwl:master Mar 25, 2026
21 of 22 checks passed
FrozenPandaz pushed a commit that referenced this pull request Mar 26, 2026
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)
@github-actions
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 Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

priority: high High Priority (important issues which affect many people severely)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(@nx/vite): Add support for Vite 8

4 participants