@@ -502,11 +502,12 @@ export function createClientRoutes(
502502 }
503503
504504 dataRoute . lazy = {
505- loader : dataRoute . loader
506- ? undefined
507- : async ( ) => {
508- let { clientLoader } = await getLazyRoute ( ) ;
509- if ( clientLoader ) {
505+ loader :
506+ dataRoute . loader || ! route . hasClientLoader
507+ ? undefined
508+ : async ( ) => {
509+ let { clientLoader } = await getLazyRoute ( ) ;
510+ invariant ( clientLoader , "No `clientLoader` export found" ) ;
510511 return ( args : LoaderFunctionArgs , singleFetch ?: unknown ) =>
511512 clientLoader ( {
512513 ...args ,
@@ -515,13 +516,13 @@ export function createClientRoutes(
515516 return fetchServerLoader ( singleFetch ) ;
516517 } ,
517518 } ) ;
518- }
519- } ,
520- action : dataRoute . action
521- ? undefined
522- : async ( ) => {
523- let { clientAction } = await getLazyRoute ( ) ;
524- if ( clientAction ) {
519+ } ,
520+ action :
521+ dataRoute . action || ! route . hasClientAction
522+ ? undefined
523+ : async ( ) => {
524+ let { clientAction } = await getLazyRoute ( ) ;
525+ invariant ( clientAction , "No `clientAction` export found" ) ;
525526 return ( args : ActionFunctionArgs , singleFetch ?: unknown ) =>
526527 clientAction ( {
527528 ...args ,
@@ -530,8 +531,7 @@ export function createClientRoutes(
530531 return fetchServerAction ( singleFetch ) ;
531532 } ,
532533 } ) ;
533- }
534- } ,
534+ } ,
535535 unstable_middleware : ! route . hasClientMiddleware
536536 ? undefined
537537 : async ( ) => {
@@ -542,7 +542,7 @@ export function createClientRoutes(
542542 ) ;
543543 invariant (
544544 clientMiddlewareModule ?. unstable_clientMiddleware ,
545- "No `unstable_clientMiddleware` export in chunk "
545+ "No `unstable_clientMiddleware` export found "
546546 ) ;
547547 return clientMiddlewareModule . unstable_clientMiddleware ;
548548 } ,
@@ -559,7 +559,9 @@ export function createClientRoutes(
559559 // No need to wrap these in layout since the root route is never
560560 // loaded via route.lazy()
561561 Component : async ( ) => ( await getLazyRoute ( ) ) . Component ,
562- ErrorBoundary : async ( ) => ( await getLazyRoute ( ) ) . ErrorBoundary ,
562+ ErrorBoundary : route . hasErrorBoundary
563+ ? async ( ) => ( await getLazyRoute ( ) ) . ErrorBoundary
564+ : undefined ,
563565 } ;
564566 }
565567
0 commit comments