mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #685] [CLOSED] fix: exclude react-server-dom-webpack from rsc/ssr dep optimizer #769
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#769
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/685
Author: @NathanDrake2406
Created: 3/25/2026
Status: ❌ Closed
Base:
main← Head:fix/rsc-streaming-dep-optimizer📝 Commits (1)
8cc6146fix: exclude react-server-dom-webpack from rsc/ssr dep optimizer📊 Changes
2 files changed (+33 additions, -2 deletions)
View changed files
📝
packages/vinext/src/index.ts(+16 -2)📝
tests/app-router.test.ts(+17 -0)📄 Description
Summary
react-server-dom-webpackfromoptimizeDepsin both therscandssrenvironments, preventing dep optimizer re-runs from invalidating the Flight client module mid-requestProblem
When an App Router app has multiple routes that import different third-party packages, Vite's dep optimizer can re-run mid-request as it lazily discovers new user-land dependencies. A dep optimizer re-run re-bundles all pre-bundled modules, creating fresh module instances. In-flight RSC streams crash with
chunk.reason.enqueueModel is not a functionbecause Flight chunk objects created by the oldReactPromiseconstructor don't match functions from the new module instance.Fix
Excluding
react-server-dom-webpackfrom the dep optimizer means it's loaded through Vite's regular transform pipeline (which works correctly withnoExternal: true) and is completely immune to re-optimisation invalidation. Theexcludeintentionally overrides the RSC plugin'sincludefor this package (Viteexcludetakes priority overinclude), ensuring the Flight protocol modules live outside the dep optimizer's lifecycle.Both the
rscandssrenvironments are covered — the RSC side produces the Flight stream (renderToReadableStream) and the SSR side consumes it (createFromReadableStream), so both need protection from module invalidation.Closes #672
Test plan
react-server-dom-webpackis inoptimizeDeps.excludefor bothrscandssrenvironmentsoptimizeDeps.entriesandoptimizeDeps.includetests still pass🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.