Skip to content

Commit 12eca0e

Browse files
committed
dynamic: bundle local $/utils/components (rx.memo) module
allow `@rx.memo` decorated functions to be referenced by dynamic components (which allows working around most limitations with dynamic components). move special cases for $/ prefix modules to `_normalize_library_path` and include them in `bundled_libraries` so they can be checked at runtime.
1 parent b1fd273 commit 12eca0e

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

reflex/compiler/compiler.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _normalize_library_name(lib: str) -> str:
5656
"""
5757
if lib == "react":
5858
return "React"
59-
return lib.replace("@", "").replace("/", "_").replace("-", "_")
59+
return lib.replace("$/", "").replace("@", "").replace("/", "_").replace("-", "_")
6060

6161

6262
def _compile_app(app_root: Component) -> str:
@@ -72,9 +72,6 @@ def _compile_app(app_root: Component) -> str:
7272

7373
window_libraries = [
7474
(_normalize_library_name(name), name) for name in bundled_libraries
75-
] + [
76-
("utils_context", f"$/{constants.Dirs.UTILS}/context"),
77-
("utils_state", f"$/{constants.Dirs.UTILS}/state"),
7875
]
7976

8077
return templates.APP_ROOT.render(

reflex/components/dynamic.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ def get_cdn_url(lib: str) -> str:
2626
return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm"
2727

2828

29-
bundled_libraries = {"react", "@radix-ui/themes", "@emotion/react", "next/link"}
29+
bundled_libraries = {
30+
"react",
31+
"@radix-ui/themes",
32+
"@emotion/react",
33+
"next/link",
34+
f"$/{constants.Dirs.UTILS}/context",
35+
f"$/{constants.Dirs.UTILS}/state",
36+
f"$/{constants.Dirs.UTILS}/components",
37+
}
3038

3139

3240
def bundle_library(component: Union["Component", str]):

0 commit comments

Comments
 (0)