-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Currently, when using the pagefind crate as a library inside another Rust project, the crate pulls in ~340 dependencies, including actix, even when the "serve" functionality is not being used at all inside the project.
I think it would be beneficial to make the actix dependency (there might me more unneeded, but haven't checked anything else) optional and put the "serve" functionality behind a compile flag.
This can be done as follows (example):
In Cargo.toml
# ...
[features]
default = ["serve"]
serve = ["dep:actix-web", "dep:actix-files", "dep:portpicker"]
# ...
[dependencies]
# ...
actix-web = { version = "4", optional = true }
actix-files = { version = "0.6", optional = true }
portpicker = { version = "0.1", optional = true }In *.rs:
// ...
#[cfg(feature = "serve")] // +
mod serve;
// ...I think it would be generally beneficial to try to trim down the binary size for use cases that don't require as many features as a standalone binary program. This serve feature seems like a low-hanging fruit to me, because it cuts down dependencies from 342 to 214.
Full git diff output: diff.txt