Remove default features when fullstack is enabled and one platform is enabled in the default features (#3925)
* Don't enable default features when only either the server or client is enabled
This commit is contained in:
1 parent
23286ade2b
commit
8c866b783d
14 files changed
+135
-26
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// This test asserts that the client feature is disable on the server build by the cli
|
||||
// even if it is set as a default feature
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let server_features = use_server_future(get_server_features)?.unwrap().unwrap();
|
||||
let mut client_features = use_signal(Vec::new);
|
||||
use_effect(move || {
|
||||
client_features.set(current_platform_features());
|
||||
});
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
"server features: {server_features:?}"
|
||||
}
|
||||
div {
|
||||
"client features: {client_features:?}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn current_platform_features() -> Vec<String> {
|
||||
let mut features = Vec::new();
|
||||
if cfg!(feature = "web") {
|
||||
features.push("web".to_string());
|
||||
}
|
||||
if cfg!(feature = "server") {
|
||||
features.push("server".to_string());
|
||||
}
|
||||
features
|
||||
}
|
||||
|
||||
#[server]
|
||||
async fn get_server_features() -> Result<Vec<String>, ServerFnError> {
|
||||
Ok(current_platform_features())
|
||||
}
|
||||
Reference in new issue
Block a user