perf(rsc): skip scans without server references#1269
Open
TheAlexLichter wants to merge 1 commit into
Open
Conversation
hi-ogawa
reviewed
Jun 25, 2026
hi-ogawa
left a comment
Contributor
There was a problem hiding this comment.
The idea is good to explore, but iirc, there is an issue with just building rsc -> client -> ssr in some framework.
Also, I'm not familiar with Vinext's own use client/server scanning, but we should confirm if that covers node_modules since user package can include the directive too.
We've had discussed some build shortcuts for tanstack with @schiller-manuel but I found we somehow needed ssr -> rsc -> client -ssr.
For framework level customization, we already have customBuildApp: false. The example looks like
vite-plugin-react/packages/plugin-rsc/examples/no-ssr/vite.config.ts
Lines 10 to 42 in 1d91f40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
serverReferences?: booleanoption to@vitejs/plugin-rsc, letting frameworks that can prove an app has no React"use server"actions skip the expensive reference-analysis builds.RSC frameworks often already know their app roots, route files, and source conventions, so they can conservatively scan and set either
rsc({ serverReferences: false })or top-levelrsc: { serverReferences: false }.This makes the optimization broadly useful across plugin-rsc-based frameworks.
Framework Wiring Points
packages/vinext/src/index.tsserverReferences: earlyMayContainServerActions.packages/waku/src/lib/vite-plugins/combined-plugins.tsserverReferences: mayContainServerActionsinside its existingrsc({ ... })call.packages/react-start-rsc/src/plugin/vite.tsserverReferencesto the existing top-level returnedrsc: { ... }config.packages/react-router-dev/vite/rsc/plugin.tsrsc: { serverReferences: mayContainServerActions }beside its environment config.Safety
Frameworks should only set
serverReferences: falsewhen they can conservatively determine that no React"use server"references exist.If scanning fails, source roots are ambiguous, or server actions may come from transformed dependencies, the safe default is to leave
serverReferencesenabled.Benchmark
In my vinext benchmark I got a difference from 191.3 ms (13.73% improvement).
Alternatives