Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions templates/leptos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ leptos_meta = { version = "0.8" }
leptos_router = { version = "0.8"{% if use_nightly %}, features = ["nightly"]{% endif %} }
tower-service = "0.3"
wasm-bindgen = "0.2"
worker = { version = "0.5", features = ["http", "axum", "d1"], optional = true }
worker = { version = "0.6", features = ["http", "axum", "d1"], optional = true }

[features]
hydrate = ["leptos/hydrate"]
Expand All @@ -35,6 +35,12 @@ ssr = [
"leptos_router/ssr",
]

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[package.metadata.wasm-pack.profile.dev]
wasm-opt = false

[package.metadata.leptos]
wasm-validation = false
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
Expand Down Expand Up @@ -95,4 +101,4 @@ lib-features = ["hydrate"]
# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false
lib-default-features = false
20 changes: 20 additions & 0 deletions templates/leptos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ use crate::app::*;
pub mod app;
mod components;


#[cfg(feature = "ssr")]
#[cfg(target_family = "wasm")]
mod wasm_workaround {
unsafe extern "C" {
pub(super) fn __wasm_call_ctors();
}
}

#[cfg(feature = "ssr")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
fn start() {
// Fix for 'Read a negative address value from the stack. Did we run out of memory?'.
// See: https://github.com/cloudflare/workers-rs/issues/772
#[cfg(target_family = "wasm")]
unsafe {
wasm_workaround::__wasm_call_ctors()
};
}

#[cfg(feature = "ssr")]
pub fn register_server_functions() {
use leptos::server_fn::axum::register_explicit;
Expand Down