put import at the top of dynamic component evaluation (#4632)

This commit is contained in:
Khaleel Al-Adhami 2025-01-15 14:17:58 -08:00 committed by GitHub
parent e8a7112249
commit caf29c3680
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -136,6 +136,23 @@ def load_dynamic_serializer():
module_code_lines.insert(0, "const React = window.__reflex.react;")
function_line = next(
index
for index, line in enumerate(module_code_lines)
if line.startswith("export default function")
)
module_code_lines = [
line
for _, line in sorted(
enumerate(module_code_lines),
key=lambda x: (
not (x[1].startswith("import ") and x[0] < function_line),
x[0],
),
)
]
return "\n".join(
[
"//__reflex_evaluate",