mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #1020] [MERGED] fix(rsc): exclude client shims from dep optimization #1024
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#1024
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/1020
Author: @NathanDrake2406
Created: 5/2/2026
Status: ✅ Merged
Merged: 5/2/2026
Merged by: @james-elicx
Base:
main← Head:nathan/issue-1008-rsc-shim-optdeps📝 Commits (4)
5b784f4fix(rsc): exclude client shims from dep optimization5358c4dUpdate rsc-client-shim-excludes.ts49c894bUpdate rsc-client-shim-excludes.tsf1c5e41Update build-optimization.test.ts📊 Changes
3 files changed (+63 additions, -6 deletions)
View changed files
📝
packages/vinext/src/index.ts(+14 -6)➕
packages/vinext/src/plugins/rsc-client-shim-excludes.ts(+33 -0)📝
tests/build-optimization.test.ts(+16 -0)📄 Description
What this changes
Adds vinext's known RSC client shim subpaths to the Vite dep optimizer exclude set for App Router projects. The exclude set is merged into the top-level, RSC, SSR, and client optimizer configs while preserving user-provided excludes and
serverExternalPackages.Closes #1008.
Why
Next.js treats public App Router APIs such as
next/link,next/form, andnext/scriptas client modules:next/link:github.com/vercel/next.js@ae61573e06/packages/next/src/client/app-dir/link.tsx (L1)next/form:github.com/vercel/next.js@ae61573e06/packages/next/src/client/app-dir/form.tsx (L1)next/script:github.com/vercel/next.js@ae61573e06/packages/next/src/client/script.tsx (L1)next/linkin Server Components:github.com/vercel/next.js@ae61573e06/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts (L272-L286)vinext matches that shape with client shims. In dev,
@vitejs/plugin-rscrecords bare package sources resolved from the RSC graph and generatesclient-package-proxy/<source>modules from that metadata. The relevant source path is here: https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-rsc/src/plugin.tsBefore this change, vinext excluded the bare
vinextpackage but notvinext/shims/*. That leaves known client shim subpaths eligible for dep optimization, which can make the package source recorded by plugin-rsc diverge from the optimized module that produced the client reference metadata. The result is theclientReferenceMetaMapmiss reported in #1008.Approach
Setexpression through the config hook.error-boundary,form,layout-segment-context,link,script, andslot.Validation
vp check packages/vinext/src/index.ts packages/vinext/src/plugins/rsc-client-shim-excludes.ts tests/build-optimization.test.tsvp test run tests/build-optimization.test.ts -t "optimizeDeps.exclude"vp test run tests/app-router.test.ts -t "renders next/link"Risks / follow-ups
The main maintenance risk is list drift: if vinext adds another top-level
"use client"shim that can be imported asvinext/shims/<name>from the RSC graph, it should be added to the helper list.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.