Skip to content

feat(vite)!: remove vitest support in favor of @nx/vitest#35517

Merged
jaysoo merged 11 commits into
masterfrom
NXC-4158
May 6, 2026
Merged

feat(vite)!: remove vitest support in favor of @nx/vitest#35517
jaysoo merged 11 commits into
masterfrom
NXC-4158

Conversation

@jaysoo
Copy link
Copy Markdown
Member

@jaysoo jaysoo commented Apr 30, 2026

Current Behavior

@nx/vite carries a parallel vitest surface (version constants, :test executor, vitest generator, plugin test inference, init-time install) that duplicates @nx/vitest.

Expected Behavior

@nx/vite owns vite. @nx/vitest owns vitest. Vitest surface removed from @nx/vite; consumers route through @nx/vitest.

v23 migration installs @nx/vitest, swaps the executor, and registers @nx/vitest plugin alongside default-config @nx/vite/plugin so test inference is preserved.

Related Issue(s)

Closes NXC-4158

@jaysoo jaysoo requested a review from a team as a code owner April 30, 2026 15:50
@jaysoo jaysoo requested a review from lourw April 30, 2026 15:50
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 30, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit e2aff44
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69fb9e8df13b3d0007af7bdb
😎 Deploy Preview https://deploy-preview-35517--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 Apr 30, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit e2aff44
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69fb9e8d370408000815ccc0
😎 Deploy Preview https://deploy-preview-35517--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.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Apr 30, 2026

View your CI Pipeline Execution ↗ for commit e2aff44

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

☁️ Nx Cloud last updated this comment at 2026-05-06 20:50:22 UTC

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

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

Comment thread packages/vite/src/migrations/update-23-0-0/ensure-vitest-package-migration.ts Outdated
Comment thread packages/vite/src/migrations/update-23-0-0/ensure-vitest-package-migration.ts Outdated
@jaysoo
Copy link
Copy Markdown
Member Author

jaysoo commented May 5, 2026

I think we can keep the migration doc and say that @nx/vite vitest features were removed in v23.

nx-cloud[bot]

This comment was marked as outdated.

Comment thread packages/vite/src/migrations/update-23-0-0/ensure-vitest-package-migration.ts Outdated
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, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


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

Comment thread packages/vite/src/migrations/update-23-0-0/ensure-vitest-package-migration.ts Outdated
@jaysoo jaysoo force-pushed the NXC-4158 branch 2 times, most recently from 7d9c569 to bdb960c Compare May 6, 2026 14:48
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 6, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

jaysoo and others added 5 commits May 6, 2026 16:02
@nx/vite ships vitest version constants, the @nx/vite:test executor, the @nx/vite:vitest generator, and @nx/vite/plugin test target inference. Duplicates @nx/vitest.

@nx/vite owns vite only. @nx/vitest owns vitest. Removed:
- vitest version constants + helpers from versions.ts/version-utils.ts
- @nx/vite:test executor
- @nx/vite:vitest generator
- @nx/vite/plugin test target inference + atomization
- vitest install in @nx/vite init
- vitest peer dep

v23 safety-net migration installs @nx/vitest, swaps @nx/vite:test → @nx/vitest:test (project + targetDefaults), splits @nx/vite/plugin registrations, and registers @nx/vitest plugin alongside default-config @nx/vite/plugin (closes 22.2.0 gap).

@nx/vite configuration generator with includeVitest still works — delegates to @nx/vitest via ensurePackage.

Fixes NXC-4158
Co-authored-by: jaysoo <jaysoo@users.noreply.github.com>
@nx/vitest always installed, even in workspaces with no vitest usage.
When @nx/vitest/plugin is already registered alongside @nx/vite/plugin
entries that carry vitest options, those options are silently dropped.
Migration guide backward-compat section still says "will be removed in
Nx 23" rather than noting the removal happened.

@nx/vitest installed only when vitest usage is detected: vitest in
package.json, @nx/vite:test executor in any project, vitest-related
options on @nx/vite/plugin, or vitest.config.* in any project root.
Vitest options extracted from @nx/vite/plugin are merged into any
existing @nx/vitest plugin entry (matched by include/exclude scope)
without overwriting user-set fields. Migration guide backward-compat
section updated to describe the removal as historical fact. Companion
migration doc added under packages/vite/docs/.

Addresses review comments on PR for NXC-4158
## Current Behavior
@nx/vitest plugin registered alongside @nx/vite/plugin without
gating package install on actual migration work. Workspaces that
rely on @nx/vite/plugin test inference (no executor, no root vitest
dep) silently lose test targets.

## Expected Behavior
Each migration helper returns whether it changed anything. Install
fires only when at least one helper actually did work. Adds an
inference-only signal: glob vite.config.* / vitest.config.* and
grep for top-level `test:` block.

## Related Issue(s)
NXC-4158
jaysoo added 6 commits May 6, 2026 16:02
## Current Behavior
No migration path from @nx/vitest:test executor to the inferred
@nx/vitest plugin. @nx/vite:convert-to-inferred no longer covers
test (removed in the vitest split).

## Expected Behavior
@nx/vitest:convert-to-inferred ports the test target migration:
configFile → config, reportsDirectory → coverage.reportsDirectory,
testFiles → testNamePattern. Mirrors the deleted @nx/vite version.

## Related Issue(s)
NXC-4158
Migration uses a scopeKey helper to merge new @nx/vitest entries into
existing ones with matching include/exclude. Defends against a
scenario that doesn't realistically occur post-v22.2.0. Migration doc
also lived under packages/vite/docs/ instead of next to the migration
itself.

Migration unconditionally splits vitest options off @nx/vite/plugin
into a new @nx/vitest entry mirroring include/exclude. If a workspace
ends up with duplicates, that mirrors a pre-existing config issue and
is left visible. Migration doc moved to
packages/vite/src/migrations/update-23-0-0/ to match repo convention.

NXC-4158
## Current Behavior
ensureVitestPluginRegistration short-circuits as soon as any
@nx/vitest entry exists. Workspaces with mixed @nx/vite/plugin scopes
(e.g. apps/**/* with testTargetName, libs/**/* bare) silently lose
inference under the bare scope after migration: the apps split adds
@nx/vitest, the global has-vitest check then bails before pairing
libs.

## Expected Behavior
Replace the global short-circuit with a per-scope coveredScopes set
built from existing @nx/vitest entries. Each @nx/vite/plugin is
paired with @nx/vitest unless its scope is already covered.

## Related Issue(s)
NXC-4158
## Current Behavior
Interface declared as the forEachExecutorOptions generic but the
callback never reads _options.

## Expected Behavior
Removed. Drops dead code without changing migration behavior.

## Related Issue(s)
NXC-4158
migrateTargetDefaults had zero direct test coverage. The three
patterns it handles (executor-keyed rename, target-name-keyed
executor swap, collision merge) were untested.

Three new specs covering each pattern. Collision case documents the
legacy-wins Object.assign behavior intentionally.

NXC-4158
## Current Behavior
scopeKey takes PluginEntry, which is ExpandedPluginConfiguration<Record<string, unknown>>. Plugins read from nxJson come back as ExpandedPluginConfiguration<unknown>, which is wider on options. CI typecheck fails on the assignment.

## Expected Behavior
scopeKey only reads include/exclude. Narrow the parameter to that structural shape so it accepts both PluginEntry and the wider read type without an unsafe cast.

## Related Issue(s)
NXC-4158
@jaysoo jaysoo merged commit c494ec5 into master May 6, 2026
25 checks passed
@jaysoo jaysoo deleted the NXC-4158 branch May 6, 2026 21:30
FrozenPandaz added a commit that referenced this pull request May 8, 2026
…35576)

## Current Behavior

Most Nx executors that have an inferred-plugin alternative
(`@nx/<pkg>/plugin`) and a `convert-to-inferred` generator are still
wired up like first-class citizens. There is no signal — at scaffold
time, schema browsing, or task execution — that they are on a path to
removal, and the existing `cypress`/`detox` deprecation messages are
inconsistent with the canonical pattern shipped most recently.

## Expected Behavior

Every executor that has an inferred-plugin migration target is now
deprecated through three surfaces, matching the canonical pattern:

- **Runtime warning.** The executor logs that it is deprecated, will be
removed in Nx v24, and points at `nx g @nx/<pkg>:convert-to-inferred`.
- **Schema-root `x-deprecated`.** Surfaces in editor / Nx Console / `nx
show project` views.
- **Generation-time warning.** When a generator is about to scaffold a
target that uses one of these executors because the corresponding
inferred plugin isn't registered, it warns at generation time and points
at the same migration path.

