@@ -1293,15 +1293,6 @@ def get_compilation_time() -> str:
12931293 # Track imports found.
12941294 all_imports = {}
12951295
1296- # This has to happen before compiling stateful components as that
1297- # prevents recursive functions from reaching all components.
1298- for component in self ._pages .values ():
1299- # Add component._get_all_imports() to all_imports.
1300- all_imports .update (component ._get_all_imports ())
1301-
1302- # Add the app wrappers from this component.
1303- app_wrappers .update (component ._get_all_app_wrap_components ())
1304-
13051296 if (toaster := self .toaster ) is not None :
13061297 from reflex .components .component import memo
13071298
@@ -1319,6 +1310,25 @@ def memoized_toast_provider():
13191310 if component is not None :
13201311 app_wrappers [key ] = component
13211312
1313+ # Compile custom components.
1314+ (
1315+ custom_components_output ,
1316+ custom_components_result ,
1317+ custom_components_imports ,
1318+ ) = compiler .compile_components (dict .fromkeys (CUSTOM_COMPONENTS .values ()))
1319+ compile_results .append ((custom_components_output , custom_components_result ))
1320+ all_imports .update (custom_components_imports )
1321+ progress .advance (task )
1322+
1323+ # This has to happen before compiling stateful components as that
1324+ # prevents recursive functions from reaching all components.
1325+ for component in self ._pages .values ():
1326+ # Add component._get_all_imports() to all_imports.
1327+ all_imports .update (component ._get_all_imports ())
1328+
1329+ # Add the app wrappers from this component.
1330+ app_wrappers .update (component ._get_all_app_wrap_components ())
1331+
13221332 if self .error_boundary :
13231333 from reflex .compiler .compiler import into_component
13241334
@@ -1465,16 +1475,6 @@ def _submit_work_without_advancing(
14651475 )
14661476 progress .advance (task )
14671477
1468- # Compile custom components.
1469- (
1470- custom_components_output ,
1471- custom_components_result ,
1472- custom_components_imports ,
1473- ) = compiler .compile_components (dict .fromkeys (CUSTOM_COMPONENTS .values ()))
1474- compile_results .append ((custom_components_output , custom_components_result ))
1475- all_imports .update (custom_components_imports )
1476-
1477- progress .advance (task )
14781478 progress .stop ()
14791479
14801480 if dry_run :
0 commit comments