Skip to content

feat(vite-plugin-core): Spport both Vite 7 (rollupOptions) and Vite 8 (rolldownOptions)#6955

Merged
birkskyum merged 5 commits intomainfrom
make-plugin-compat-with-rolldownoptions
Mar 17, 2026
Merged

feat(vite-plugin-core): Spport both Vite 7 (rollupOptions) and Vite 8 (rolldownOptions)#6955
birkskyum merged 5 commits intomainfrom
make-plugin-compat-with-rolldownoptions

Conversation

@birkskyum
Copy link
Member

@birkskyum birkskyum commented Mar 17, 2026

By runtime checking if rollup or rolldown is used, the plugin can now read/write to rollupOptions or rolldownOptions, thus support both vite 7 and 8

Summary by CodeRabbit

  • New Features
    • Added automatic Vite version detection to support both Vite 7 and Vite 8, ensuring seamless compatibility with your installed version without requiring manual configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

This PR adds runtime detection for Vite version compatibility, supporting both Vite 7 (rollupOptions) and Vite 8 (rolldownOptions) through utility functions that abstract bundler option access based on the detected bundler.

Changes

Cohort / File(s) Summary
Vite Bundler Compatibility
packages/start-plugin-core/src/utils.ts
Introduces runtime bundler detection with isRolldown variable, bundlerOptionsKey for dynamic key selection, and getBundlerOptions() utility to abstract accessing bundler-specific build options from either Rolldown or Rollup configurations.
Plugin Updates
packages/start-plugin-core/src/plugin.ts, packages/start-plugin-core/src/preview-server-plugin/plugin.ts
Imports new bundler utilities and replaces hard-coded rollupOptions references with dynamic bundlerOptionsKey and getBundlerOptions() calls for both client and server build configuration access.
Changelog
.changeset/rolldownoptions-compat.md
Adds changeset documenting a minor version release for bundler option compatibility between Vite versions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopping through versions with bundler delight,
Rolldown and Rollup now work just right!
Runtime detection, a clever small trick,
Vite 7 and 8, compatibility quick!
One key to rule them, utilities shine,
This compatibility layer? Absolutely fine!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately reflects the main change: adding support for both Vite 7 (rollupOptions) and Vite 8 (rolldownOptions) with runtime detection.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch make-plugin-compat-with-rolldownoptions
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Mar 17, 2026

View your CI Pipeline Execution ↗ for commit a65903e

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 9m 32s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 28s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-17 16:37:28 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

🚀 Changeset Version Preview

1 package(s) bumped directly, 3 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/start-plugin-core 1.166.15 → 1.167.0 Changeset

🟩 Patch bumps

Package Version Reason
@tanstack/react-start 1.166.15 → 1.166.16 Dependent
@tanstack/solid-start 1.166.15 → 1.166.16 Dependent
@tanstack/vue-start 1.166.15 → 1.166.16 Dependent

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@6955

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@6955

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@6955

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@6955

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@6955

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@6955

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@6955

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@6955

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@6955

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@6955

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@6955

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@6955

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@6955

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@6955

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@6955

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@6955

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@6955

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@6955

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@6955

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@6955

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@6955

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@6955

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@6955

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@6955

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@6955

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@6955

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@6955

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@6955

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@6955

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@6955

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@6955

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@6955

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@6955

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@6955

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@6955

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@6955

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@6955

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@6955

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@6955

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@6955

commit: a65903e

@github-actions
Copy link
Contributor

