Skip to content

Skip saving page components when skipping compile output #4653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions reflex/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,12 @@ def add_page(
meta=meta,
)

def _compile_page(self, route: str):
def _compile_page(self, route: str, save_page: bool = True):
"""Compile a page.

Args:
route: The route of the page to compile.
save_page: If True, the compiled page is saved to self.pages.
"""
component, enable_state = compiler.compile_unevaluated_page(
route, self.unevaluated_pages[route], self.state, self.style, self.theme
Expand All @@ -579,7 +580,8 @@ def _compile_page(self, route: str):

# Add the page.
self._check_routes_conflict(route)
self.pages[route] = component
if save_page:
self.pages[route] = component

def get_load_events(self, route: str) -> list[IndividualEventType[[], Any]]:
"""Get the load events for a route.
Expand Down Expand Up @@ -879,14 +881,16 @@ def get_compilation_time() -> str:
# If a theme component was provided, wrap the app with it
app_wrappers[(20, "Theme")] = self.theme

should_compile = self._should_compile()

for route in self.unevaluated_pages:
console.debug(f"Evaluating page: {route}")
self._compile_page(route)
self._compile_page(route, save_page=should_compile)

# Add the optional endpoints (_upload)
self._add_optional_endpoints()

if not self._should_compile():
if not should_compile:
return

self._validate_var_dependencies()
Expand Down
Loading