Skip to content

fix(react-start): dedupe rsbuild dependencies#7644

Draft
elecmonkey wants to merge 3 commits into
TanStack:mainfrom
elecmonkey:fix/rsbuild-react-dedupe
Draft

fix(react-start): dedupe rsbuild dependencies#7644
elecmonkey wants to merge 3 commits into
TanStack:mainfrom
elecmonkey:fix/rsbuild-react-dedupe

Conversation

@elecmonkey

@elecmonkey elecmonkey commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR aligns the react-start Rsbuild plugin with the existing Vite-side dedupe behavior.

Summary by CodeRabbit

  • Chores
    • Updated the React Start Rsbuild integration to deduplicate React (and related) packages, reducing duplicate React instances in the bundle.
    • Improves build consistency and reliability across environments by normalizing dependency resolution and keeping React and React DOM aligned.
    • Helps prevent runtime issues caused by multiple React copies. No action required.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6629f591-0750-4605-8f7f-f1dcd1782a24

📥 Commits

Reviewing files that changed from the base of the PR and between 60a81be and 5cc2eea.

📒 Files selected for processing (2)
  • .changeset/tiny-phones-dedup.md
  • packages/react-start/src/plugin/rsbuild.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/tiny-phones-dedup.md
  • packages/react-start/src/plugin/rsbuild.ts

📝 Walkthrough

Walkthrough

Adds a reactStartRsbuildEnvironmentOverrides constant in rsbuild.ts that defines resolve.dedupe entries for React and React DOM across all RSBuild environments. This constant is wired into corePluginOpts.rsbuild.environments inside tanstackStart. A patch changeset entry documents the change.

Changes

RSBuild Package Deduplication

Layer / File(s) Summary
Dedupe config constant and plugin wiring
packages/react-start/src/plugin/rsbuild.ts, .changeset/tiny-phones-dedup.md
Introduces reactStartRsbuildEnvironmentOverrides with a resolve.dedupe list for React and React DOM. Assigns it to corePluginOpts.rsbuild.environments in tanstackStart. Patch changeset entry included.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • TanStack/router#7372: Both PRs modify packages/react-start/src/plugin/rsbuild.ts by adding/wiring RSBuild environments overrides that set resolve.dedupe for react and react-dom.

Suggested labels

package: react-start

Poem

A bunny hops through the build with glee,
No duplicate React packages shall there be!
resolve.dedupe keeps the stack aligned,
React once per build — perfectly designed.
🐇✨ Clean builds for all!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding React package deduplication to the Rsbuild plugin configuration in react-start.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 5cc2eea

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 27m 5s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 17s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-16 18:47:11 UTC

@codspeed-hq

codspeed-hq Bot commented Jun 16, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 11.57%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 4 regressed benchmarks
✅ 138 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem serialization-payload (solid) 7 MB 12.1 MB -41.99%
Memory mem aborted-requests (solid) 2 MB 2.5 MB -19.11%
Simulation ssr server-fn raw-stream (solid) 106.5 ms 111.8 ms -4.7%
Simulation ssr server-fn multipart (solid) 60.1 ms 63 ms -4.68%
Memory mem aborted-requests (vue) 958.5 KB 888.9 KB +7.83%
Memory mem serialization-payload (react) 32.7 MB 31.4 MB +4.02%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing elecmonkey:fix/rsbuild-react-dedupe (5cc2eea) with main (e499164)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (1362bf2) during the generation of this report, so e499164 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

nx-cloud[bot]

This comment was marked as outdated.

@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7644

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7644

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7644

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7644

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7644

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7644

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7644

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7644

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7644

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7644

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7644

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7644

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7644

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7644

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7644

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7644

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7644

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7644

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7644

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7644

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7644

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7644

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7644

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7644

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7644

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7644

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7644

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7644

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7644

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7644

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7644

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7644

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7644

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7644

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7644

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7644

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7644

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7644

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7644

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7644

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7644

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7644

commit: 5cc2eea

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nx Cloud is proposing a fix for your failed CI:

We scoped the dedupe: ['react', 'react-dom'] override from all environments to only the client environment, which fixes the RSC 500 errors caused by the server layer resolving to the wrong React instance. Applying dedupe to all environments forced the react-server-components rspack layer to reuse the client-side React bundle, which lacks the react-server export condition required by RSC. This change preserves the deduplication benefit for client bundles while allowing the ssr environment's RSC layer to resolve React independently with the correct condition.

Tip

We verified this fix by re-running tanstack-react-start-e2e-rsc:test:e2e--rsbuild-ssr--shard-4-of-6.

diff --git a/packages/react-start/src/plugin/rsbuild.ts b/packages/react-start/src/plugin/rsbuild.ts
index bd159690..3b75cf86 100644
--- a/packages/react-start/src/plugin/rsbuild.ts
+++ b/packages/react-start/src/plugin/rsbuild.ts
@@ -11,7 +11,7 @@ import type {
 import type { RsbuildPlugin } from '@rsbuild/core'
 
 const reactStartRsbuildEnvironmentOverrides = {
-  all: {
+  [RSBUILD_ENVIRONMENT_NAMES.client]: {
     resolve: {
       dedupe: ['react', 'react-dom'],
     },

Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.

Apply changes locally with:

npx nx-cloud apply-locally HRa7-KQnd

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

@elecmonkey elecmonkey marked this pull request as draft June 16, 2026 18:54
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