Summary
We've landed several experimental features in @vitejs/plugin-rsc that currently lack dedicated test cases. We should add tests to exercise these code paths and ensure they work correctly.
Features needing test coverage
1. onClientReference callback (#1065)
The new setOnClientReference API allows frameworks to be notified when client reference dependencies are loaded during SSR.
import { setOnClientReference, type OnClientReference } from '@vitejs/plugin-rsc/ssr'
const callback: OnClientReference = ({ id, deps }) => {
// id: client reference module id
// deps: { js: string[], css: string[] }
}
setOnClientReference(callback)
Test cases needed:
- Callback is invoked when a client reference is accessed during SSR
- Callback receives correct
id and deps (both js and css arrays)
- Callback is called on every access (not memoized)
setRequireModule with onLoad callback works correctly
2. cssLinkPrecedence option (#1064)
The new cssLinkPrecedence option controls whether CSS links use React's precedence attribute.
rsc({
cssLinkPrecedence: false, // disable React's precedence attribute on CSS links
})
Test cases needed:
- When
true (default): CSS links include precedence attribute
- When
false: CSS links are rendered without the precedence attribute
- Both
generateResourcesCode and preloadDeps respect the setting
Related PRs
Summary
We've landed several experimental features in
@vitejs/plugin-rscthat currently lack dedicated test cases. We should add tests to exercise these code paths and ensure they work correctly.Features needing test coverage
1.
onClientReferencecallback (#1065)The new
setOnClientReferenceAPI allows frameworks to be notified when client reference dependencies are loaded during SSR.Test cases needed:
idanddeps(bothjsandcssarrays)setRequireModulewithonLoadcallback works correctly2.
cssLinkPrecedenceoption (#1064)The new
cssLinkPrecedenceoption controls whether CSS links use React'sprecedenceattribute.Test cases needed:
true(default): CSS links includeprecedenceattributefalse: CSS links are rendered without theprecedenceattributegenerateResourcesCodeandpreloadDepsrespect the settingRelated PRs
precedenceattribute #1064 - feat(plugin-rsc): allow to control whether CSS links use React'sprecedenceattribute