Skip to content

fix(types): widen RollupConfig.plugins to accept rolldown-typed plugins - #4483

Merged
pi0 merged 3 commits into
nitrojs:mainfrom
dargmuesli:fix/rollup-config-plugins-rolldown-type
Sep 2, 2026
Merged

pi0 merged 3 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 #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

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 27caac7d-2972-4d99-8d0c-134e30f48dfd

📥 Commits

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

📒 Files selected for processing (2)
  • src/build/rollup/dev.ts
  • src/build/rollup/prod.ts

📝 Walkthrough

Walkthrough

RollupConfig now accepts Rollup and Rolldown plugin types. Development and production Rollup paths resolve Rollup through importRollup(nitro) and cast configurations to RollupOptions.

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 use Nitro-aware Rollup resolution and 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 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.
Title check ✅ Passed The title follows Conventional Commits syntax with the fix(types): prefix and accurately describes the plugin type widening.
Description check ✅ Passed The description clearly explains the Vite 8/Rolldown plugin type incompatibility and the changes made to resolve it.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 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 Resolved
@pi0 pi0 changed the title fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins [v3] fix(types): widen RollupConfig.plugins to accept rolldown-typed plugins Sep 2, 2026

@pi0 pi0 left a comment

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.

Thanks ❤️

…nfig-plugins-rolldown-type

# Conflicts:
#	src/build/rollup/prod.ts
@pi0
pi0 merged commit e940be6 into nitrojs:main Sep 2, 2026
9 of 11 checks passed
@dargmuesli
dargmuesli deleted the fix/rollup-config-plugins-rolldown-type branch September 2, 2026 17:53
@pi0x pi0x mentioned this pull request Sep 3, 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

2 participants