Skip to content

Plugin from Vite 8 / Rolldown not assignable to rollupConfig.plugins #4482

Description

@dargmuesli

Environment

- nitropack: 2.13.4
- vite: 8.1.5 (bundles rolldown ~1.1.5 as its internal bundler)
- rollup: 4.62.2
- @vitejs/plugin-vue: 6.0.8
- typescript: 6.0.3
- node: v24.18.0

Also reproduces via Nuxt 4.5.0 (nitropack 2.13.4, vite 8.1.5); regression from Nuxt 4.4.8, which uses Vite 7/Rollup.

Reproduction

package.json

{
  "name": "nitro-rollup-plugin-repro",
  "private": true,
  "type": "module",
  "devDependencies": {
    "nitropack": "2.13.4",
    "@vitejs/plugin-vue": "6.0.8",
    "vite": "8.1.5",
    "typescript": "6.0.3"
  }
}

nitro.config.ts

import vue from '@vitejs/plugin-vue'
import { defineNitroConfig } from 'nitropack/config'

export default defineNitroConfig({
  rollupConfig: {
    plugins: [vue()],
  },
})

tsconfig.json

{
  "compilerOptions": {
    "strict": true,
    "moduleResolution": "bundler",
    "module": "esnext",
    "target": "es2022",
    "skipLibCheck": true,
    "noEmit": true
  },
  "include": ["nitro.config.ts"]
}

Run: npm install && npx tsc --noEmit -p tsconfig.json

(StackBlitz doesn't load for me at the moment, I need to investigate why still)

Describe the bug

nitro.config.ts:6 fails to type-check:

nitro.config.ts(6,15): error TS2322: Type 'Plugin<Api>' is not assignable to type 'InputPluginOption'.
  Type 'Plugin<Api>' is not assignable to type 'Plugin<any>'.
    Types of property 'augmentChunkHash' are incompatible.
      ...
      Property 'environment' is missing in type
        '.../rollup/dist/rollup".PluginContext'
      but required in type
        '.../rolldown/dist/shared/define-config-....Y'.

rollupConfig.plugins (RollupConfig = InputOptions & {...}) is typed against the rollup package's Plugin/InputPluginOption.

Vite 8 changed its Plugin type to:

interface Plugin<A = any> extends Rolldown.Plugin<A>

so any plugin factory typed against Vite's Plugin (e.g. @vitejs/plugin-vue's vue()) is now structurally a Rolldown plugin. The hook-context shapes diverge: Rolldown's PluginContext requires an environment property that Rollup's PluginContext doesn't have, so a Vite/Rolldown-typed plugin no longer satisfies Nitro's Rollup-typed rollupConfig.plugins.

Additional context

  • Possible fixes: loosen RollupConfig.plugins's type to accept Rolldown-shaped plugins as well (e.g. union with Rolldown.Plugin), or accept structurally-looser hook signatures.
  • Happy to help narrow this down further or test a fix.

Logs

none beyond the tsc output above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions