Skip to content

fix(kit): cast nuxt addVitePlugin calls past duplicate vite peer types - #590

Open
antfubot wants to merge 1 commit into
mainfrom
fix/nuxt-vite-plugin-duplicate-vite-types
Open

antfubot wants to merge 1 commit into
mainfrom
fix/nuxt-vite-plugin-duplicate-vite-types

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Description

CI's Typecheck step is red on main: after the vite 8.3.1 bump, pnpm resolves vite's optional @vitejs/devtools peer to a different published version for each Nuxt-hosted devtools app's own dependency chain versus the one @nuxt/kit's addVitePlugin is typed against. Both installs are the same vite@8.3.1, but TypeScript treats them as structurally distinct because DevEnvironment's hotUpdate hook now flows through a private _pluginContextMap field, so vue-tsc rejects our own plugin objects as foreign Plugin instances in packages/oxc, packages/rolldown, and packages/vite's modules/rpc.ts.

Pinning the lockfile to a single @vitejs/devtools peer flavor (via overrides, peerDependencyRules.allowedVersions, and ignoreMissing) didn't hold — each Nuxt app instance re-resolves its own @nuxt/vite-builder → vite → @vitejs/devtools chain independently, so a lockfile-level fix would mean pinning every such chain across the monorepo. Instead, this adds a small addDevToolsVitePlugin helper at each addVitePlugin call site that casts past the structural mismatch, since the plugin objects are valid at runtime regardless of which peer flavor typed them.

Linked Issues

Additional context

Verified pnpm lint && pnpm test && pnpm typecheck && pnpm build all pass locally with this change (typecheck was the only broken step).


This PR was created with the help of an AI agent.

pnpm resolves vite's optional @vitejs/devtools peer independently for
each Nuxt-hosted devtools app and for @nuxt/kit's own dependency chain,
so addVitePlugin ends up typed against a structurally distinct (but
runtime-identical) vite install than the plugin objects we hand it.
vue-tsc rejected this as a foreign Plugin instance after the vite 8.3.1
bump exposed the mismatch through the DevEnvironment hotUpdate hook.
@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@590

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@590

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@590

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@590

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@590

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@590

commit: ec3e160

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.

1 participant