Skip to content

Add test coverage for experimental plugin-rsc features #1071

@hi-ogawa

Description

@hi-ogawa

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions