Skip to content

Commit cbb4027

Browse files
committed
Merge remote-tracking branch 'origin/main' into masenf/linked-state
2 parents 949e7c2 + 805ad97 commit cbb4027

16 files changed

Lines changed: 624 additions & 267 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "reflex"
3-
version = "0.8.22dev1"
3+
version = "0.8.23dev1"
44
description = "Web apps in pure Python."
55
license.text = "Apache-2.0"
66
authors = [

reflex/compiler/templates.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ def context_template(
378378
return ({{ children, ...props }}) => {{
379379
const [Component, setComponent] = useState(null);
380380
useEffect(() => {{
381-
setComponent(component);
381+
async function load() {{
382+
const comp = await component();
383+
setComponent(() => comp);
384+
}}
385+
load();
382386
}}, []);
383387
return Component ? jsx(Component, props, children) : null;
384388
}};
@@ -581,9 +585,6 @@ def vite_config_template(
581585
enableNativePlugin: false,
582586
hmr: {"true" if experimental_hmr else "false"},
583587
}},
584-
legacy: {{
585-
inconsistentCjsInterop: true,
586-
}},
587588
server: {{
588589
port: process.env.PORT,
589590
hmr: {"true" if hmr else "false"},

reflex/components/component.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,6 @@ def _get_imports(self) -> ParsedImportDict:
22322232
"""
22332233
# React lazy import mechanism.
22342234
dynamic_import = {
2235-
"react": [ImportVar(tag="lazy")],
22362235
f"$/{constants.Dirs.UTILS}/context": [ImportVar(tag="ClientSide")],
22372236
}
22382237

@@ -2263,15 +2262,15 @@ def _get_dynamic_imports(self) -> str:
22632262
library_import = f"import('{import_name}')"
22642263
mod_import = (
22652264
# https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#with-named-exports
2266-
f".then((mod) => ({{default: mod.{self.tag}}}))"
2265+
f".then((mod) => mod.{self.tag})"
22672266
if not self.is_default
2268-
else ""
2267+
else ".then((mod) => mod.default.default ?? mod.default)"
22692268
)
22702269
return (
2271-
f"const {self.alias or self.tag} = ClientSide(lazy(() => "
2270+
f"const {self.alias or self.tag} = ClientSide(() => "
22722271
+ library_import
22732272
+ mod_import
2274-
+ "))"
2273+
+ ")"
22752274
)
22762275

22772276

reflex/components/plotly/plotly.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ def dynamic_plotly_import(name: str, package: str) -> str:
288288
The dynamic import for the plotly component.
289289
"""
290290
library_import = f"import('{package}')"
291-
mod_import = ".then((mod) => ({ default: createPlotlyComponent(mod) }))"
291+
mod_import = ".then((mod) => createPlotlyComponent(mod))"
292292
return f"""
293-
const {name} = ClientSide(lazy(() =>
293+
const {name} = ClientSide(() =>
294294
{library_import}{mod_import}
295-
))
295+
)
296296
"""
297297

298298

reflex/constants/installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bun(SimpleNamespace):
1414
"""Bun constants."""
1515

1616
# The Bun version.
17-
VERSION = "1.3.3"
17+
VERSION = "1.3.4"
1818

1919
# Min Bun Version
2020
MIN_VERSION = "1.3.0"

reflex/environment.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ class EnvironmentVariables:
583583
# Path to the alembic config file
584584
ALEMBIC_CONFIG: EnvVar[ExistingPath] = env_var(Path(constants.ALEMBIC_CONFIG))
585585

586+
# Include schemas in alembic migrations.
587+
ALEMBIC_INCLUDE_SCHEMAS: EnvVar[bool] = env_var(False)
588+
586589
# Disable SSL verification for HTTPX requests.
587590
SSL_NO_VERIFY: EnvVar[bool] = env_var(False)
588591

reflex/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ def run_autogenerate(rev: str, context: MigrationContext):
518518
render_item=cls._alembic_render_item,
519519
process_revision_directives=writer,
520520
compare_type=False,
521+
include_schemas=environment.ALEMBIC_INCLUDE_SCHEMAS.get(),
521522
render_as_batch=True, # for sqlite compatibility
522523
)
523524
env.run_migrations()

reflex/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ def _is_valid_type(events: Any) -> bool:
17701770
if events is None or _is_valid_type(events):
17711771
return events
17721772

1773-
if not isinstance(events, Sequence):
1773+
if not (isinstance(events, Sequence) and not isinstance(events, (str, bytes))):
17741774
events = [events]
17751775

17761776
try:

reflex/testing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from typing import TYPE_CHECKING, Any, Literal, TypeVar
2727

2828
import uvicorn
29+
from typing_extensions import Self
2930

3031
import reflex
3132
import reflex.reflex
@@ -131,7 +132,7 @@ def create(
131132
Callable[[], None] | types.ModuleType | str | functools.partial[Any] | None
132133
) = None,
133134
app_name: str | None = None,
134-
) -> AppHarness:
135+
) -> Self:
135136
"""Create an AppHarness instance at root.
136137
137138
Args:
@@ -453,7 +454,7 @@ def consume_frontend_output():
453454
self.frontend_output_thread = threading.Thread(target=consume_frontend_output)
454455
self.frontend_output_thread.start()
455456

456-
def start(self) -> AppHarness:
457+
def start(self) -> Self:
457458
"""Start the backend in a new thread and dev frontend as a separate process.
458459
459460
Returns:
@@ -482,7 +483,7 @@ def get_app_global_source(key: str, value: Any):
482483
return f"{key} = {value!r}"
483484
return inspect.getsource(value)
484485

485-
def __enter__(self) -> AppHarness:
486+
def __enter__(self) -> Self:
486487
"""Contextmanager protocol for `start()`.
487488
488489
Returns:

reflex/utils/build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ def build():
199199
path_ops.rm(str(wdir / constants.Dirs.BUILD_DIR))
200200

201201
checkpoints = [
202-
"building for production",
203-
"building SSR bundle for production",
202+
"building client environment for production...",
203+
"modules transformed",
204+
"building ssr environment for production...",
204205
"built in",
205206
]
206207

0 commit comments

Comments
 (0)