Skip to content

fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins [v3] - #4483

Open
dargmuesli wants to merge 1 commit into
nitrojs:mainfrom
dargmuesli:fix/rollup-config-plugins-rolldown-type
Open

fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins [v3]#4483
dargmuesli wants to merge 1 commit into
nitrojs:mainfrom
dargmuesli:fix/rollup-config-plugins-rolldown-type

Conversation

@dargmuesli

@dargmuesli dargmuesli commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4482.

Vite 8 changed its own Plugin type to extends Rolldown.Plugin<A> (Vite now bundles Rolldown as its internal bundler instead of Rollup+esbuild). Any plugin factory typed against Vite's Plugin, e.g. @vitejs/plugin-vue's vue(), is therefore now structurally a Rolldown plugin. Nitro's rollupConfig.plugins is typed against the rollup package's Plugin, so passing a Vite 8 plugin there no longer type-checks.

nitro.options.rollupConfig is already deliberately reused across both the rollup and rolldown builders (see the // Added for backward compatibility casts in src/build/vite/bundler.ts) so this widens the public plugins field to accept either bundler's plugin shape, and adds a narrow as RollupOptions cast at the two places that call the rollup package (rollup.rollup(), rollup.watch()), which still need the strict, Rollup-only type.

Note: this targets main, companion PR for v2 now open there: #4484.

Changes

  • src/types/build.ts: RollupConfig.plugins is now RollupInputOptions["plugins"] | RolldownInputOptions["plugins"] instead of being locked to Rollup's own type.
  • src/build/rollup/prod.ts: cast rollupConfig to RollupOptions at the rollup.rollup() call site.
  • src/build/rollup/dev.ts: same cast at the rollup.watch() call site.

Vite 8 changed its own Plugin type to extend Rolldown.Plugin, so plugin
factories typed against Vite (e.g. @vitejs/plugin-vue's vue()) no longer
satisfy rollupConfig.plugins, which is typed against real Rollup's Plugin.
rollupConfig is already reused for the rolldown builder internally, so
widen the public type and keep the two real rollup() call sites strict
via a local cast.

Fixes nitrojs#4482
@dargmuesli
dargmuesli requested a review from pi0 as a code owner July 27, 2026 00:37
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@dargmuesli is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Rollup plugin typing

Layer / File(s) Summary
Shared configuration type contract
src/types/build.ts
RollupConfig accepts Rollup-typed or Rolldown-typed plugins while retaining optional output configuration.
Build option integration
src/build/rollup/dev.ts, src/build/rollup/prod.ts
Development watcher merging and production builds cast rollupConfig to RollupOptions.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR widens RollupConfig.plugins for Rolldown plugins and adds RollupOptions casts at both Rollup call sites, matching #4482.
Out of Scope Changes check ✅ Passed The changes are limited to the plugin type widening and necessary RollupOptions casts, with no unrelated additions.
Title check ✅ Passed The title uses a valid conventional commit prefix and clearly matches the plugin-type widening change.
Description check ✅ Passed The description directly explains the RollupConfig typing fix and the RollupOptions casts in the changed files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4483

commit: f7481c6

@dargmuesli dargmuesli changed the title fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins [v3] Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant