Skip to content

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

Open
rsidzinkaloopme wants to merge 1 commit intonrwl:masterfrom
rsidzinkaloopme:feat/vite-8-support
Open

feat(vite): add support for Vite 8#34850
rsidzinkaloopme wants to merge 1 commit intonrwl:masterfrom
rsidzinkaloopme:feat/vite-8-support

Conversation

@rsidzinkaloopme
Copy link

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

@rsidzinkaloopme rsidzinkaloopme requested a review from a team as a code owner March 16, 2026 09:48
@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 2090b20
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c2d5e45e328d000886f799
😎 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

netlify bot commented Mar 16, 2026

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 2090b20

@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
@rsidzinkaloopme
Copy link
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
Contributor

nx-cloud bot commented Mar 17, 2026

View your CI Pipeline Execution ↗ for commit 2090b20

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

☁️ Nx Cloud last updated this comment at 2026-03-24 22:57:52 UTC

@rsidzinkaloopme rsidzinkaloopme requested a review from a team as a code owner March 17, 2026 14:07
@rsidzinkaloopme rsidzinkaloopme force-pushed the feat/vite-8-support branch 2 times, most recently from bcf6844 to 6abd70f Compare March 17, 2026 17:12
@rsidzinkaloopme rsidzinkaloopme 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
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
@rsidzinkaloopme
Copy link
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
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
@jaysoo jaysoo force-pushed the feat/vite-8-support branch 2 times, most recently from 8851d84 to 074ceb8 Compare March 24, 2026 01:54
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 3 times, most recently from e0c9ea6 to f948969 Compare March 24, 2026 16:37
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 f948969 to 2090b20 Compare March 24, 2026 18:20
nx-cloud[bot]

This comment was marked as outdated.

Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

3 participants