use bundled radix ui for dynamic components (#3993)
This commit is contained in:
parent
3eeb0bde9c
commit
982c43d595
@ -57,12 +57,20 @@ def load_dynamic_serializer():
|
||||
)
|
||||
] = None
|
||||
|
||||
libs_in_window = [
|
||||
"react",
|
||||
"@radix-ui/themes",
|
||||
]
|
||||
|
||||
imports = {}
|
||||
for lib, names in component._get_all_imports().items():
|
||||
if (
|
||||
not lib.startswith((".", "/"))
|
||||
and not lib.startswith("http")
|
||||
and lib != "react"
|
||||
and all(
|
||||
not lib.startswith(lib_in_window)
|
||||
for lib_in_window in libs_in_window
|
||||
)
|
||||
):
|
||||
imports[get_cdn_url(lib)] = names
|
||||
else:
|
||||
@ -83,10 +91,16 @@ def load_dynamic_serializer():
|
||||
)
|
||||
+ "]"
|
||||
)
|
||||
elif 'from "react"' in line:
|
||||
module_code_lines[ix] = line.replace(
|
||||
"import ", "const ", 1
|
||||
).replace(' from "react"', " = window.__reflex.react", 1)
|
||||
else:
|
||||
for lib in libs_in_window:
|
||||
if f'from "{lib}"' in line:
|
||||
module_code_lines[ix] = (
|
||||
line.replace("import ", "const ", 1)
|
||||
.replace(
|
||||
f' from "{lib}"', f" = window.__reflex['{lib}']", 1
|
||||
)
|
||||
.replace(" as ", ": ")
|
||||
)
|
||||
if line.startswith("export function"):
|
||||
module_code_lines[ix] = line.replace(
|
||||
"export function", "export default function", 1
|
||||
|
Loading…
Reference in New Issue
Block a user