Skip to content

feat(vite)!: deprecate the nxViteTsPaths and nxCopyAssetsPlugin helpers#35664

Merged
jaysoo merged 6 commits into
masterfrom
NXC-4316
Jun 2, 2026
Merged

feat(vite)!: deprecate the nxViteTsPaths and nxCopyAssetsPlugin helpers#35664
jaysoo merged 6 commits into
masterfrom
NXC-4316

Conversation

@jaysoo
Copy link
Copy Markdown
Member

@jaysoo jaysoo commented May 12, 2026

Current Behavior

nxViteTsPaths and nxCopyAssetsPlugin from @nx/vite/plugins/* run silently. New TS-solution workspaces never emit them; new non-ts-solution workspaces still do.

Expected Behavior

Both helpers log a one-time deprecation warning on call and carry @deprecated JSDoc tags. Behavior unchanged in v23; removal candidate for v24.

  • TS-solution: helpers are unused (package-manager workspaces handle path resolution; the project root is the publishable folder so no package.json copy is needed). Generator output is helper-free and a spec test locks that in.
  • Non-ts-solution: workspaces still need both helpers, so generator output is unchanged for now. A spec test locks in the current emit with a TODO(v24) for the swap to vite-tsconfig-paths.

Configure-Vite docs lead with vite-tsconfig-paths and publicDir / vite-plugin-static-copy and flag the helpers as deprecated.

Related Issue(s)

NXC-4316

@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 95ff94a
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a1f3c3f1066ad00083d8283
😎 Deploy Preview https://deploy-preview-35664--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 May 12, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 95ff94a
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a1f3c3fe57f570008e2098a
😎 Deploy Preview https://deploy-preview-35664--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 May 12, 2026

View your CI Pipeline Execution ↗ for commit 95ff94a

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

☁️ Nx Cloud last updated this comment at 2026-06-02 21:12:22 UTC

@jaysoo jaysoo force-pushed the NXC-4316 branch 2 times, most recently from 2db5af9 to 015b819 Compare May 14, 2026 17:39
@jaysoo jaysoo marked this pull request as ready for review May 14, 2026 17:51
@jaysoo jaysoo requested a review from a team as a code owner May 14, 2026 17:51
@jaysoo jaysoo requested a review from FrozenPandaz May 14, 2026 17:51
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

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

The deprecation docs contradict the example configs

astro-docs/.../configure-vite.mdoc adds two caution asides flagging the helpers as deprecated:

  • L31–32 — "nxViteTsPaths is deprecated"
  • L133–134 — "nxCopyAssetsPlugin is deprecated"

But further down the same page, the "What your vite.config.ts looks like" section still demonstrates the deprecated helper in both example configs:

  • For applications — L172 import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin', L194 plugins: [react(), nxViteTsPaths()]
  • For libraries — L223 import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin', L230 nxViteTsPaths()

So the page tells readers the helper is deprecated, then hands them a recommended vite.config.ts that uses it. The caution asides even say "as shown above" — but the canonical example config below them shows the old way. Please update those two example configs to tsconfigPaths() from vite-tsconfig-paths so the page is self-consistent.

Other docs pages still teach the deprecated helper

Beyond configure-vite.mdoc, several other guides still show nxViteTsPaths as the current way to do things. Worth fixing here or as a tracked follow-up so the deprecation messaging is consistent site-wide:

  • technologies/vue/nuxt/Guides/deploy-nuxt-to-vercel.mdoc — L46 import, L69 plugins: [nxViteTsPaths()]
  • technologies/react/Guides/adding-assets-react.mdoc — L344 import, L360 nxViteTsPaths()
  • technologies/test-tools/storybook/Guides/one-storybook-for-all.mdoc
  • technologies/test-tools/storybook/Guides/one-storybook-with-composition.mdoc
  • technologies/typescript/Guides/switch-to-workspaces-project-references.mdoc

(guides/Tasks & Caching/convert-to-inferred.mdoc also references it, but that guide is about migrating off old patterns, so it's likely fine as-is.)

Copy link
Copy Markdown
Contributor

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

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

Docs updates look good — the example configs now use tsconfigPaths() from vite-tsconfig-paths consistently across the vite, react, vue/nuxt, and storybook guides. The earlier inconsistency is resolved.

nx-cloud[bot]

This comment was marked as 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.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We investigated the e2e-gradle:e2e-ci--src/gradle-dsl.test.ts failure and determined it is unrelated to our changes — the PR only modifies vite and astro-docs, while e2e-gradle is untouched. The error is an intermittent ENOENT for a temporary workspace-data file produced during e2e environment setup, indicating a one-off timing gap in test infrastructure rather than a defect introduced by this PR.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


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

@jaysoo jaysoo marked this pull request as draft May 19, 2026 14:07
jaysoo and others added 5 commits June 2, 2026 09:27
`nxViteTsPaths` and `nxCopyAssetsPlugin` from `@nx/vite/plugins/*` run silently.

Both helpers log a one-time deprecation warning on call and carry `@deprecated` JSDoc tags. Behavior unchanged in v23; removal candidate for v24. Configure-Vite docs lead with `vite-tsconfig-paths` and `publicDir` / `vite-plugin-static-copy` and flag the helpers as deprecated.

NXC-4316
## Current Behavior

`generator-utils.spec.ts > should generate correct config when using ts solution setup` and three `configuration.spec.ts > TS solution setup` tests set up `package.json` workspaces but no `pnpm-workspace.yaml`. `detectPackageManager()` resolves to pnpm in the test env, so `isWorkspacesEnabled` falls back to looking for `pnpm-workspace.yaml`, finds none, and reports the tree as non-TS-solution. The tests silently exercise the non-TS-solution path while their inline snapshots assert the TS-solution path.

## Expected Behavior

Add `pnpm-workspace.yaml` to both TS-solution fixtures so `isUsingTsSolutionSetup` returns true and the existing `if (!isTsSolutionSetup)` gate in `createOrEditViteConfig` is actually exercised. Confirms that the TS solution setup does not emit `nxViteTsPaths` or `nxCopyAssetsPlugin` in generated configs.

## Related Issue(s)

NXC-4316
…gacy branches

## Current Behavior

`createOrEditViteConfig` skips `nxViteTsPaths` / `nxCopyAssetsPlugin` for ts-solution and emits them for non-ts-solution. The behaviour is implicit in scattered snapshots; no test asserts the split directly.

## Expected Behavior

`configuration.spec.ts` gains two focused tests: ts-solution gen does not emit the deprecated helpers, non-ts-solution gen still does. The non-ts-solution test carries a TODO(v24) flagging the swap to `vite-tsconfig-paths` once the legacy branch is migrated.

## Related Issue(s)

NXC-4316
@jaysoo jaysoo marked this pull request as ready for review June 2, 2026 14:24
Comment thread packages/vite/plugins/nx-copy-assets.plugin.ts Outdated
## Current Behavior
Stray duplicate `CopyAssetsHandler` import breaks `vite:build-base` (TS2300). New configuration spec inline snapshots use `rollupOptions`, but the generator emits `rolldownOptions`, so `vite:test` fails.

## Expected Behavior
Single import. Inline snapshots match generator output. Both targets pass. Also marks the legacy non-ts-solution emit branch with a TODO(v24).

## Related Issue(s)
NXC-4316
@jaysoo jaysoo merged commit 4d6eddf into master Jun 2, 2026
26 checks passed
@jaysoo jaysoo deleted the NXC-4316 branch June 2, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants