test: reach parity with upstream React Router corpus coverage - #127
Conversation
Port the remaining upstream suites and close the plugin gap they exposed: - rsc-nonce-test: CSP nonces in RSC framework and data modes. The SSR entries pass the nonce to the Flight client too, because React Router does not forward it and the rspack Flight client preloads client reference chunks with script tags. - plugin-order-validation-test: the MDX-before-React-Router rule this plugin enforces, in classic and RSC framework modes. The Vite plugin-rsc ordering cases have no Rsbuild equivalent. - loader-context-test: un-skipped. A custom dev server builds its RouterContextProvider from the context instance the server build exposes through entry.module, using customServer mode and loadReactRouterServerBuild; documented in the README. - basename-test: the base/basename startup validation case is marked not applicable with the reason; Rsbuild serves a basename outside base, and the "works when basename does not start with base" cases cover it. Plugin fix: a user-provided app/entry.ssr.tsx in RSC framework mode failed the build because the RSC entry template imported its own SSR template directly, leaving the template compiled as React Server code. The template now imports the resolved SSR entry through the virtual/react-router/unstable_rsc/entry-ssr alias. Not portable: vite-plugin-cloudflare-test (Vite Cloudflare dev plugin); the cloudflare example keeps its own end-to-end coverage. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Benchmark results
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3b5178e08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ```js | ||
| // server.js | ||
| getLoadContext: async () => { | ||
| const { valueContext } = (await build()).entry.module; |
There was a problem hiding this comment.
Keep
build callable in production
When this getLoadContext is added to the complete custom-server example above and the documented production start command is used, build is the resolved ServerBuild object assigned on lines 426–428, not a function, so the first request throws TypeError: build is not a function. Keep the production value behind the same callable interface used in development, as the new integration fixture does, or branch here before accessing entry.module.
Useful? React with 👍 / 👎.
| // server.js | ||
| getLoadContext: async () => { | ||
| const { valueContext } = (await build()).entry.module; | ||
| return new RouterContextProvider([[valueContext, 'value']]); |
There was a problem hiding this comment.
Import RouterContextProvider in the server example
When users add this fragment to the custom-server example immediately above, handling a request fails with ReferenceError: RouterContextProvider is not defined because that example's imports include only createRequestHandler from the React Router packages. Add the corresponding react-router import to the documented server setup.
Useful? React with 👍 / 👎.
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Closes the remaining coverage gaps between this corpus and upstream React Router's integration suite, and fixes the one plugin bug the work exposed.
Ported suites:
createFromReadableStream, since React Router does not forward it and the rspack Flight client preloads client-reference chunks with<script>tags.rsbuild:mdxbefore React Router rule this plugin already enforces, in classic and RSC framework modes. Upstream's@vitejs/plugin-rscordering cases have no Rsbuild equivalent.RouterContextProviderfrom the context instance the server build exposes viabuild.entry.module(re-exported fromapp/entry.server.tsx), usingcustomServer: trueandloadReactRouterServerBuild. Documented in the README under Custom Server Setup.Plugin fix (patch changeset): a user-provided
app/entry.ssr.tsxin RSC framework mode failed the build with "You're importing a module that depends on react-dom/server" because the RSC entry template imported its own SSR template by relative path, so the override entered the SSR layer while the template kept being compiled as React Server code. The template now imports the resolved SSR entry through avirtual/react-router/unstable_rsc/entry-ssralias.Remaining RSC
test.skip/test.fixmeentries in the corpus all mirror upstream's own skips. The only upstream suite still not ported isvite-plugin-cloudflare-test, which exercises the Vite Cloudflare dev plugin; the cloudflare example keeps its own end-to-end coverage.Verification
pnpm typecheck,pnpm build,pnpm exec rstest run(all pass; new unit test for the alias)🤖 Generated with Claude Code