Skip to content

feat(rsc): ability to preserve decoded server references#1253

Open
james-elicx wants to merge 7 commits into
vitejs:mainfrom
james-elicx:codex/preserve-decoded-server-references
Open

feat(rsc): ability to preserve decoded server references#1253
james-elicx wants to merge 7 commits into
vitejs:mainfrom
james-elicx:codex/preserve-decoded-server-references

Conversation

@james-elicx

@james-elicx james-elicx commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Extracts the core, React, and server-manifest reference-preservation changes from #1246.


RSC frameworks may need to cache, proxy, or compose Flight fragments before sending them back to the browser. A concrete example is a use cache wrapper that stores a rendered product card as a Flight stream and later replays it into a new RSC response.

That cached fragment can still contain a server action, like an “add to cart” action owned by the framework/runtime. During replay, the cache layer should not have to import the action implementation from the app bundler manifest; it only needs to keep the action reference opaque so the browser can call it through the normal action path later.

This adds an opt-in serverReferences: "preserve" decode mode for that case. It also preserves and deduplicates server-reference export names when transforms share a module, and adds an experimental serverReferenceMarkers option so preceding transforms can mark modules whose server-reference metadata must survive the "use server" HMR cleanup pass.

The e2e caches a Flight stream containing a framework-owned server action reference, replays that cached stream, and verifies the replayed client UI can still invoke the action.

@james-elicx james-elicx changed the title feat(rsc): preserve decoded server references feat(rsc): ability to preserve decoded server references Jun 18, 2026
@james-elicx james-elicx marked this pull request as ready for review June 30, 2026 23:30
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