Skip to content
Source
Sign inSign up
TanStack/router

fix(start-plugin-core): Rsbuild manifests list only a route's own chunks #8876

OpenSheraff(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromstart-plugin-core/rsbuild-manifest-own-chunksopened

Showing 3 changed files with 100 additions and 7 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/rsbuild-manifest-own-chunks.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/start-plugin-core': patch
+---
+​
+Rsbuild: a route's client manifest entry lists only its own chunks and CSS. When two routes shared a module in a chunk of its own, each route's entry also listed the other route's chunk as a preload and its stylesheet.
24 additions and 7 deletionspackages/start-plugin-core/src/rsbuild/normalized-client-build.tsModified
View file
@@ -230,16 +230,33 @@
// A shared chunk can belong to several route groups. Group membership
// limits where dependencies can be loaded from; it does not establish
// an import from the shared chunk back to every route in those groups.
- const availableChunks = new Set<RspackCompilationChunk>()
- const groups = new Set(chunk.groupsIterable)
- for (const group of groups) {
- for (const availableChunk of group.chunks) {
- availableChunks.add(availableChunk)
+ // A chunk counts as available only when every group of this chunk (or
+ // one of its ancestors) has it: a module duplicated into each route's
+ // chunk is satisfied per group, by that group's own chunk, so neither
+ // route's chunk is a dependency of the shared chunk (#8780).
+ let availableChunks: Set<RspackCompilationChunk> | undefined
+ for (const group of chunk.groupsIterable) {
+ const groupChunks = new Set<RspackCompilationChunk>()
+ const ancestors = new Set([group])
+ for (const ancestor of ancestors) {
+ for (const availableChunk of ancestor.chunks) {
+ groupChunks.add(availableChunk)
+ }
+ for (const parent of ancestor.getParents()) {