Bundle Size Benchmarks

  • Commit: 3bc18d462345
  • Measured at: 2026-03-17T16:28:59.067Z
  • Baseline source: history:d6371529b5ab
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.61 KiB 0 B (0.00%) 276.07 KiB 76.12 KiB ▁▁▁▁▁▁▁▁███
react-router.full 90.65 KiB 0 B (0.00%) 286.28 KiB 78.68 KiB ▁▁▁▁▁▁▁▁███
solid-router.minimal 37.14 KiB 0 B (0.00%) 111.38 KiB 33.29 KiB ▁▁▁▁▁▁▁▁███
solid-router.full 41.36 KiB 0 B (0.00%) 124.18 KiB 37.12 KiB ▁▁▁▁▁▁▁▁███
vue-router.minimal 52.99 KiB 0 B (0.00%) 151.41 KiB 47.65 KiB ▁▁▁▁▁▁▁▁███
vue-router.full 57.69 KiB 0 B (0.00%) 166.34 KiB 51.60 KiB ▁▁▁▁▁▁▁▁███
react-start.minimal 101.99 KiB 0 B (0.00%) 324.08 KiB 88.20 KiB ▁▁▁▁▁▁▁▁███
react-start.full 105.33 KiB 0 B (0.00%) 333.89 KiB 91.02 KiB ▁▁▁▁▁▁▁▁███
solid-start.minimal 51.24 KiB 0 B (0.00%) 157.82 KiB 45.28 KiB ▁▁▁▁▁▁▁▁███
solid-start.full 56.53 KiB 0 B (0.00%) 173.32 KiB 49.72 KiB ▁▁▁▁▁▁▁▁███

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/start-plugin-core/src/utils.ts`:
- Around line 15-16: Replace the loose any usage in getBundlerOptions by adding
precise types for the build parameter and return (e.g., RollupOptions |
RolldownOptions) and explicitly pick the correct option based on a detected
bundler flag instead of relying on the nullish coalescing; inside
getBundlerOptions detect whether to use rolldown by checking a bundler indicator
(isRolldown) and return build.rolldownOptions when isRolldown is true otherwise
return build.rollupOptions, updating the function signature and imports/types
accordingly to eliminate all any occurrences (reference: getBundlerOptions,
build.rolldownOptions, build.rollupOptions, isRolldown).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ddaf4d44-b4a4-422a-9920-a7bc915b8ab7

📥 Commits

Reviewing files that changed from the base of the PR and between 3bc18d4 and a65903e.

📒 Files selected for processing (4)
  • .changeset/rolldownoptions-compat.md
  • packages/start-plugin-core/src/plugin.ts
  • packages/start-plugin-core/src/preview-server-plugin/plugin.ts
  • packages/start-plugin-core/src/utils.ts

Comment on lines +15 to +16
export function getBundlerOptions(build: any): any {
return build?.rolldownOptions ?? build?.rollupOptions
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Vite 7 and Vite 8, when both build.rollupOptionsandbuild.rolldownOptionsare provided, which one is actually used by the active bundler, and isrolldownVersionon thevite module an official runtime discriminator?

💡 Result:

  • Vite 7 (regular vite): the active bundler is Rollup, so only build.rollupOptions is used. (There is no build.rolldownOptions config API in Vite 7 docs; Rolldown support lives in the separate rolldown-vite package.)[3]

  • Vite 8: the active bundler is Rolldown.[1] The config field build.rollupOptions is deprecated and is just an alias of build.rolldownOptions.[2] So the active bundler effectively uses build.rolldownOptions; build.rollupOptions does not represent a separate, independently-applied set of options in Vite 8.[2]

  • Is vite.rolldownVersion an official runtime discriminator? Yes—Vite’s official Rolldown integration guide explicitly documents checking the existence of the rolldownVersion export (and/or this.meta.rolldownVersion) to detect when running under rolldown-vite.[3]

Sources: [1] [2] [3]


🏁 Script executed:

# First, let's see the full context of the file around lines 15-16
cat -n packages/start-plugin-core/src/utils.ts | head -30

Repository: TanStack/router

Length of output: 1309


🏁 Script executed:

# Also check what imports are available
head -20 packages/start-plugin-core/src/utils.ts

Repository: TanStack/router

Length of output: 716


🏁 Script executed:

# Search for isRolldown definition and usage
rg "isRolldown" packages/start-plugin-core/src/

Repository: TanStack/router

Length of output: 234


🏁 Script executed:

# Check if vite types are available in the project
rg "from.*vite" packages/start-plugin-core/src/ | head -10

Repository: TanStack/router

Length of output: 1180


Remove any types and bind getBundlerOptions to detected bundler.

The function currently uses loose any types, violating the TypeScript strict mode requirement. Additionally, while the ?? logic happens to work (Vite 7 lacks rolldownOptions, Vite 8 treats rollupOptions as an alias), explicitly binding to isRolldown improves clarity and maintainability.

Proposed fix
+type BuildWithBundlerOptions = {
+  rollupOptions?: vite.RollupOptions
+  rolldownOptions?: vite.RollupOptions
+}
+
 /** Read `build.rollupOptions` or `build.rolldownOptions` from a build config. */
-export function getBundlerOptions(build: any): any {
-  return build?.rolldownOptions ?? build?.rollupOptions
+export function getBundlerOptions(
+  build?: BuildWithBundlerOptions,
+): vite.RollupOptions | undefined {
+  return isRolldown ? build?.rolldownOptions : build?.rollupOptions
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/start-plugin-core/src/utils.ts` around lines 15 - 16, Replace the
loose any usage in getBundlerOptions by adding precise types for the build
parameter and return (e.g., RollupOptions | RolldownOptions) and explicitly pick
the correct option based on a detected bundler flag instead of relying on the
nullish coalescing; inside getBundlerOptions detect whether to use rolldown by
checking a bundler indicator (isRolldown) and return build.rolldownOptions when
isRolldown is true otherwise return build.rollupOptions, updating the function
signature and imports/types accordingly to eliminate all any occurrences
(reference: getBundlerOptions, build.rolldownOptions, build.rollupOptions,
isRolldown).

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 3 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing make-plugin-compat-with-rolldownoptions (a65903e) with main (d637152)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (3bc18d4) during the generation of this report, so d637152 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@birkskyum birkskyum changed the title feat: make start vite plugin compatitble with rolldownOptions feat: make start vite plugin compatitble with both rollup/rolldownOptions Mar 17, 2026
@birkskyum birkskyum changed the title feat: make start vite plugin compatitble with both rollup/rolldownOptions feat(start-plugin-core): add compat for both rollup/rolldownOptions Mar 17, 2026
@birkskyum birkskyum changed the title feat(start-plugin-core): add compat for both rollup/rolldownOptions feat: add support for rolldownOptions in vite plugin Mar 17, 2026
@birkskyum birkskyum changed the title feat: add support for rolldownOptions in vite plugin feat(vite-plugin-core): Spport both Vite 7 (rollupOptions) and Vite 8 (rolldownOptions) Mar 17, 2026
@birkskyum birkskyum merged commit 6651473 into main Mar 17, 2026
17 checks passed
@birkskyum birkskyum deleted the make-plugin-compat-with-rolldownoptions branch March 17, 2026 17:35
@Sheraff
Copy link
Contributor

Sheraff commented Mar 19, 2026

I think this PR might have broken the SSR benchmarks. They are marked as skipped here

⏩ 3 skipped benchmarks

Looking at the commit history, this PR's merge commit seems to be the 1st with skipped benchmarks.

They seem to fail during the build

> vite build --config ./solid/vite.config.ts
vite v7.3.1 building client environment for production...
✓ 0 modules transformed.
✗ Build failed in 91ms
error during build:
Could not resolve entry module "solid/index.html".

Maybe an issue with the rolldown detection? GPT tracked it down to this #6984. The fix is ugly, but we can see if it does restore the benchmarks. Well the fix doesn't work, but it still seems to be coming from this PR...

BTW: if it fails on the benchmarks, there is a chance it fails in real apps too, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants