Skip to content

Commit acf503a

Browse files
authored
Fix #[cfg_ssr] and #[cfg_not_ssr] to use is_ssr! and is_not_ssr! macros. (#801)
Update cfg_ssr and cfg_not_ssr attribute macros to use is_ssr! and is_not_ssr!
1 parent b4e3cd7 commit acf503a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/sycamore-macro/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ pub fn derive_props(input: TokenStream) -> TokenStream {
7373
pub fn cfg_ssr(_args: TokenStream, input: TokenStream) -> TokenStream {
7474
let input: proc_macro2::TokenStream = input.into();
7575
quote! {
76-
#[cfg(any(not(target_arch = "wasm32"), sycamore_force_ssr))]
77-
#input
76+
::sycamore::web::is_ssr! {
77+
#input
78+
}
7879
}
7980
.into()
8081
}
@@ -97,8 +98,9 @@ pub fn cfg_ssr(_args: TokenStream, input: TokenStream) -> TokenStream {
9798
pub fn cfg_not_ssr(_args: TokenStream, input: TokenStream) -> TokenStream {
9899
let input: proc_macro2::TokenStream = input.into();
99100
quote! {
100-
#[cfg(all(target_arch = "wasm32", not(sycamore_force_ssr)))]
101-
#input
101+
::sycamore::web::is_not_ssr! {
102+
#input
103+
}
102104
}
103105
.into()
104106
}

packages/sycamore-web/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ pub use self::suspense::*;
6969
pub use self::view::*;
7070

7171
/// We add this to make the macros from `sycamore-macro` work properly.
72+
/// We also add the `web` module so that the macros can access `::sycamore::web` correctly.
7273
extern crate self as sycamore;
74+
mod web {
75+
pub use crate::*;
76+
}
7377

7478
#[doc(hidden)]
7579
pub mod rt {

0 commit comments

Comments
 (0)