From 59b862627722b7af0ee9b5fb5efddeca675604ef Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 3 May 2023 16:25:35 -0400 Subject: [PATCH] docs: switch from compile errors to runtime warnings for incompatible feature flags (#990) --- leptos/src/lib.rs | 21 --------------------- leptos_dom/src/lib.rs | 9 +++++++++ leptos_dom/src/ssr.rs | 9 +++++++++ leptos_dom/src/ssr_in_order.rs | 9 +++++++++ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/leptos/src/lib.rs b/leptos/src/lib.rs index e3e97f77f..6524fd623 100644 --- a/leptos/src/lib.rs +++ b/leptos/src/lib.rs @@ -240,24 +240,3 @@ pub fn component_props_builder( ) ->

::Builder {

::builder() } - -#[cfg(all(not(doc), feature = "csr", feature = "ssr"))] -compile_error!( - "You have both `csr` and `ssr` enabled as features, which may cause \ - issues like ` failing to work silently. `csr` is enabled by \ - default on `leptos`, and can be disabled by adding `default-features = \ - false` to your `leptos` dependency." -); - -#[cfg(all(not(doc), feature = "hydrate", feature = "ssr"))] -compile_error!( - "You have both `hydrate` and `ssr` enabled as features, which may cause \ - issues like ` failing to work silently." -); - -#[cfg(all(not(doc), feature = "hydrate", feature = "csr"))] -compile_error!( - "You have both `hydrate` and `csr` enabled as features, which may cause \ - issues. `csr` is enabled by default on `leptos`, and can be disabled by \ - adding `default-features = false` to your `leptos` dependency." -); diff --git a/leptos_dom/src/lib.rs b/leptos_dom/src/lib.rs index de0536558..87764c0cd 100644 --- a/leptos_dom/src/lib.rs +++ b/leptos_dom/src/lib.rs @@ -834,6 +834,15 @@ where F: FnOnce(Scope) -> N + 'static, N: IntoView, { + #[cfg(all(feature = "web", feature = "ssr"))] + crate::console_warn( + "You have both `csr` and `ssr` or `hydrate` and `ssr` enabled as \ + features, which may cause issues like ` failing to work \ + silently. `csr` is enabled by default on `leptos`, and can be \ + disabled by adding `default-features = false` to your `leptos` \ + dependency.", + ); + cfg_if! { if #[cfg(all(target_arch = "wasm32", feature = "web"))] { mount_to(crate::document().body().expect("body element to exist"), f) diff --git a/leptos_dom/src/ssr.rs b/leptos_dom/src/ssr.rs index 3c0b0eeae..456a783d4 100644 --- a/leptos_dom/src/ssr.rs +++ b/leptos_dom/src/ssr.rs @@ -271,6 +271,15 @@ impl View { instrument(level = "info", skip_all,) )] pub fn render_to_string(self, _cx: Scope) -> Cow<'static, str> { + #[cfg(all(feature = "web", feature = "ssr"))] + crate::console_error( + "\n[DANGER] You have both `csr` and `ssr` or `hydrate` and `ssr` \ + enabled as features, which may cause issues like ` \ + failing to work silently. `csr` is enabled by default on \ + `leptos`, and can be disabled by adding `default-features = \ + false` to your `leptos` dependency.\n", + ); + self.render_to_string_helper(false) } diff --git a/leptos_dom/src/ssr_in_order.rs b/leptos_dom/src/ssr_in_order.rs index e52f46fdb..20ad40535 100644 --- a/leptos_dom/src/ssr_in_order.rs +++ b/leptos_dom/src/ssr_in_order.rs @@ -55,6 +55,15 @@ pub fn render_to_stream_in_order_with_prefix( view: impl FnOnce(Scope) -> View + 'static, prefix: impl FnOnce(Scope) -> Cow<'static, str> + 'static, ) -> impl Stream { + #[cfg(all(feature = "web", feature = "ssr"))] + crate::console_error( + "\n[DANGER] You have both `csr` and `ssr` or `hydrate` and `ssr` \ + enabled as features, which may cause issues like ` \ + failing to work silently. `csr` is enabled by default on `leptos`, \ + and can be disabled by adding `default-features = false` to your \ + `leptos` dependency.\n", + ); + let (stream, runtime, _) = render_to_stream_in_order_with_prefix_undisposed_with_context( view,