Skip to content

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

Open
dargmuesli wants to merge 2 commits 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 2 commits 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 66646e93-3182-4c7b-8060-00faad03e434

📥 Commits

Reviewing files that changed from the base of the PR and between f7481c6 and 75fe057.

📒 Files selected for processing (1)
  • src/types/build.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/types/build.ts

📝 Walkthrough

Walkthrough

RollupConfig now accepts Rollup and Rolldown plugin types. Development and production Rollup paths cast the configuration to RollupOptions before use.

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

Possibly related PRs

  • nitrojs/nitro#3887: Adds Rolldown configuration types and bundler integration in related build typing areas.
  • nitrojs/nitro#4002: Introduces Rolldown integration supported by the mixed plugin typing.
🚥 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
Title check ✅ Passed The title follows Conventional Commits syntax and accurately describes widening RollupConfig.plugins for Rolldown plugins.
Description check ✅ Passed The description explains the Vite 8/Rolldown type incompatibility and the changes made to resolve it.
Linked Issues check ✅ Passed The changes address issue #4482 by accepting Rolldown plugins while preserving strict types at Rollup API call sites.
Out of Scope Changes check ✅ Passed All changes support the linked issue and PR objective; no unrelated code changes are present.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 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: 75fe057

@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
Comment thread src/types/build.ts Outdated
// Vite's `Plugin` extends `Rolldown.Plugin` instead of Rollup's own type.
// `rollupConfig` is also reused for the `rolldown` builder (see
// `build/vite/bundler.ts`), so accept either shape here.
plugins?: RollupInputOptions["plugins"] | RolldownInputOptions["plugins"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could allow a mix of both plugins in same array?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Pushed a commit for this :) let me know if it looks alright

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

2 participants