feat: support React Router 8 compatibility#74
Conversation
commit: |
Benchmark ResultsCompared PR head Reading benchmark confidenceRaw deltas are always shown. The signal label only indicates whether the observed median delta is larger than a robust run-to-run noise band; it does not erase or replace the measurement. The noise band is the larger of 2% or two combined robust standard deviations estimated from each side's relative median absolute deviation (rMAD). Fewer than three finite samples is reported as insufficient data. An inconclusive result should be rerun or investigated from the uploaded raw samples before drawing a performance conclusion.
Dev Rollup
Production Build BenchmarksRendered 7 production build benchmarks.
ci-small+ci-large Dev Fixture SummaryRendered 7 dev benchmark fixtures from the
large-355-ssr-esm Plugin Operations
synthetic-1024-ssr-esm Plugin Operations
synthetic-1024-ssr-esm-split Plugin Operations
synthetic-256-sourcemaps Plugin Operations
synthetic-256-ssr-esm Plugin Operations
synthetic-256-ssr-esm-split Plugin Operations
synthetic-48-ssr-esm Plugin Operations
Synthetic Rsbuild AppRendered 2 production build benchmarks.
Rendered 1 dev benchmark fixture from the embedded complex app.
Profile: |
…typing - one resolveAppPackagePath/getPackageVersion pair in plugin-utils (react-router version now resolved from the app, not the plugin install) - extract createRouteManifestItem from the dev-manifest effect and collapse the per-chunk module lookups - replace Awaited<ReturnType<...>>/Parameters<...>[5] gymnastics with the exported ReactRouterManifestForDev/RouteChunkManifestOptions types - type modePlan webOutput/webOptimization with Rspack config types and drop the as-const noise - dedupe classic server-build options, single rsc-option normalization, inline single-use query helpers, remove plugin factory indirection Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Transformed routes import UNSAFE_withComponentProps and friends from react-router, which only exist from 7.7.0; 7.13 is the lowest v7 line this plugin is tested against (main's previous floor). Widening the peer range to ^7.0.0 let 7.0-7.12 installs pass peer resolution and then fail every classic-mode build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Register the RSC request listener via the server.setup post-callback so it runs after compiled-asset and public-dir middlewares, making it the fallback for anything static serving declines - the same routing semantics as production. This removes the GET/POST and file-extension bypass heuristics that 404'd extension-ful resource routes (e.g. /sitemap.xml) and non-GET/POST resource routes in dev; only /__rsbuild_ internals bypass the handler now. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Wire the prerender config into the RSC mode plan and add an onAfterBuild step that replays upstream's RSC prerender pipeline against the built server bundle's fetch handler: emits <path>/index.html plus <path>.rsc flight payloads (_.rsc for the root), meta-refresh documents for redirects, raw bytes for resource routes, and __spa-fallback.html/.rsc for ssr:false builds. The RSC preview fixture now serves prerendered documents and the SPA fallback like upstream's configurePreviewServer. Classic-mode prerender is untouched. Vendored parity tests rsc/rsc-prerender-test.ts now pass 3/3. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
createReactRouterModePlan is now a thin dispatcher over createClassicModePlan / createRscModePlan with a narrow shared ModePlanContext, so each mode's planner owns only the inputs it uses instead of one 30-field options blob feeding both branches. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The sync script now carries a pinned upstream ref (4cf6e62d0cdf9d7f6e09b0ea10077d7fb0e1b438), refuses to sync from a dirty or mismatched source checkout (--update-pin adopts a new sha), and writes tests/react-router-framework/UPSTREAM.json recording the repository, sha, source dirs, file count, and adapter-owned overlay list. The README documents the pin-update flow and that everything outside the adapter-owned files is generated and must not be hand-edited. corpusVerified is false: 13 checked-in files drift from the pinned sha (a locally added rsc-framework-test.ts plus Rsbuild adaptations and small edits) - recorded in the manifest as an undeclared overlay to classify in a follow-up. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The corpus is repo-owned and rsbuild-adapted; UPSTREAM.json records provenance only. Delete the five checked-in template vite.config.ts files (the adapter generates rsbuild.config.ts and never reads them) and strip vite/@vitejs/@vanilla-extract/vite-plugin/@cloudflare/ vite-plugin/vite-tsconfig-paths entries from corpus package.jsons (never installed - the corpus is not a workspace package and the adapter rewrites fixture deps wholesale). No test file imports 'vite' at top level; remaining matches are fixture template strings the adapter converts. vite-env-only stays: fixture app code imports its macros. Verified: playwright smoke 7/7, test:core 490/490. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
RSC mode silently ignored buildEnd, presets, serverBundles, and subResourceIntegrity from react-router.config - a user's buildEnd hook never fired and serverBundles/SRI produced nothing with no signal. Upstream's RSC vite plugin rejects these with a validation error; assertReactRouterRscConfigSupport now does the same. allowedActionOrigins was also dropped in RSC mode even though react-router's matchRSCServerRequest supports it (upstream's default RSC entry drops it too). Expose it as a virtual/react-router/unstable_rsc/allowed-action-origins module and pass it through the entry template so action-origin restrictions apply. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The RSC mode plan pinned routeChunkConfig.splitRouteModules to false, so a configured 'enforce' never triggered chunk validation. Upstream's RSC vite plugin gates validation on config.splitRouteModules === 'enforce' while chunk splitting itself stays content-detected - pass the resolved config value through to match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The config factory in integration/helpers/vite.ts now emits rsbuild.config.ts content (pluginReactRouter/pluginReactRouterRSC + pluginReact, pluginMdx when needed) with real option mappings: base->output.assetPrefix, port->server.port+strictPort, assetsInlineLimit->output.dataUriLimit, assetsDir->output.distPath, vanilla-extract via @vanilla-extract/webpack-plugin (deterministic identifiers, realContentHash off, sideEffects workaround). ~35 inline vite.config fixture strings converted across 20+ test files; Vite-only suites (plugin-order validation, @cloudflare/vite-plugin, fs.allow) carry visible describe/test.skip with reasons. The vite-7/vite-8 template pair is collapsed to one (identical under rsbuild), halving template-parameterized suite runs. The adapter's vite.config interception is now a warn-loudly dead path (0 hits across all runs). Verified against captured baselines: no test that passed before fails after; vite-manifests (3), server-bundles dev/build-manifest, spa-mode manifest, and vanilla-extract no-JS suites (3) newly pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Route edits in classic dev now apply through react-refresh instead of full reloads, and loader/action changes trigger client revalidation: - src/dev-hmr.ts: resolves @rsbuild/plugin-react's react-refresh runtime, generates a dev-only HMR runtime virtual module, and maintains an HDR revision module that the dev runtime bumps when a node rebuild commits so the browser revalidates loader data. - route transforms gain a devHmr mode wrapping client route modules with refresh registration; dev-runtime-controller patches route metadata on the client and signals rebuild commits instead of forcing full reloads. - When the react-refresh runtime is absent (or in RSC/build mode), everything falls back to the previous full-reload behavior. Vendored parity tests vite-hmr-hdr-test.ts now pass 3/3 (previously 0/6 pre-template-collapse). vite-dev-test.ts guard: 12 passed, 4 pre-existing failures verified identical without this change. This work was implemented by a subagent whose worktree was lost to a session limit; the change set was recovered by replaying its recorded 54 edit operations and validated byte-for-byte against its partial snapshot. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The helper spawnSyncs 'rsbuild dev' expecting Vite's validate-and-exit startup behavior; rsbuild's dev server never self-terminates, which blocked a suite run indefinitely when a test assumed an error exit. Triage confirmed no plugin or rsbuild bug (config function-form was coincidental): a 30s timeout keeps any such assumption from hanging the harness again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two manifest asset-URL bugs: - The dev manifest derived its asset prefix solely from output.assetPrefix, ignoring dev.assetPrefix (Rsbuild's effective prefix in dev, defaulted from server.base). Asset URLs 404'd for any app configuring a dev prefix. resolveEffectiveAssetPrefix now mirrors Rsbuild's per-mode precedence off the normalized config, resolved in onBeforeCreateCompiler. - The build-mode browser manifest was generated at processAssets stage 'additions' (-100), before rspack's realContentHash rename at OPTIMIZE_HASH (2500), so manifest CSS/JS URLs could reference pre-rename hashed names absent from the output. Build-mode manifest generation and emission now run at 'report' (5000), unifying the previously separate SRI deferral; dev keeps 'additions' (no realContentHash pass in dev). test:core 491 -> 499. Classic-mode basename dev/build corpus cases all pass; vanilla-extract build cases pass with the fixtures' realContentHash:false workaround removed (workaround removal lands with the corpus rename commit). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Content-level renames completing the file renames that landed with fb25f5a: viteConfig->rsbuildConfig (77 refs), vitePreview-> rsbuildPreview, viteDevCmd->rsbuildDevCmd, viteMajorTemplates-> bundlerTemplates, Rsbuild-accurate describe/test titles ('Vite CSS'-> 'CSS', 'vite dev'->'rsbuild dev', ...), rsc fixture package scripts now say rsbuild, and UPSTREAM.json gains a complete upstream->corpus renames map (31 entries) so manual upstream comparison survives the renames. The two describe.skip'ed Vite-only suites keep their accurate Vite titles, as do assertions on strings React Router itself emits. Also applies the deferred manifest-fix corpus hunk to the renamed config factory: 'base' now maps to dev.assetPrefix as well (the plugin honors it since fb25f5a) and the vanilla-extract realContentHash:false workaround is removed (manifest reads post-hash names now). Verified: test:core 499; smoke 7/7; hmr-hdr 3/3; css+basename exactly match pre-existing baselines (24 passed / 14 failed / 3 skipped / 1 DNR - zero new failures); corpus greps for vite-flavored helper names come back empty. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Assets referenced only by server code (asset?url imports, .css?url files) are returned to the client as URLs but were never emitted to build/client, 404ing at runtime. Mirroring upstream's ssrEmitAssets + writeBundle move/remove: a node-target processAssets 'report' hook (post-realContentHash, so names are final) relocates emitted static assets into the client output when absent and strips them from the server build; server code-split chunks get a proper async chunkFilename and server-only .css?url output is redirected to the flat static/assets layout while preserving postcss processing. Verified against rsbuild source: dev serves from real disk when writeToDisk is on (setupOutputFileSystem), cleanAll runs before compilations so relocated files survive, and the uniform assetPrefix keeps loader-returned URLs aligned. No rsbuild/rspack built-in covers cross-environment asset sharing (tracedecay-searched), so the relocation module stays. Corpus: build-test + extra-server-environment now 9/9 (combined with the post-realContentHash manifest fix, even code-split CSS passes); smoke 7/7; test:core 506. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tests/react-router-framework/.tmp/ (7,856 materialized fixture files) was accidentally committed by a broad git add during the corpus work, inflating the PR diff massively. Untrack it and ignore fixture scratch, test-results, and playwright reports going forward. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Four-angle review (reuse/simplification/efficiency/altitude) over the RR8 branch diff: - assetPrefix now has a single writer (onBeforeCreateCompiler); the two config-phase assignments are gone and the virtual-module publicPath reads output.assetPrefix locally - RscModePlan drops its routeTransformExecutor/routeChunkOptions sentinels; the one unguarded consumer gates on plan kind - shared parseVersionMajorMinor replaces two divergent react-router version parsers; getPackageVersion memoizes default-resolver lookups - rsc-route-transforms imports CLIENT_NON_COMPONENT_EXPORTS from constants instead of redefining it; SPA_FALLBACK_HTML_FILE is a shared constant across both prerender pipelines; RSC basename/ bootstrap prefixes reuse normalizeAssetPrefix (was 4 copies) - route modules are no longer parsed for analysis in the node transform (client-entry covers every route; disk fallback intact), removing 1-2 redundant SWC parses per route per build - ssr-asset-relocation caches relocated destinations across node compilations (serverBundles, dev rebuilds) skipping steady-state stat/write syscalls; dev-hmr skips redundant mkdir after first bump - react-refresh runtime resolution no longer falls back to a bare root resolve that could bind a different physical instance than the browser graph (silent no-op refresh); unavailable now means the documented full-reload path - devHmr options pass through the mode plan without re-projection; RSC virtual modules share a defaultExport helper; classic createResolveConfig drops its empty-alias conditional Skipped deliberately: the node .css?url filename mapping (documented, empirically-validated tradeoff), hooks-per-mode/discriminated-union mode-plan reshape (deferred, larger), PrerenderConfig type unification (low value vs inference churn), shared classic/RSC alias builder (resolution semantics deliberately differ). manifestChunkNames on RscModePlan was confirmed live (web clientStats), not dead state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The interop script's hand-rolled plugin API stub predates the onBeforeCreateCompiler registration added for effective-asset-prefix resolution, so CI's build-test failed with 'api.onBeforeCreateCompiler is not a function'. The hook exists on the real Rsbuild plugin API (@rsbuild/core 2.x); only the stub was stale. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e8fe50f to
0e7fa0c
Compare
Its only plugin import is type-only and the typegen integration resolves it from the app directory with graceful fallback, so adding the peer must not break installs that lack it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Preserve the React Router 8 warning format while incorporating repository hygiene and prerender release metadata from main.
Trim branch-specific commentary and replace Module Federation option assertions with structural narrowing.
Assigning ogEnv back when NODE_ENV was originally unset coerced it to the string "undefined", poisoning every later fixture build in the serial CI worker: rsbuild saw an unrecognized mode, the built web bundle kept a literal process.env.NODE_ENV, and the browser threw 'process is not defined' — failing preview-test.ts ~600 tests downstream and blocking the suite via max-failures. Delete the variable when it was unset instead. Reproduced and verified: error-sanitization + preview serial sequence now 40/40. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rsbuild only emits the NODE_ENV define for its recognized modes; an unrecognized value (such as the string 'undefined' leaking from a misconfigured shell) resolves mode 'none', leaves the bare reference in the browser bundle, and React throws 'process is not defined' at runtime. Define it unconditionally for the web environment — valid explicit values pass through, otherwise build resolves to production and dev to development, and a user-supplied define wins. Mirrors the Vite plugin. Verified: preview build serves correctly under NODE_ENV=undefined. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The step adding a newly-imported client component pays a cold module compile before the hot update applies; the 15s budget that comfortably covers the ~6s local run intermittently expires on slow CI runners (same sha passed and failed across runs). Use 45s under CI, matching the hydration budget. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Web-only commits reuse the node compiler's stale modifiedFiles snapshot, and each HDR bump itself triggers a web rebuild, so the bump fed back into an infinite rebuild loop after the first server-file edit. Track the last node compilation identity that signaled and fire once per real node build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…compat-v2 # Conflicts: # .github/workflows/e2e-tests.yml # pnpm-lock.yaml # src/build-output-transforms.ts # src/dev-hmr.ts # src/dev-runtime-controller.ts # src/index.ts # src/route-artifacts.ts # src/route-transform-tasks.ts # tests/build-output-transforms.test.ts # tests/dev-runtime-controller.test.ts # tests/route-artifacts.test.ts
…compat-v2 # Conflicts: # tests/benchmark-fixture.test.ts
Summary
Adds React Router 8 compatibility while preserving React Router 7 support and the current Rsbuild plugin architecture.
What changed
main, including the sharded benchmark workflowValidation
CI=true pnpm install --frozen-lockfilepnpm test— 56 files, 659 tests passedpnpm buildnpx publint --errors-only— no errorsactionlint— no errors, ignoring the existing intentional SC2046 command-substitution warningsReview notes
UPSTREAM.jsonrecords only the last reviewed upstream revision