9999 _substate_key ,
100100 code_uses_state_contexts ,
101101)
102- from reflex .utils import codespaces , console , exceptions , format , prerequisites , types
102+ from reflex .utils import (
103+ codespaces ,
104+ console ,
105+ exceptions ,
106+ format ,
107+ path_ops ,
108+ prerequisites ,
109+ types ,
110+ )
103111from reflex .utils .exec import is_prod_mode , is_testing_env
104112from reflex .utils .imports import ImportVar
105113
@@ -974,9 +982,10 @@ def get_compilation_time() -> str:
974982 should_compile = self ._should_compile ()
975983
976984 if not should_compile :
977- for route in self ._unevaluated_pages :
978- console .debug (f"Evaluating page: { route } " )
979- self ._compile_page (route , save_page = should_compile )
985+ with console .timing ("Evaluate Pages (Backend)" ):
986+ for route in self ._unevaluated_pages :
987+ console .debug (f"Evaluating page: { route } " )
988+ self ._compile_page (route , save_page = should_compile )
980989
981990 # Add the optional endpoints (_upload)
982991 self ._add_optional_endpoints ()
@@ -1002,10 +1011,11 @@ def get_compilation_time() -> str:
10021011 + adhoc_steps_without_executor ,
10031012 )
10041013
1005- for route in self ._unevaluated_pages :
1006- console .debug (f"Evaluating page: { route } " )
1007- self ._compile_page (route , save_page = should_compile )
1008- progress .advance (task )
1014+ with console .timing ("Evaluate Pages (Frontend)" ):
1015+ for route in self ._unevaluated_pages :
1016+ console .debug (f"Evaluating page: { route } " )
1017+ self ._compile_page (route , save_page = should_compile )
1018+ progress .advance (task )
10091019
10101020 # Add the optional endpoints (_upload)
10111021 self ._add_optional_endpoints ()
@@ -1040,13 +1050,13 @@ def get_compilation_time() -> str:
10401050 custom_components |= component ._get_all_custom_components ()
10411051
10421052 # Perform auto-memoization of stateful components.
1043- (
1044- stateful_components_path ,
1045- stateful_components_code ,
1046- page_components ,
1047- ) = compiler . compile_stateful_components ( self . _pages . values ())
1048-
1049- progress .advance (task )
1053+ with console . timing ( "Auto-memoize StatefulComponents" ):
1054+ (
1055+ stateful_components_path ,
1056+ stateful_components_code ,
1057+ page_components ,
1058+ ) = compiler . compile_stateful_components ( self . _pages . values ())
1059+ progress .advance (task )
10501060
10511061 # Catch "static" apps (that do not define a rx.State subclass) which are trying to access rx.State.
10521062 if code_uses_state_contexts (stateful_components_code ) and self ._state is None :
@@ -1069,6 +1079,17 @@ def get_compilation_time() -> str:
10691079
10701080 progress .advance (task )
10711081
1082+ # Copy the assets.
1083+ assets_src = Path .cwd () / constants .Dirs .APP_ASSETS
1084+ if assets_src .is_dir ():
1085+ with console .timing ("Copy assets" ):
1086+ path_ops .update_directory_tree (
1087+ src = assets_src ,
1088+ dest = (
1089+ Path .cwd () / prerequisites .get_web_dir () / constants .Dirs .PUBLIC
1090+ ),
1091+ )
1092+
10721093 # Use a forking process pool, if possible. Much faster, especially for large sites.
10731094 # Fallback to ThreadPoolExecutor as something that will always work.
10741095 executor = None
@@ -1121,9 +1142,10 @@ def _submit_work(fn: Callable, *args, **kwargs):
11211142 _submit_work (compiler .remove_tailwind_from_postcss )
11221143
11231144 # Wait for all compilation tasks to complete.
1124- for future in concurrent .futures .as_completed (result_futures ):
1125- compile_results .append (future .result ())
1126- progress .advance (task )
1145+ with console .timing ("Compile to Javascript" ):
1146+ for future in concurrent .futures .as_completed (result_futures ):
1147+ compile_results .append (future .result ())
1148+ progress .advance (task )
11271149
11281150 app_root = self ._app_root (app_wrappers = app_wrappers )
11291151
@@ -1158,7 +1180,8 @@ def _submit_work(fn: Callable, *args, **kwargs):
11581180 progress .stop ()
11591181
11601182 # Install frontend packages.
1161- self ._get_frontend_packages (all_imports )
1183+ with console .timing ("Install Frontend Packages" ):
1184+ self ._get_frontend_packages (all_imports )
11621185
11631186 # Setup the next.config.js
11641187 transpile_packages = [
@@ -1184,8 +1207,9 @@ def _submit_work(fn: Callable, *args, **kwargs):
11841207 # Remove pages that are no longer in the app.
11851208 p .unlink ()
11861209
1187- for output_path , code in compile_results :
1188- compiler_utils .write_page (output_path , code )
1210+ with console .timing ("Write to Disk" ):
1211+ for output_path , code in compile_results :
1212+ compiler_utils .write_page (output_path , code )
11891213
11901214 @contextlib .asynccontextmanager
11911215 async def modify_state (self , token : str ) -> AsyncIterator [BaseState ]:
0 commit comments