fix: migrate dev middleware registration to server.setup#77
fix: migrate dev middleware registration to server.setup#77ScriptedAlchemy wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis change replaces the deprecated Sequence Diagram(s)sequenceDiagram
participant PluginIndex as src/index.ts
participant DevServerModule as src/dev-server.ts
participant Rsbuild
participant DevRuntime as devRuntime
PluginIndex->>DevServerModule: createReactRouterDevServerSetup({ loadBuild })
DevServerModule-->>PluginIndex: returns ServerSetup function
PluginIndex->>Rsbuild: register via server.setup
Rsbuild->>DevServerModule: invoke setup(context) on dev action
DevServerModule->>DevRuntime: loadBuild() via devRuntime.createBuildLoader()
DevServerModule->>Rsbuild: register createDevServerMiddleware into context.server.middlewares
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Related Issues: None specified in provided context. Related PRs: None specified in provided context. Suggested labels: dev-server, tests, refactor Suggested reviewers: None specified in provided context. Poem 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Rsbuild 2.1 deprecates `dev.setupMiddlewares` in favor of `server.setup`. Register the React Router dev middleware through a `server.setup` function that returns a post-built-in-middlewares callback, preserving the ordering guarantee that static assets are served before the request handler. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
b3c7fea to
7d2914b
Compare
Benchmark ResultsCompared PR head Dev Rollup
Production Build BenchmarksRendered 7 production build benchmarks.
full 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: |
Summary
Rsbuild 2.1 logs
warn [rsbuild] \dev.setupMiddlewares` is deprecated, use `server.setup` insteadwhenever the plugin registers its dev middleware. This migrates the registration insrc/index.tsto theserver.setup` API.reactRouterDevServerSetupfunction underserver.setup. It guards oncontext.action === 'dev'and returns a callback, which Rsbuild runs only after its built-in middlewares are registered — the documented equivalent of the oldmiddlewares.push()semantics, so static assets are still tried before the React Router request handler.customServerand SPA (ssr: false) modes contribute nothing, matching the previous empty-array behavior.ServerSetuptype is derived fromRsbuildConfig(same pattern assrc/dev-runtime-controller.ts, since@rsbuild/coredoesn't exportServerSetupFn). Merging is safe alongside the controller's existing close-observer becausemergeRsbuildConfigflattens function-plus-arraysetupvalues into one array.features.test.tscustomServer assertion updated to checkserver.setup, plus new tests for the default SSR case (setup function present) and SPA mode (absent). Removed the deadsetupMiddlewares: []from the test stub base config.Verification
pnpm test: 41 files, 442 tests pass;tsc --noEmitclean.rsbuild devofexamples/default-template: SSR home route 200 with rendered HTML,/static/js/entry.client.js200 withtext/javascript(asset middleware still wins), no deprecation warning.rsbuild devofexamples/spa-mode: no deprecation warning./returns 404 in dev, but unmodifiedmainbehaves identically (SPA e2e runs against a static production build), so this is pre-existing, not a regression.maindoes emit the deprecation warning, confirming this change removes exactly that warning.🤖 Generated with Claude Code