@@ -26,7 +26,9 @@ export function getKeyedLinksForMatches(
26
26
let module = routeModules [ match . route . id ] ;
27
27
let route = manifest . routes [ match . route . id ] ;
28
28
return [
29
- route . css ? route . css . map ( ( href ) => ( { rel : "stylesheet" , href } ) ) : [ ] ,
29
+ route && route . css
30
+ ? route . css . map ( ( href ) => ( { rel : "stylesheet" , href } ) )
31
+ : [ ] ,
30
32
module ?. links ?.( ) || [ ] ,
31
33
] ;
32
34
} )
@@ -138,11 +140,12 @@ export async function getKeyedPrefetchLinks(
138
140
) : Promise < KeyedHtmlLinkDescriptor [ ] > {
139
141
let links = await Promise . all (
140
142
matches . map ( async ( match ) => {
141
- let mod = await loadRouteModule (
142
- manifest . routes [ match . route . id ] ,
143
- routeModules
144
- ) ;
145
- return mod . links ? mod . links ( ) : [ ] ;
143
+ let route = manifest . routes [ match . route . id ] ;
144
+ if ( route ) {
145
+ let mod = await loadRouteModule ( route , routeModules ) ;
146
+ return mod . links ? mod . links ( ) : [ ] ;
147
+ }
148
+ return [ ] ;
146
149
} )
147
150
) ;
148
151
@@ -197,7 +200,7 @@ export function getNewMatchesForLinks(
197
200
if ( mode === "data" ) {
198
201
return nextMatches . filter ( ( match , index ) => {
199
202
let manifestRoute = manifest . routes [ match . route . id ] ;
200
- if ( ! manifestRoute . hasLoader ) {
203
+ if ( ! manifestRoute || ! manifestRoute . hasLoader ) {
201
204
return false ;
202
205
}
203
206
@@ -235,6 +238,7 @@ export function getModuleLinkHrefs(
235
238
matches
236
239
. map ( ( match ) => {
237
240
let route = manifestPatch . routes [ match . route . id ] ;
241
+ if ( ! route ) return [ ] ;
238
242
let hrefs = [ route . module ] ;
239
243
if ( route . imports ) {
240
244
hrefs = hrefs . concat ( route . imports ) ;
@@ -256,12 +260,11 @@ function getCurrentPageModulePreloadHrefs(
256
260
matches
257
261
. map ( ( match ) => {
258
262
let route = manifest . routes [ match . route . id ] ;
263
+ if ( ! route ) return [ ] ;
259
264
let hrefs = [ route . module ] ;
260
-
261
265
if ( route . imports ) {
262
266
hrefs = hrefs . concat ( route . imports ) ;
263
267
}
264
-
265
268
return hrefs ;
266
269
} )
267
270
. flat ( 1 )
0 commit comments