@@ -4961,17 +4961,19 @@ async function loadLazyMiddleware(
49614961 routeToUpdate . unstable_lazyMiddleware = undefined ;
49624962}
49634963
4964- async function loadLazyMiddlewareForMatches (
4964+ function loadLazyMiddlewareForMatches (
49654965 matches : AgnosticDataRouteMatch [ ] ,
49664966 manifest : RouteManifest
4967- ) {
4968- await Promise . all (
4969- matches . map ( ( m ) =>
4967+ ) : Promise < void [ ] > | void {
4968+ let promises = matches
4969+ . map ( ( m ) =>
49704970 m . route . unstable_lazyMiddleware
49714971 ? loadLazyMiddleware ( m . route , manifest )
49724972 : undefined
49734973 )
4974- ) ;
4974+ . filter ( Boolean ) ;
4975+
4976+ return promises . length > 0 ? Promise . all ( promises ) : undefined ;
49754977}
49764978
49774979// Default implementation of `dataStrategy` which fetches all loaders in parallel
@@ -5158,15 +5160,17 @@ async function callDataStrategyImpl(
51585160) : Promise < Record < string , DataStrategyResult > > {
51595161 // Ensure all lazy/lazyMiddleware async functions are kicked off in parallel
51605162 // before we await them where needed below
5161- let loadMiddlewarePromises = loadLazyMiddlewareForMatches ( matches , manifest ) ;
5163+ let loadMiddlewarePromise = loadLazyMiddlewareForMatches ( matches , manifest ) ;
51625164 let loadRouteDefinitionsPromises = matches . map ( ( m ) =>
51635165 m . route . lazy
51645166 ? loadLazyRouteModule ( m . route , mapRouteProperties , manifest )
51655167 : undefined
51665168 ) ;
51675169
51685170 // Ensure all middleware is loaded before we start executing routes
5169- await loadMiddlewarePromises ;
5171+ if ( loadMiddlewarePromise ) {
5172+ await loadMiddlewarePromise ;
5173+ }
51705174
51715175 let dsMatches = matches . map ( ( match , i ) => {
51725176 let loadRoutePromise = loadRouteDefinitionsPromises [ i ] ;
0 commit comments