[Bug]: vite-plugin: vite and ripple are imported but not declared as dependencies
@ripple-ts/vite-plugin (0.4.7 on npm, and main at 83ed561) imports two packages that its package.json lists only as devDependencies:
vite, at run time and in the published types:// src/index.js:1197 and src/load-config.js:334 const { build: viteBuild } = await import('vite'); const { createServer } = await import('vite');// types/index.d.ts:1 import type { Plugin, BuildEnvironmentOptions, ViteDevServer } from 'vite';ripple, in the published types:// types/index.d.ts:3-4 import type { Transport } from 'ripple/transport'; export type { Transport, Transporter } from 'ripple/transport';
Because neither is a dependency or a peer dependency, a strict package manager resolves these imports to whatever copy it happens to hoist, not the app's own vite and ripple.
What we saw
In tsrx-org/tsrx the website depends on [email protected] and @ripple-ts/[email protected]. After an unrelated lockfile change, pnpm hoisted a different peer variant of Vite ([email protected] built against @types/[email protected] instead of the website's @types/[email protected]). The plugin's import type … from 'vite' picked up that copy, so tsc loaded two Vites, each augmenting rolldown's plugin context:
node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/define-config-BhJ90aEv.d.mts(2053,11): error TS2320: Interface 'MinimalPluginContext' cannot simultaneously extend types 'PluginContextExtension' and 'PluginContextExtension'.
node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/index.d.ts(2472,3): error TS2416: Property 'environment' in type 'MinimalPluginContext$1<T>' is not assignable to the same property in base type 'MinimalPluginContext'.The website's own code was unchanged; only the hoisted copy had moved.
Suggested fix
Declare both as peer dependencies (an app using the plugin always has them), and keep them in devDependencies for the package's own tests:
"peerDependencies": {
"ripple": "<the supported range>",
"vite": "<the supported range>"
}type-fest appears only in a JSDoc @import in src/index.js, so it matters only to projects that type-check the plugin's JavaScript.
Workaround
In the meantime, pnpm users can add the peer themselves:
# pnpm-workspace.yaml
packageExtensions:
'@ripple-ts/vite-plugin':
peerDependencies:
vite: '*'
peerDependenciesMeta:
vite:
optional: trueSource: Ripple-TS/ripple