fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins [v2] - #4484
fix(types): widen RollupConfig.plugins to accept Rolldown-typed plugins [v2]#4484dargmuesli wants to merge 1 commit into
Conversation
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 is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
commit: |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Summary
Fixes #4482.
Vite 8 changed its own
Plugintype toextends Rolldown.Plugin<A>(Vite now bundles Rolldown as its internal bundler instead of Rollup+esbuild). Any plugin factory typed against Vite'sPlugin, e.g.@vitejs/plugin-vue'svue(), is therefore now structurally a Rolldown plugin.RollupConfig.pluginsis typed against therolluppackage's ownPlugin, so passing a Vite 8 plugin there no longer type-checks.This widens
pluginsto accept either bundler's plugin shape, and adds a narrowas RollupOptionscast at the two places that call the actualrolluppackage (rollup.rollup(),rollup.watch()), which still need the strict, Rollup-only type.Note: this targets
v2, companion PR formainalready open there: #4483.Changes
src/types/rollup.ts:RollupConfig.pluginsis nowRollupInputOptions["plugins"] | RolldownInputOptions["plugins"]instead of being locked to Rollup's own type.src/core/build/prod.ts/src/core/build/dev.ts: castrollupConfigtoRollupOptionsat therollup.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-anyparameters 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: addedrolldownas a type-only devDependency and externalized it (plus its own type-only transitives,@oxc-project/typesand@rolldown/pluginutils) in theunbuildconfig so it isn't flagged as an implicit bundle dependency.