@@ -534,6 +534,16 @@ function isLikelyComponentType(type) {
534534            // Definitely React components. 
535535            return  true 
536536          default :
537+             // Check if this is a compound component (object with all properties being React components) 
538+             if  ( isPlainObject ( type ) )  { 
539+               const  keys  =  Object . keys ( type ) 
540+               if  ( 
541+                 keys . length  >  0  && 
542+                 keys . every ( ( key )  =>  isLikelyComponentType ( type [ key ] ) ) 
543+               )  { 
544+                 return  true 
545+               } 
546+             } 
537547            return  false 
538548        } 
539549      } 
@@ -546,20 +556,12 @@ function isLikelyComponentType(type) {
546556} 
547557
548558function  isPlainObject ( obj )  { 
549-   if  ( typeof  obj  !==  'object'  ||  obj  ===  null )  { 
550-     return  false 
551-   } 
552- 
553559  return  ( 
554560    Object . prototype . toString . call ( obj )  ===  '[object Object]'  && 
555561    ( obj . constructor  ===  Object  ||  obj . constructor  ===  undefined ) 
556562  ) 
557563} 
558564
559- function  isLikelyCompoundComponent ( type )  { 
560-   return  isPlainObject ( type )  &&  Object . keys ( type ) . every ( isLikelyComponentType ) 
561- } 
562- 
563565/** 
564566 * Plugin utils 
565567 */ 
@@ -580,12 +582,23 @@ export function registerExportsForReactRefresh(filename, moduleExports) {
580582      // The register function has an identity check to not register twice the same component, 
581583      // so this is safe to not used the same key here. 
582584      register ( exportValue ,  filename  +  ' export '  +  key ) 
583-     }  else  if  ( isLikelyCompoundComponent ( exportValue ) )  { 
584-       for  ( const  subKey  in  exportValue )  { 
585-         register ( 
586-           exportValue [ subKey ] , 
587-           filename  +  ' export '  +  key  +  '$'  +  subKey , 
585+ 
586+       // If it's a compound component (plain object with component properties), 
587+       // also register the individual components 
588+       if  ( 
589+         typeof  exportValue  ===  'object'  && 
590+         exportValue  !=  null  && 
591+         isPlainObject ( exportValue )  && 
592+         Object . keys ( exportValue ) . every ( ( subKey )  => 
593+           isLikelyComponentType ( exportValue [ subKey ] ) , 
588594        ) 
595+       )  { 
596+         for  ( const  subKey  in  exportValue )  { 
597+           register ( 
598+             exportValue [ subKey ] , 
599+             filename  +  ' export '  +  key  +  '$'  +  subKey , 
600+           ) 
601+         } 
589602      } 
590603    } 
591604  } 
0 commit comments