Repository navigation
Description
Describe the bug
Two compounding defects in the bundled-libraries plumbing for dynamic components (relocated but unchanged by the RegistrationContext work):
compile_app()callsreset_bundled_libraries()at the start of every frontend compile and re-adds onlyplugin.get_frontend_dependencies(). Any user/app-levelbundle_library()call made at module import is silently dropped fromwindow.__reflex. Meanwhile the backend worker short-circuitscompile_appbefore the reset and KEEPS the registration — frontend bundle and backend registry end up permanently out of sync.- The dynamic serializer's window-rewrite loop matches only the exact substring
from "<lib>". Subpath imports of a lib that IS in the registry (e.g.rx.icon's package_path formlucide-react/dist/esm/icons/*.mjs) are left as bare specifiers inside the eval'd data-URI module, which browsers can never resolve (no import map applies).
Net effect: the documented-for-plugins bundle_library() pattern is defeated for any library imported via subpaths.
To Reproduce
App that calls bundle_library("lucide-react") at module import time plus a computed var returning an rx.Component that contains rx.icon(...), e.g.:
import reflex as rx
from reflex.components.dynamic import bundle_library
bundle_library("lucide-react")
class State(rx.State):
@rx.var
def dynamic_icon(self) -> rx.Component:
return rx.vstack(rx.icon("apple"))
def index():
return rx.box(State.dynamic_icon)
app = rx.App()
app.add_page(index)Run reflex run and load the page with the browser console open.
Observed behavior
window.__reflexnever containslucide-react(registration wiped by the compile-time reset).- Serialization passes whose context DOES hold the lib emit un-rewritten bare specifiers like
import LucideApple from "lucide-react/dist/esm/icons/apple.mjs"inside the eval'd data-URI module, and the browser throwsTypeError: Failed to resolve module specifier "lucide-react/dist/esm/icons/apple.mjs". - Serializer-level check with zero network: with
"lucide-react"registered, serializingrx.vstack(rx.icon("apple"))emits the bare subpath import — the rewrite loop inreflex_base/components/dynamic.pyonly matches the exactfrom "<lib>"substring, andformat_library_namestrips only the@versionsuffix, not subpaths.
Expected behavior
User bundle_library() registrations survive compilation and land in window.__reflex; subpath imports of bundled libraries are rewritten to resolve against the bundled copy.
Specifics (please complete the following information):
- Python Version: 3.11
- Reflex Version: 0.9.9a1
- OS: linux
- Browser (Optional): Chromium
Additional context
- Severity: low. Not a regression — behavior is byte-identical on 0.9.8 — but worth fixing while the bundled-libraries plumbing is being reworked post-Move more globals to RegistrationContext #6382.
- Found during 0.9.9a1 pre-release testing; the
dynappapp, driver, and dev-run logs are on branchclaude/reflex-prerelease-testing-t0sd90underprerelease-testing/2026-08-27-v0.9.9a1/registration_context/.
Activity
linear-code commentedon Aug 28, 2026
ENG-11814