MCPcopy
hub / github.com/reflex-dev/reflex / compile_app

Function compile_app

reflex/compiler/compiler.py:1093–1410  ·  view source on GitHub ↗

Compile an app using the compiler plugin pipeline. Returns: ``True`` when a real frontend compile ran, ``False`` when the call short-circuited (backend-only paths that only re-evaluate pages).

(
    app: App,
    *,
    prerender_routes: bool = False,
    dry_run: bool = False,
    use_rich: bool = True,
)

Source from the content-addressed store, hash-verified

1091
1092
1093def compile_app(
1094 app: App,
1095 *,
1096 prerender_routes: bool = False,
1097 dry_run: bool = False,
1098 use_rich: bool = True,
1099) -> bool:
1100 """Compile an app using the compiler plugin pipeline.
1101
1102 Returns:
1103 ``True`` when a real frontend compile ran, ``False`` when the call
1104 short-circuited (backend-only paths that only re-evaluate pages).
1105 """
1106 from reflex_base.components.dynamic import bundle_library, reset_bundled_libraries
1107 from reflex_base.utils.exceptions import ReflexRuntimeError
1108
1109 app._apply_decorated_pages()
1110 app._pages = {}
1111
1112 should_compile = app._should_compile()
1113 backend_dir = prerequisites.get_backend_dir()
1114 if not dry_run and not should_compile and backend_dir.exists():
1115 stateful_pages_marker = backend_dir / constants.Dirs.STATEFUL_PAGES
1116 if stateful_pages_marker.exists():
1117 with stateful_pages_marker.open("r") as file:
1118 stateful_pages = json.load(file)
1119 for route in stateful_pages:
1120 console.debug(f"BE Evaluating stateful page: {route}")
1121 app._compile_page(route, save_page=False)
1122 app._add_optional_endpoints()
1123 return False
1124
1125 if constants.Page404.SLUG not in app._unevaluated_pages:
1126 app.add_page(route=constants.Page404.SLUG)
1127
1128 app.style = evaluate_style_namespaces(app.style)
1129 config = get_config()
1130
1131 if not should_compile and not dry_run:
1132 with console.timing("Evaluate Pages (Backend)"):
1133 for route in app._unevaluated_pages:
1134 console.debug(f"Evaluating page: {route}")
1135 app._compile_page(route, save_page=False)
1136
1137 app._write_stateful_pages_marker()
1138 app._add_optional_endpoints()
1139 return False
1140
1141 progress = (
1142 Progress(
1143 *Progress.get_default_columns()[:-1],
1144 MofNCompleteColumn(),
1145 TimeElapsedColumn(),
1146 )
1147 if use_rich
1148 else console.PoorProgress()
1149 )
1150 fixed_steps = 7

Callers

nothing calls this directly

Calls 15

compileMethod · 0.95
get_configFunction · 0.90
ProgressClass · 0.90
reset_bundled_librariesFunction · 0.90
bundle_libraryFunction · 0.90
CompileContextClass · 0.90
CompilerHooksClass · 0.90
default_page_pluginsFunction · 0.90
get_compile_contextFunction · 0.90
is_prod_modeFunction · 0.90

Tested by

no test coverage detected