Skip to content

test: reach parity with upstream React Router corpus coverage - #127

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
test/corpus-parity
Sep 4, 2026
Merged

test: reach parity with upstream React Router corpus coverage#127
ScriptedAlchemy merged 1 commit into
mainfrom
test/corpus-parity

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator

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:

  • rsc-nonce-test (RSC framework + RSC data): CSP nonces on every document script under a strict policy. The user SSR entries also hand the nonce to createFromReadableStream, since React Router does not forward it and the rspack Flight client preloads client-reference chunks with <script> tags.
  • plugin-order-validation-test: the rsbuild:mdx before React Router rule this plugin already enforces, in classic and RSC framework modes. Upstream's @vitejs/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 via build.entry.module (re-exported from app/entry.server.tsx), using customServer: true and loadReactRouterServerBuild. Documented in the README under Custom Server Setup.
  • basename-test: the Vite base/basename startup validation case is marked not applicable with the reason. Rsbuild serves a basename outside base, which the three "works when basename does not start with base" cases already prove.

Plugin fix (patch changeset): a user-provided app/entry.ssr.tsx in 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 a virtual/react-router/unstable_rsc/entry-ssr alias.

Remaining RSC test.skip/test.fixme entries in the corpus all mirror upstream's own skips. The only upstream suite still not ported is vite-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)
  • Locally: nonce (3), plugin order (2), loader context (1), client-version (4), CSRF (2), rsc-framework, rsc-css, rsc-nojs, rsc-prerender suites all pass
  • Examples rsc-mode, react-router-8, default-template build

🤖 Generated with Claude Code

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T23:45:59.870146Z d3b5178 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/rsbuild-plugin-react-router@d3b5178

commit: d3b5178

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

Case Base Head Delta
build-256-ssr 2075.5 ms 2074.6 ms -0.0%
dev-48-ssr 903.7 ms 912.0 ms +0.9%

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread README.md
```js
// server.js
getLoadContext: async () => {
const { valueContext } = (await build()).entry.module;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread README.md
// server.js
getLoadContext: async () => {
const { valueContext } = (await build()).entry.module;
return new RouterContextProvider([[valueContext, 'value']]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@codspeed-hq

codspeed-hq Bot commented Sep 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 1 untouched benchmark
⏩ 2 skipped benchmarks1


Comparing test/corpus-parity (d3b5178) with main (93c1333)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (16130d3) during the generation of this report, so 93c1333 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ScriptedAlchemy
ScriptedAlchemy merged commit 3ecef1b into main Sep 4, 2026
9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the test/corpus-parity branch September 4, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant