Skip to content

rolldown-vite plugin types throw when using rollup plugins #117

@TheAlexLichter

Description

@TheAlexLichter

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)

  1. Run pnpm create vite
  2. Use a Vanilla TypeScript app
  3. pnpm i @rollup/plugin-replace
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions