rolldown-viteWhen using @rollup/plugin-replace together with rolldown-vite, a type error is reported:
Type 'ResolveIdPluginContext' is missing the following properties from type 'PluginContext': cache, getWatchFiles, setAssetSource
Same happens for other plugins such as @rollup/plugin-strip. Type worked as expected (no errors) with plain Vite.
(Without the repro)
pnpm create vitepnpm i @rollup/plugin-replaceimport { defineConfig } from 'vite'
import replace from '@rollup/plugin-replace'
export default defineConfig({
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
})
]
})
Then you see the TS Error.
All systems
pnpm
vite.config.ts:5:5 - error TS2769: No overload matches this call.
The last overload gave the following error.
Type 'Plugin<any>' is not assignable to type 'PluginOption'.
Type 'import("/Users/alichter/Programming/rm-rolldown-vite-vanilla-test/node_modules/.pnpm/rollup@4.40.0/node_modules/rollup/dist/rollup").Plugin<any>' is not assignable to type 'import("/Users/alichter/Programming/rm-rolldown-vite-vanilla-test/node_modules/.pnpm/rolldown-vite@6.3.0-beta.8_esbuild@0.25.2_typescript@5.7.3/node_modules/rolldown-vite/dist/node/index").Plugin<any>'.
Types of property 'resolveId' are incompatible.
Type 'ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { attributes: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>, { ...; }> | undefined' is not assignable to type 'ObjectHook<(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: { kind?: "import" | "dynamic-import" | "require-call" | undefined; custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>, { ...; }> | undefined'.
Type '(this: PluginContext, source: string, importer: string | undefined, options: { attributes: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>' is not assignable to type 'ObjectHook<(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: { kind?: "import" | "dynamic-import" | "require-call" | undefined; custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>, { ...; }> | undefined'.
Type '(this: PluginContext, source: string, importer: string | undefined, options: { attributes: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>' is not assignable to type '(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: { kind?: "import" | "dynamic-import" | "require-call" | undefined; custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>'.
The 'this' types of each signature are incompatible.
Type 'ResolveIdPluginContext' is missing the following properties from type 'PluginContext': cache, getWatchFiles, setAssetSource
5 replace({
~~~~~~~~~
6 'process.env.NODE_ENV': JSON.stringify('production'),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 })
~~~~~~
node_modules/.pnpm/rolldown-vite@6.3.0-beta.8_esbuild@0.25.2_typescript@5.7.3/node_modules/rolldown-vite/dist/node/index.d.ts:3672:18
3672 declare function defineConfig(config: UserConfigExport): UserConfigExport;
~~~~~~~~~~~~