Compile the app and output it to the pages folder. Args: prerender_routes: Whether to prerender the routes. dry_run: Whether to compile the app without saving it. use_rich: Whether to use rich progress bars. trigger: Label identifying what ini
(
self,
prerender_routes: bool = False,
dry_run: bool = False,
use_rich: bool = True,
trigger: CompileTrigger | None = None,
)
| 1293 | self._validate_var_dependencies(substate) |
| 1294 | |
| 1295 | def _compile( |
| 1296 | self, |
| 1297 | prerender_routes: bool = False, |
| 1298 | dry_run: bool = False, |
| 1299 | use_rich: bool = True, |
| 1300 | trigger: CompileTrigger | None = None, |
| 1301 | ): |
| 1302 | """Compile the app and output it to the pages folder. |
| 1303 | |
| 1304 | Args: |
| 1305 | prerender_routes: Whether to prerender the routes. |
| 1306 | dry_run: Whether to compile the app without saving it. |
| 1307 | use_rich: Whether to use rich progress bars. |
| 1308 | trigger: Label identifying what initiated this compile. Recorded |
| 1309 | on the ``compile`` telemetry event. |
| 1310 | |
| 1311 | Raises: |
| 1312 | ReflexRuntimeError: When any page uses state, but no rx.State subclass is defined. |
| 1313 | FileNotFoundError: When a plugin requires a file that does not exist. |
| 1314 | """ |
| 1315 | ctx = TelemetryContext.start(trigger=trigger) |
| 1316 | if ctx is None: |
| 1317 | compiler.compile_app( |
| 1318 | self, |
| 1319 | prerender_routes=prerender_routes, |
| 1320 | dry_run=dry_run, |
| 1321 | use_rich=use_rich, |
| 1322 | ) |
| 1323 | return |
| 1324 | |
| 1325 | with ctx: |
| 1326 | did_real_compile = False |
| 1327 | try: |
| 1328 | did_real_compile = compiler.compile_app( |
| 1329 | self, |
| 1330 | prerender_routes=prerender_routes, |
| 1331 | dry_run=dry_run, |
| 1332 | use_rich=use_rich, |
| 1333 | ) |
| 1334 | except Exception as exc: |
| 1335 | ctx.set_exception(exc) |
| 1336 | did_real_compile = True |
| 1337 | raise |
| 1338 | finally: |
| 1339 | if did_real_compile: |
| 1340 | telemetry_accounting.record_compile(self, ctx) |
| 1341 | |
| 1342 | def _write_stateful_pages_marker(self): |
| 1343 | """Write list of routes that create dynamic states for the backend to use later.""" |