Repository navigation
Fix/rsbuild static chunk availability - #8780
LadyBluenotes wants to merge 5 commits into
Conversation
🦋 Changeset detectedLatest commit: 4542078 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit 4542078
☁️ Nx Cloud last updated this comment at |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Asset contract and normalization packages/start-plugin-core/src/types.ts, packages/start-plugin-core/src/rsbuild/normalized-client-build.ts, packages/start-plugin-core/src/vite/start-manifest-plugin/normalized-client-build.ts |
The client build types now distinguish chunk builds from grouped builds. Rsbuild normalization maps route origins to route asset groups and collects entry, preload, and CSS assets. The Vite normalizer continues to return the chunk-build type. |
Manifest route resources packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts |
The manifest builder selects the grouped-build path when route assets are present. It maps route preloads and CSS to manifest resources, merges entry assets into the root, and emits entry scripts. |
Asset behavior validation packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts, e2e/react-start/deferred-hydration/src/routes/__root.tsx, e2e/react-start/deferred-hydration/src/shared/root-deferred.module.css, e2e/react-start/deferred-hydration/tests/hydration.spec.ts, .changeset/rsbuild-static-chunk-availability.md |
Tests cover shared chunks, lazy-group dependencies, route assets, asset ordering, and Windows paths. The deferred-hydration example and test cover CSS in a root hydration boundary. A changeset records a patch release. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant RspackCompilation
participant normalizeRspackClientBuild
participant buildStartManifest
RspackCompilation->>normalizeRspackClientBuild: Provide entrypoint and chunk groups
normalizeRspackClientBuild->>buildStartManifest: Return entry and route assets
buildStartManifest->>buildStartManifest: Map route preloads and CSS to manifest resources
Possibly related issues
- Tracking: open Router and Start PRs by problem area #8810: The tracking issue describes the shared-chunk route asset behavior and the parent-availability rule covered by this change.
Possibly related PRs
- TanStack/router#8800: It caches the normalized build and fingerprints chunk groups used by this PR’s group-based normalization.
Suggested reviewers: schiller-manuel, czearing
Merge Risk: 
Minimal · up to 45420
-
The change makes Rsbuild static chunk availability follow chunk-group parent paths, which should stop sibling route assets from leaking into the manifest. No actionable merge-blocking risk was found, and tests cover the main cases, including shared chunks, two-parent groups and cycles.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "Fix/rsbuild static chunk availability" names the main change: the fix to static dependency chunk availability for Rsbuild (computeStaticDependencyChunks now intersects parent availability per chunk group). It is concise and specific. The branch-style prefix "Fix/" is a minor style issue but does not affect relevance.
Full details: Description check
-
Explanation
The description follows the template: it has a Changes section explaining the bug (shared chunks in sibling route groups linking another route's CSS and preloads), the fix (per-group intersection of parent availability with a fixed-point iteration), and the tests added. It includes the checklist with the items checked and the release impact section with the changeset box checked. The AI disclosure is present. The description does not mention the changeset file by name, and it does not state the scope of the e2e deferred-hydration changes, but these gaps are non-critical.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 7 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
🚀 Changeset Version Preview1 package(s) bumped directly, 4 bumped as dependents. 🟩 Patch bumps
|
Merging this PR will improve performance by 3.42%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Bundle Size BenchmarksThis pull request does not affect bundle size in any measured scenario. |
…cross loading paths A shared chunk recorded static imports to every chunk in the union of its groups and their ancestors, so it pointed at each sibling route's copy of a duplicated module. Compute availability per chunk group as its own chunks plus the intersection of its parents, iterate to a shrinking fixed point for cyclic async graphs, and intersect across the chunk's groups.
… own loading context
96b2c48 to
3e09e47
Compare
…aring a module The route CSS rows (SPEC J2.22) now live in route-css-cases.ts and run for each bundler from its own file: known-bugs-route-css.test.ts on Vite dev and build, known-bugs-route-css-rsbuild.test.ts on the Rsbuild dev server and an Rsbuild production build served as `rsbuild preview` does (new StartBuild.preview() of the build harness). New rows: two routes whose components import their own CSS and share a module. On a route, the other route's styles must not apply, after a client-side navigation and in the page the server renders there. Vite passes; on Rsbuild, with the shared module in a chunk of its own, the page links the other route's stylesheet (Start's Rsbuild manifest, #8780), pinned as a separate known bug. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y when every group of the importer has it (#8780) computeStaticDependencyChunks took the union of the chunks of every group a shared chunk belongs to, so a module duplicated into each route's chunk made the shared chunk depend on both routes' chunks and each route's page linked the other route's CSS. The intersection over the groups (with their ancestors) keeps a per-group dependency out of the shared chunk's imports. Flips the four shares-module rows of known-bugs-route-css-rsbuild. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The shows-component, shows-error and shows-not-found rows return to known-bug pins on Vite and Rsbuild, as in the oracle; the Rsbuild shares-module rows (#8780) keep passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@LadyBluenotes I think we could simplify this by collecting assets per route’s chunk group, rather than reconstructing a global A shared chunk can belong to several loading contexts, and its dependencies may be provided by different chunks in each context. Flattening those relationships into a single imports list loses that distinction and can pull sibling route assets into the manifest. My suggestion is:
I implemented a prototype here. The regression scenarios from this PR pass after adapting the assertions to the final route manifest, along with the Rsbuild CSS, deferred hydration, and HMR integration tests. |
Collect JavaScript and CSS from route chunk groups instead of reconstructing global chunk imports. Preserve parent-path intersection and the Vite chunk-based manifest path. Include entry-owned hydration styles so root-level deferred content is styled without loading its JavaScript. Cover shared loading groups and root hydration with compiler and production browser regressions.
🎯 Changes
Follow-up to #8695 (#8415, #8511).
computeStaticDependencyChunks()treated a chunk as available if any group of the importing chunk, or any ancestor, contained it. A shared chunk in sibling route groups therefore got import edges to each route's copy of a duplicated module, and the manifest gave route A route C's CSS and preloads.Rspack and webpack combine availability across parents with intersection (
intersect_withincode_splitter.rs;minAvailableModules &= availableModulesinbuildChunkGraph.js). This PR does the same per chunk group: own chunks plus the intersection of the parents' availability. It iterates to a fixed point that only shrinks, so cyclic async graphs terminate and give the same result in any order. A chunk's availability is the intersection across its groups.New Rspack-fixture tests: sibling duplication, a two-parent lazy group, a dependency available on every path, and a ping/pong cycle in both orders.
AI disclosure: drafted with an AI assistant; reviewed and verified by me.
✅ Checklist
🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests