Skip to content

Commit

Permalink
slightly smaller fullstack builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff committed May 28, 2024
1 parent cdd3977 commit c65fe1a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 18 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions packages/cli-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,46 @@ pub static CURRENT_CONFIG: once_cell::sync::Lazy<
})
});

/// Get just the base path from the config without pulling in serde_json
pub const fn current_config_base_path() -> Option<&'static str> {
// Find "base_path": "path/to/base"
match CURRENT_CONFIG_JSON {
Some(json) => {
let mut index = 0;
let mut search_index = 0;
let search_for = r#""base_path":""#;
while index < json.len() {
let char = json.as_bytes()[index];
if char == b' ' {
index += 1;
continue;
}
if char == search_for.as_bytes()[search_index] {
search_index += 1;
}
if search_index == search_for.len() {
// Find the end of the string
let mut end_index = index + search_for.len();
while end_index < json.len() {
let char = json.as_bytes()[end_index];
if char == b'"' {
break;
}
end_index += 1;
}
let (_, after_start) = json.as_bytes().split_at(index);
let (before_end, _) = after_start.split_at(end_index - index);
// SAFETY: We are slicing into a valid UTF-8 string
return Some(unsafe { std::str::from_utf8_unchecked(before_end) });
}
index += 1
}
None
}
None => None,
}
}

#[cfg(feature = "read-config")]
/// The current crate's configuration.
pub const CURRENT_CONFIG_JSON: Option<&str> = std::option_env!("DIOXUS_CONFIG");
5 changes: 0 additions & 5 deletions packages/core/src/diff/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ impl VirtualDom {
scope_id: ScopeId,
) {
let scope = &mut self.scopes[scope_id.0];
println!(
"running {:?} vs {:?}",
scope.props.props().type_id(),
TypeId::of::<SuspenseBoundaryPropsWithOwner>()
);
if SuspenseBoundaryProps::downcast_from_props(&mut *scope.props).is_some() {
SuspenseBoundaryProps::diff(scope_id, self, to)
} else {
Expand Down
3 changes: 1 addition & 2 deletions packages/fullstack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ anymap = { version = "0.12.1", optional = true }
async-trait = { version = "0.1.58", optional = true }

serde = "1.0.159"
serde_json = { version = "1.0.95", optional = true }
tokio-stream = { version = "0.1.12", features = ["sync"], optional = true }
futures-util = { workspace = true }
futures-channel = { workspace = true }
Expand Down Expand Up @@ -71,7 +70,7 @@ dioxus = { workspace = true, features = ["fullstack"] }

[features]
default = ["hot-reload"]
hot-reload = ["serde_json", "dioxus-web?/hot_reload", "dioxus-hot-reload/serve"]
hot-reload = ["dioxus-web?/hot_reload", "dioxus-hot-reload/serve"]
mounted = ["dioxus-web?/mounted"]
file_engine = ["dioxus-web?/file_engine"]
eval = ["dioxus-web?/eval"]
Expand Down
5 changes: 1 addition & 4 deletions packages/html/src/render_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ fn render_template_node(node: &TemplateNode, out: &mut String) -> std::fmt::Resu
write!(out, "</{tag}>")?;
}
TemplateNode::Text { text: t } => write!(out, "{t}")?,
TemplateNode::Dynamic { id: _ } => {
todo!("handle dynamic text nodes?");
write!(out, "<pre hidden />")?
} // TemplateNode::DynamicText { id: t } => write!(out, "<!-- --> {t} <!-- -->")?,
TemplateNode::Dynamic { id: _ } => write!(out, "<pre hidden />")?,
};
Ok(())
}
9 changes: 3 additions & 6 deletions packages/router/src/history/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ use super::{

#[allow(dead_code)]
fn base_path() -> Option<&'static str> {
let base_path = dioxus_cli_config::CURRENT_CONFIG
.as_ref()
.ok()
.and_then(|c| c.dioxus_config.web.app.base_path.as_deref());
tracing::trace!("Using base_path from Dioxus.toml: {:?}", base_path);
base_path
const BASE_PATH: Option<&'static str> = dioxus_cli_config::current_config_base_path();
tracing::trace!("Using base_path from Dioxus.toml: {:?}", BASE_PATH);
BASE_PATH
}

#[allow(clippy::extra_unused_type_parameters)]
Expand Down

0 comments on commit c65fe1a

Please sign in to comment.