Skip to content

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

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

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

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. RollupConfig.plugins is typed against the rollup package's own Plugin, so passing a Vite 8 plugin there no longer type-checks.

This widens plugins to accept either bundler's plugin shape, and adds a narrow as RollupOptions cast at the two places that call the actual rollup package (rollup.rollup(), rollup.watch()), which still need the strict, Rollup-only type.

Note: this targets v2, companion PR for main already open there: #4483.

Changes

  • src/types/rollup.ts: RollupConfig.plugins is now RollupInputOptions["plugins"] | RolldownInputOptions["plugins"] instead of being locked to Rollup's own type.
  • src/core/build/prod.ts / src/core/build/dev.ts: cast rollupConfig to RollupOptions at the rollup.rollup() / rollup.watch() call sites, which still need the strict Rollup type.
  • src/presets/deno/preset-legacy.ts: the widened union weakens contextual type inference for inline plugin object literals, which surfaced three implicit-any parameters in this preset's raw rollup plugins. Added explicit parameter types (resolveId(id: string), renderChunk(code: string), handler(code: string, chunk: RenderedChunk)) to restore them.
  • package.json / build.config.ts: added rolldown as a type-only devDependency and externalized it (plus its own type-only transitives, @oxc-project/types and @rolldown/pluginutils) in the unbuild config so it isn't flagged as an implicit bundle dependency.

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.
Widen the public type and keep the two real rollup() call sites strict via
a local cast.

The widened union weakens contextual inference for inline plugin object
literals, which surfaced implicit-any params in the Deno legacy preset's
raw rollup plugins; added explicit annotations there. Also added rolldown
as a type-only devDependency (import type only) and externalized it (plus
its own transitives) in the unbuild config so it isn't flagged as an
implicit bundle dependency.

Fixes nitrojs#4482
@dargmuesli
dargmuesli requested a review from pi0 as a code owner July 27, 2026 01:38
@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

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e953377-48cc-455b-b947-1b59caf9ca8a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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/nitropack@4484

commit: c6d05ad

@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 [v2] Jul 27, 2026
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedrolldown@​1.2.0911007898100

View full report

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.

1 participant