lib is compiled two times #2185
-
I have this function: #[server(FetchPastTempTargets)]
pub async fn fetch_past_temp_targets() -> Result<Vec<MonitoringTempTargetData>, ServerFnError> {
#[cfg(feature = "ssr")]
return Ok(crate::behavior::load_temp_targets()?);
#[cfg(not(feature = "ssr"))]
Err(ServerFnError::ServerError("Unreachable".to_string()))
} declared it in a module both lib.rs (wasm frontend) and main.rs (server) have access to. I can't compile it because the compilation of lib.rs fails with
Which should not happen under any circumstances because of
The I am slowly losing my sanity to this one because it does not make any sense. It seems as if wasm (lib) is compiled twice, once with the correct "hydrate" feature, and once with the "ssr" feature enabled, which is beyond scuffed. I have no clue where this could originate from, I even started looking into the My leptos cargo.toml: [package.metadata.leptos]
output-name = "app"
assets-dir = "public"
# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]
# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false
# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
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
# The profile to use for the lib target when compiling for release
#
# Optional. Defaults to "release".
lib-profile-release = "wasm-release" |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
What is the rest of your cargo.toml like? Specifically the dependencies and features sections. |
Beta Was this translation helpful? Give feedback.
-
I found the answer. Because lib is also compiled when compiling the bin, of course it is unable to find the I have to safeguard the whole content of lib.rs inside a |
Beta Was this translation helpful? Give feedback.
I found the answer. Because lib is also compiled when compiling the bin, of course it is unable to find the
behavior
module. And since the "ssr" feature is enabled, the server function compiles to the server version.I have to safeguard the whole content of lib.rs inside a
#[cfg(feature = "hydrate")]
. I originally removed that and solved it differently. But now it works again.