feat(rspack): use rsbuild dev server in middleware mode#35575
Conversation
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/webpack/src/configs/client.ts`:
- Around line 79-86: Restrict the early return in the HMR setup after adding
HotModuleReplacementPlugin to cases where builder is 'rspack' and createRsbuild
is truthy, matching the routing condition in webpack.ts. Allow the
webpack-hot-middleware/client injection to continue for rspack builds using the
classic middleware fallback.
In `@packages/webpack/src/webpack.ts`:
- Around line 224-247: Update rsbuildToH3Handler so its middleware callback
accepts the optional error and rejects the surrounding Promise when next(err) is
provided; retain the existing done/resolve behavior for error-free next calls
and response finish/close events.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 93d29300-0f37-47a3-abb9-4c534a7f7c03
⛔ Files ignored due to path filters (2)
packages/rspack/package.jsonis excluded by!**/package.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (3)
packages/nitro-server/src/legacy.tspackages/webpack/src/configs/client.tspackages/webpack/src/webpack.ts
Merging this PR will improve performance by 14.8%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | loadNuxt in the basic test fixture (dev) |
370.3 ms | 322.5 ms | +14.8% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/rsbuild-dev-server (d5b4376) with main (d597a4e)
Footnotes
-
3 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. ↩
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/webpack/src/webpack.ts (1)
212-218: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winEnsure Rsbuild's dev server lifecycle completes even without a listener.
Rsbuild's
devServer.afterListen()triggers theonAfterStartDevServerlifecycle hooks. It should be called unconditionally to ensure any plugins relying on these hooks execute properly, even if HMR is disabled due to a missing listener.♻️ Proposed refactor
const listener = nuxt._devServerListener if (listener) { devServer.connectWebSocket({ server: listener }) - await devServer.afterListen() } else { logger.warn('Could not find the Nuxt dev server to attach Rspack HMR to; hot module replacement will be disabled.') } + + await devServer.afterListen()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/webpack/src/webpack.ts` around lines 212 - 218, Update the dev-server setup around the listener check so devServer.afterListen() is called unconditionally after the optional devServer.connectWebSocket({ server: listener }) call. Keep the existing warning and HMR-disabled behavior when listener is absent, while ensuring the onAfterStartDevServer lifecycle hooks always execute.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/webpack/src/webpack.ts`:
- Around line 212-218: Update the dev-server setup around the listener check so
devServer.afterListen() is called unconditionally after the optional
devServer.connectWebSocket({ server: listener }) call. Keep the existing warning
and HMR-disabled behavior when listener is absent, while ensuring the
onAfterStartDevServer lifecycle hooks always execute.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 97016909-17ef-417f-bc64-8590442b5468
📒 Files selected for processing (4)
packages/nuxt/src/core/nuxt.tspackages/schema/src/types/nuxt.tspackages/vite/src/plugins/dev-server.tspackages/webpack/src/webpack.ts
611afb0 to
d5b4376
Compare
🔗 Linked issue
follow-on from #35489
📚 Description
this migrates us to use the rsbuild dev server rather than
webpack-dev-middlewareandwebpack-hot-middleware