File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,13 +156,33 @@ export function attachRouterServerSsrUtils({
156156 const matches = matchesToDehydrate . map ( dehydrateMatch )
157157
158158 let manifestToDehydrate : Manifest | undefined = undefined
159- // only send manifest of the current routes to the client
159+ // For currently matched routes, send full manifest (preloads + assets)
160+ // For all other routes, only send assets (no preloads as they are handled via dynamic imports)
160161 if ( manifest ) {
162+ const currentRouteIds = new Set (
163+ router . state . matches . map ( ( k ) => k . routeId ) ,
164+ )
161165 const filteredRoutes = Object . fromEntries (
162- router . state . matches . map ( ( k ) => [
163- k . routeId ,
164- manifest . routes [ k . routeId ] ,
165- ] ) ,
166+ Object . entries ( manifest . routes ) . flatMap (
167+ ( [ routeId , routeManifest ] ) => {
168+ if ( currentRouteIds . has ( routeId ) ) {
169+ return [ [ routeId , routeManifest ] ]
170+ } else if (
171+ routeManifest . assets &&
172+ routeManifest . assets . length > 0
173+ ) {
174+ return [
175+ [
176+ routeId ,
177+ {
178+ assets : routeManifest . assets ,
179+ } ,
180+ ] ,
181+ ]
182+ }
183+ return [ ]
184+ } ,
185+ ) ,
166186 )
167187 manifestToDehydrate = {
168188 routes : filteredRoutes ,
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export async function getStartManifest() {
3636
3737 const manifest = {
3838 routes : Object . fromEntries (
39- Object . entries ( startManifest . routes ) . map ( ( [ k , v ] ) => {
39+ Object . entries ( startManifest . routes ) . flatMap ( ( [ k , v ] ) => {
4040 const result = { } as {
4141 preloads ?: Array < string >
4242 assets ?: Array < RouterManagedTag >
@@ -53,7 +53,7 @@ export async function getStartManifest() {
5353 if ( ! hasData ) {
5454 return [ ]
5555 }
56- return [ k , result ]
56+ return [ [ k , result ] ]
5757 } ) ,
5858 ) ,
5959 }
You can’t perform that action at this time.
0 commit comments