diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index 5b780013c..61be4d48e 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -20,7 +20,6 @@ prettyplease = "0.1" proc-macro-error = "1" proc-macro2 = "1" quote = "1" -serde = "1" syn = { version = "1", features = ["full"] } syn-rsx = "0.9" uuid = { version = "1", features = ["v4"] } @@ -33,6 +32,7 @@ convert_case = "0.6.0" [dev-dependencies] log = "0.4" typed-builder = "0.11" +leptos = { path = "../leptos" } [features] default = ["ssr"] diff --git a/leptos_macro/src/server.rs b/leptos_macro/src/server.rs index b883d4ddf..821767549 100644 --- a/leptos_macro/src/server.rs +++ b/leptos_macro/src/server.rs @@ -43,7 +43,7 @@ pub fn server_macro_impl(args: proc_macro::TokenStream, s: TokenStream2) -> Resu let block = body.block; cfg_if! { - if #[cfg(not(feature = "stable"))] { + if #[cfg(all(not(feature = "stable"), debug_assertions))] { use proc_macro::Span; let span = Span::call_site(); #[cfg(not(target_os = "windows"))] diff --git a/leptos_server/src/lib.rs b/leptos_server/src/lib.rs index 575020a26..745910024 100644 --- a/leptos_server/src/lib.rs +++ b/leptos_server/src/lib.rs @@ -326,9 +326,19 @@ where let mut write = REGISTERED_SERVER_FUNCTIONS .write() .map_err(|e| ServerFnError::Registration(e.to_string()))?; - write.insert(Self::url(), run_server_fn); + let prev = write.insert(Self::url(), run_server_fn); - Ok(()) + // if there was already a server function with this key, + // return Err + match prev { + Some(_) => Err(ServerFnError::Registration(format!( + "There was already a server function registered at {:?}. \ + This can happen if you use the same server function name in two different modules + on `stable` or in `release` mode.", + Self::url() + ))), + None => Ok(()), + } } }