feat(vite): plugin-rsc 0.5.31 alignment — exports-map client-ref dedup, manager API adaptation, react 19.2.8 - #816
Merged
Conversation
…p, manager API adaptation, react 19.2.8
Dev-mode client-reference dedup now resolves a deep third-party "use
client" module to its PRECISE public subpath through the package's exports
map (single-star patterns included, every candidate verified by resolving
back to the identical file, cached per source) instead of rewriting to the
bare package root — which silently dropped any symbol the root did not
barrel-export. The root rewrite survives only as a documented lossy
fallback when no public subpath maps to the file.
expose-action-id adopts the public getPluginApi() and tolerates both
plugin-rsc manager shapes (serverReferences.metaMap Map and the legacy
serverReferenceMetaMap record), failing loudly with a named error if
neither matches — groundwork for the #1310 claims API (pluggable server
functions, released in 0.5.31, now the pinned catalog version with the
quarantine exemption updated). react/react-dom peers and catalog move to
19.2.8.
New e2e surfaces, dev + production in BOTH test-app and cloudflare-basic:
client-package-resolution (rango-e2e-deep-context-lib fixture package with
non-barrel deep exports pins the dedup rework, red case = NOT_FOUND
context) and head-script-preload (dedicated playwright.preload.config.ts —
isolated ports and vite cache, RANGO_E2E_HEAD_SCRIPTS=preload threads
rango({ headScripts }) — pins the inline-bootstrap + modulepreload
document shape), wired into root test:e2e and both CI matrix jobs.
segment-codec tests pin the preserveServerReferences decoder option
shipped in #584 via inspectable mocks.
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.
Problem
Three consumer-observable gaps, one dependency alignment:
"use client"modules live at deep subpaths (lib/context, not re-exported from the package root), the dev-mode dedup rewrote the module to the bare package root — and every symbol the root did not barrel-export vanished silently. Consumers saw context values render as theirNOT_FOUNDdefaults with no error.expose-action-idwas coupled to a private plugin-rsc shape. It reached intomanager.serverReferenceMetaMapby structure; plugin-rsc 0.5.31 introducesmanager.serverReferences(the #1310 claims API), and the old lookup would silently miss it.headScripts: "preload"had zero e2e coverage. The mode changes the document's script strategy (inline bootstrap + modulepreload hints instead of executing head scripts) and nothing pinned it.^0.5.31(carries #1310 — pluggable server-function registration) and react19.2.8peers/catalog.Before / after
Before: dev dedup rewrote the module to
rango-e2e-deep-context-lib(the root), the context symbol resolved toundefined, and the page rendered the provider-less default (NOT_FOUND).After: dedup resolves the file through the package's
exportsmap to the exact public subpath (rango-e2e-deep-context-lib/context) and re-exports from that — the context identity dedupes correctly and the provided value renders.End-to-end example
The fixture package
__test_packages__/rango-e2e-deep-context-libis the realistic shape: a component library whoseexportsmap exposes./contextwith a"use client"provider/consumer pair that is not barrel-exported from the root. A server component renders the provider around a client consumer; the e2e asserts the provided value appears in server HTML and survives hydration, dev + production, in both test-app and cloudflare-basic.Semantics
optimizeDeps.excludeserverReferences.metaMapserverReferenceMetaMappresentCode changes
src/vite/plugins/client-ref-dedup.ts— exports-map public-specifier resolution (star patterns, resolve-back verification, per-source caching), encoded-specifier virtual modules; the lossy root fallback kept and documented.src/vite/plugins/expose-action-id.ts— publicgetPluginApi(), dual manager-shape support with loud failure.playwright.preload.config.ts(router + cloudflare-basic) — isolated ports (checkoutPortOffset), isolated vite cache,RANGO_E2E_HEAD_SCRIPTS=preload→rango({ headScripts })..github/workflows/e2e.yml— preload-dev / preload-production matrix entries in both jobs with--config/--no-depsthreading; roottest:e2eruns both new surfaces.pnpm-workspace.yaml/package.json— plugin-rsc^0.5.31(quarantine exemption updated with the review note), react19.2.8.src/cache/__tests__/segment-codec.test.ts— pins thepreserveServerReferencesdecoder option (fix(router): preserve embedded server actions across cache and prerender hits #584) via inspectable mocks.Test plan
test:unit:allgreen on 0.5.31 (includes the four touched suites, 79 tests directly).client-package-resolution: dev + production, test-app AND cloudflare-basic (8/8) — red case demonstrated by the fixture'sNOT_FOUNDdefault.head-script-preload: warmup + dev + production pairs in both apps (5/5 each) — pins inline bootstrap, no executing external head scripts, modulepreload hints for client references.action-id-resolution(production) on 0.5.31 — 10/10, exercises the manager-shape adaptation at build time.Notes
config.createResolveris deprecated in Vite 8 — the plugin should move to the environment-scoped resolver before the next Vite major; left as a follow-up to keep this PR mechanical.manager.serverReferences.{resolve,replaceClaim,deleteClaim}) is the groundwork for named inline actions ("use server <name>"); this PR only adapts the read side.