Fix bundled library subpath serialization - #7016
Conversation
Greptile SummaryThe PR preserves explicit bundled-library registrations across compilation and routes dynamic subpath imports through their corresponding
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/reflex-base/src/reflex_base/components/dynamic.py | Tracks explicit registrations separately and reconstructs bundled subpath imports from exact window namespace entries. |
| packages/reflex-base/src/reflex_base/registry.py | Adds registration-context storage and copying for explicitly bundled libraries. |
| reflex/compiler/compiler.py | Preserves explicit registrations during compile resets and generates collision-free window-library aliases. |
| packages/reflex-components-radix/src/reflex_components_radix/plugin.py | Registers Radix Themes as a compile-derived dependency while retaining compatibility with older reflex-base versions. |
| tests/units/compiler/test_dynamic_components_codegen.py | Covers exact-subpath default and named import reconstruction plus app-root bundling. |
| tests/units/compiler/test_compiler.py | Covers explicit-registration preservation, stale derived-registration removal, and normalized alias collisions. |
| tests/integration/test_dynamic_components.py | Exercises a dynamically rendered Lucide icon through the browser integration path. |
Reviews (4): Last reviewed commit: "Document bundled library helper return v..." | Re-trigger Greptile
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
can you explain what scenarios result in triggering this bug? i understand what's going on, but it seems like most situations that matter, like hot-reload would end up re-bundling the needed libraries anyway. |
|
I agree that normal hot-reload may re-run the app module and re-register the library, which can mask the problem. The bug is not limited to source-file hot-reload, though. The failure occurs when bundle_library() is called during app/component registration and compile_app() later resets the bundled-library list before compilation. Examples include repeated compilation in the same process, cached app modules, compiler/AppHarness tests, export/build paths, and dynamic component serialization. In those cases, the explicit library registration is lost even though the app/context is still valid. Hot- reload may re-register it, but the compiler should not depend on hot- reload re-executing user code to preserve an explicit registration. |
Summary
Fixes issue #6975.
compile_app()was clearing explicitbundle_library()registrations during frontend compilation. Dynamic componentsalso failed to rewrite bundled library subpath imports, such as Lucide deep imports.
Changes
window.__reflex.Tests
uv run pytest tests/units/compiler/test_dynamic_components_codegen.py tests/units/compiler/test_compiler.py -quv run pytest tests/integration/test_dynamic_components.py -q