forked from vitejs/vite
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Describe the bug
When 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.
Reproduction
https://github.com/TheAlexLichter/rolldown-vite-rollup-plugin-type-error
Steps to reproduce
(Without the repro)
- Run
pnpm create vite
- Use a Vanilla TypeScript app
pnpm i @rollup/plugin-replace
- Set your vite config to:
import { 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
System Info
All systems
Used Package Manager
pnpm
Logs
Details
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;
~~~~~~~~~~~~
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs and the Rolldown-related guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels