diff --git a/examples/directives/Cargo.toml b/examples/directives/Cargo.toml index c33b157ee1..50bbe514bd 100644 --- a/examples/directives/Cargo.toml +++ b/examples/directives/Cargo.toml @@ -9,8 +9,8 @@ log = "0.4.22" console_log = "1.0" console_error_panic_hook = "0.1.7" web-sys = { version = "0.3.70", features = ["Clipboard", "Navigator"] } +wasm-bindgen = "0.2.93" [dev-dependencies] wasm-bindgen-test = "0.3.42" -wasm-bindgen = "0.2.93" web-sys = { version = "0.3.70", features = ["NodeList"] } \ No newline at end of file diff --git a/examples/directives/src/lib.rs b/examples/directives/src/lib.rs index adae27c22b..7f7d90faef 100644 --- a/examples/directives/src/lib.rs +++ b/examples/directives/src/lib.rs @@ -50,7 +50,7 @@ impl From<()> for Amount { } pub fn add_dot(el: Element, amount: Amount) { - use leptos::wasm_bindgen::JsCast; + use wasm_bindgen::JsCast; let el = el.unchecked_into::(); let handle = el.clone().on(click, move |_| { diff --git a/examples/js-framework-benchmark/Cargo.toml b/examples/js-framework-benchmark/Cargo.toml index 531ccba9a4..929cb11f79 100644 --- a/examples/js-framework-benchmark/Cargo.toml +++ b/examples/js-framework-benchmark/Cargo.toml @@ -13,8 +13,8 @@ leptos = { path = "../../leptos", features = ["csr"] } # for actual benchmarking getrandom = { version = "0.2.15", features = ["js"] } rand = { version = "0.8.5", features = ["small_rng"] } console_error_panic_hook = "0.1.7" +wasm-bindgen = "0.2" [dev-dependencies] -wasm-bindgen = "0.2" wasm-bindgen-test = "0.3.42" web-sys = "0.3" diff --git a/examples/js-framework-benchmark/src/main.rs b/examples/js-framework-benchmark/src/main.rs index fe2d31aafa..3c11acd16e 100644 --- a/examples/js-framework-benchmark/src/main.rs +++ b/examples/js-framework-benchmark/src/main.rs @@ -1,7 +1,6 @@ use js_framework_benchmark_leptos::App; -use leptos::{ - leptos_dom::helpers::document, mount::mount_to, wasm_bindgen::JsCast, -}; +use leptos::{leptos_dom::helpers::document, mount::mount_to}; +use wasm_bindgen::JsCast; pub fn main() { console_error_panic_hook::set_once(); diff --git a/leptos/src/lib.rs b/leptos/src/lib.rs index 44a2768788..a4dc1fc2d2 100644 --- a/leptos/src/lib.rs +++ b/leptos/src/lib.rs @@ -331,17 +331,20 @@ pub mod task { }; } -// these reexports are used in islands -#[cfg(feature = "islands")] +// Re-exports used in macros. Don't use these directly in your code. #[doc(hidden)] -pub use serde; -#[cfg(feature = "islands")] -#[doc(hidden)] -pub use serde_json; -#[cfg(feature = "tracing")] -#[doc(hidden)] -pub use tracing; -#[doc(hidden)] -pub use wasm_bindgen; -#[doc(hidden)] -pub use web_sys; +pub mod __reexports { + #[cfg(feature = "islands")] + #[doc(hidden)] + pub use serde; + #[cfg(feature = "islands")] + #[doc(hidden)] + pub use serde_json; + #[cfg(feature = "tracing")] + #[doc(hidden)] + pub use tracing; + #[doc(hidden)] + pub use wasm_bindgen; + #[doc(hidden)] + pub use web_sys; +} diff --git a/leptos_dom/src/macro_helpers/tracing_property.rs b/leptos_dom/src/macro_helpers/tracing_property.rs index 488ee807f4..c2c97ea2d2 100644 --- a/leptos_dom/src/macro_helpers/tracing_property.rs +++ b/leptos_dom/src/macro_helpers/tracing_property.rs @@ -4,8 +4,8 @@ use wasm_bindgen::UnwrapThrowExt; /// Use for tracing property macro_rules! tracing_props { () => { - ::leptos::tracing::span!( - ::leptos::tracing::Level::TRACE, + ::leptos::__reexports::tracing::span!( + ::leptos::__reexports::tracing::Level::TRACE, "leptos_dom::tracing_props", props = String::from("[]") ); @@ -23,8 +23,8 @@ macro_rules! tracing_props { )* props.pop(); props.push(']'); - ::leptos::tracing::span!( - ::leptos::tracing::Level::TRACE, + ::leptos::__reexports::tracing::span!( + ::leptos::__reexports::tracing::Level::TRACE, "leptos_dom::tracing_props", props ); diff --git a/leptos_macro/src/component.rs b/leptos_macro/src/component.rs index 3f793b4b05..562e62c320 100644 --- a/leptos_macro/src/component.rs +++ b/leptos_macro/src/component.rs @@ -196,7 +196,7 @@ impl ToTokens for Model { let props_serializer = if is_island_with_other_props { let fields = prop_serializer_fields(vis, props); quote! { - #[derive(::leptos::serde::Deserialize)] + #[derive(::leptos::__reexports::serde::Deserialize)] #vis struct #props_serialized_name { #fields } @@ -241,7 +241,7 @@ impl ToTokens for Model { * * However, until https://github.com/tokio-rs/tracing/pull/1819 is merged * (?), you can't provide an alternate path for `tracing` (for example, - * ::leptos::tracing), which means that if you're going to use the macro + * ::leptos::__reexports::tracing), which means that if you're going to use the macro * you *must* have `tracing` in your Cargo.toml. * * Including the feature-check here causes cargo warnings on @@ -255,7 +255,7 @@ impl ToTokens for Model { let instrument = cfg!(feature = "trace-components").then(|| quote! { #[cfg_attr( feature = "tracing", - ::leptos::tracing::instrument(level = "info", name = #trace_name, skip_all) + ::leptos::__reexports::tracing::instrument(level = "info", name = #trace_name, skip_all) )] }); @@ -265,7 +265,7 @@ impl ToTokens for Model { #instrument }, quote! { - let __span = ::leptos::tracing::Span::current(); + let __span = ::leptos::__reexports::tracing::Span::current(); }, quote! { #[cfg(debug_assertions)] @@ -299,7 +299,7 @@ impl ToTokens for Model { let island_serialize_props = if is_island_with_other_props { quote! { - let _leptos_ser_props = ::leptos::serde_json::to_string(&props).expect("couldn't serialize island props"); + let _leptos_ser_props = ::leptos::__reexports::serde_json::to_string(&props).expect("couldn't serialize island props"); } } else { quote! {} @@ -521,8 +521,8 @@ impl ToTokens for Model { }; let deserialize_island_props = if is_island_with_other_props { quote! { - let props = el.dataset().get(::leptos::wasm_bindgen::intern("props")) - .and_then(|data| ::leptos::serde_json::from_str::<#props_serialized_name>(&data).ok()) + let props = el.dataset().get(::leptos::__reexports::wasm_bindgen::intern("props")) + .and_then(|data| ::leptos::__reexports::serde_json::from_str::<#props_serialized_name>(&data).ok()) .expect("could not deserialize props"); } } else { @@ -531,9 +531,9 @@ impl ToTokens for Model { let hydrate_fn_name = hydrate_fn_name.as_ref().unwrap(); quote! { - #[::leptos::wasm_bindgen::prelude::wasm_bindgen(wasm_bindgen = ::leptos::wasm_bindgen)] + #[::leptos::__reexports::wasm_bindgen::prelude::wasm_bindgen(wasm_bindgen = ::leptos::__reexports::wasm_bindgen)] #[allow(non_snake_case)] - pub fn #hydrate_fn_name(el: ::leptos::web_sys::HtmlElement) { + pub fn #hydrate_fn_name(el: ::leptos::__reexports::web_sys::HtmlElement) { #deserialize_island_props let island = #name(#island_props); let state = island.hydrate_from_position::(&el, ::leptos::tachys::view::Position::Current); @@ -546,7 +546,7 @@ impl ToTokens for Model { }; let props_derive_serialize = if is_island_with_other_props { - quote! { , ::leptos::serde::Serialize } + quote! { , ::leptos::__reexports::serde::Serialize } } else { quote! {} };