All warnings link to
<https://nx.dev/docs/guides/tasks--caching/convert-to-inferred>.

### Executors deprecated in this PR

| Package | Executors |
|---|---|
| `@nx/webpack` | `webpack`, `dev-server` |
| `@nx/vite` | `build`, `dev-server`, `preview-server` |
| `@nx/rollup` | `rollup` |
| `@nx/next` | `build`, `server` |
| `@nx/remix` | `build`, `serve` |
| `@nx/jest` | `jest` |
| `@nx/playwright` | `playwright` |
| `@nx/eslint` | `lint` |
| `@nx/storybook` | `storybook`, `build` |
| `@nx/rspack` | `rspack`, `dev-server` |
| `@nx/expo` | `build`, `export`, `install`, `prebuild`, `run`, `serve`,
`start`, `submit` |
| `@nx/react-native` | `build-android`, `build-ios`, `bundle`,
`pod-install`, `run-android`, `run-ios`, `start`, `upgrade` |
| `@nx/vitest` | `test` |

### Generation-time warnings wired in

- `@nx/<pkg>:configuration` for webpack, vite, rollup, jest, playwright,
storybook, rspack, vitest
- `@nx/<pkg>:application` for next, expo, react-native
- `@nx/eslint:lint-project` legacy fallback path
- `@nx/react:application` (webpack, rspack branches) and
`@nx/react:library` (rollup legacy fallback) — warning text is inlined
rather than imported. Two distinct reasons:
- **rspack:** `@nx/react` does not declare a tsconfig project reference
to `@nx/rspack`, so the deep import would not even type-check.
- **webpack and rollup:** the project reference exists, so the deep
import compiles, but `@nx/webpack` and `@nx/rollup` only expose
`./index.js` in their package `exports` field. The import would resolve
in source but throw `Cannot find module
'@nx/<pkg>/src/utils/deprecation'` at runtime in published packages.
- `@nx/react-native:web-configuration` (webpack) — inline for the same
reason as the rspack case (no project reference).

### Scope notes

- `@nx/vite:test` is intentionally **not** included — it is being
removed entirely by PR #35517 (deprecation messaging would ship as dead
code). `@nx/vitest:test` is now in scope: the `convert-to-inferred`
generator for `@nx/vitest` is in place, so the deprecation has a real
migration target.
- `@nx/cypress`/`@nx/detox` already shipped earlier; this PR retitles
their generation-time messages to the new wording (drop the redundant
"register the plugin first" guidance, swap "Scaffolding" for
"Generating") and points the detox URL at the general
convert-to-inferred guide.
- `@nx/react-native:storybook` is intentionally **not** included. The
companion `@nx/react-native:storybook-configuration` generator was
already removed in v21 and no generator has emitted this target since
Jan 2024 (RN 0.73 upgrade). It will be removed outright in a follow-up
PR rather than going through the deprecate-now / remove-in-v24 cycle.
- `@nx/webpack:ssr-dev-server`, `@nx/expo:build-list`,
`@nx/expo:sync-deps`, `@nx/expo:update`, `@nx/expo:ensure-symlink`,
`@nx/react-native:sync-deps`, and `@nx/react-native:ensure-symlink` are
intentionally left as-is — none are covered by `convert-to-inferred` and
they have no clean replacement (Nx-specific glue or non-migrating
utilities).
- `@nx/esbuild:esbuild` and `@nx/nuxt:*` ship neither an inferred plugin
nor a `convert-to-inferred` generator yet, so they're out of scope.
- Per-package READMEs, introduction-doc banners, per-package "migration
recipe" pages, and `migrations.json` entries are intentionally skipped
per the canonical pattern (NXC-4422). The runtime warning carries the
migration story.

## Related Issue(s)

Fixes NXC-4423.
Fixes NXC-4296.
Fixes NXC-4294.
Fixes NXC-4290.
Fixes NXC-4285.
Fixes NXC-4283.
Fixes NXC-4286.
Fixes NXC-4297.
Fixes NXC-4293.
Fixes NXC-4292.
Fixes NXC-4282.
Fixes NXC-4287.
Fixes NXC-4295.
Fixes NXC-4447.

---------

Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
@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 May 12, 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.

3 participants