-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interest in a "lite" feature? #470
Comments
Hi! I am generally in favor of enabling users to have fewer dependencies, especially ones that they might not always need. However, as far as I know, the common practice is designing features to be additive, how would it work with the possible Btw, from the absolute numbers point of view, what are the exact improvements let's say on
|
How this would work on the Cargo.toml level - I'm not really sure. Some crates do use mutually exclusive features for selecting different backends, e.g. https://github.com/rust-lang/flate2-rs#backends – this always seems to come with caveats, either errors if there are conflicting feature requirements in the dependency tree or ignoring some of them. I think it should be possible to write it in a way that specifying both full/standard features and "lite" would result in the former instead of an error. Probably something like this: [features]
default = ["resolve-http", "resolve-file", "cli", "full"]
full = ["dep:regex", "dep:fancy_regex", "..."]
lite = ["dep:regex_lite"]
cli = ["clap"]
draft201909 = []
draft202012 = []
resolve-http = ["reqwest"]
resolve-file = [] And then resolving e.g. regex to As for specific numbers, here is an example in a CLI project with a fairly typical dependency tree: There’s clap, serde and a few other crates in there.
Interestingly on AArch64 binary size increases more: from 2.7M to 4.4M (+62% - the absolute increase is similar). |
Awesome! Thank you for such a detailed report :) it would definitely be useful to have! |
This is a very good library with solid coverage of the JSON schema spec. However, both JSON and JSON schema especially have a few corner cases that are particularly difficult to handle. JSON itself has the whole "what's a number, really?" thing, and JSON schema has a few interesting corners in the spec like:
These add considerable amounts of code to jsonschema; fancy regex and the "high-end"
regex
crate seem to add up to about 1 MB of code these days. Just the special case of multipleOf with a float multiple adds a bignum math library.I suspect that many end-users don't use these corners of the spec (I know I don't) and could benefit from a "lite" feature set:
I did some haphazard exploration of adding this and it doesn't seem to be particularly annoying. The biggest change would be introducing a module (or just a bunch of
#[cfg] use
inlib.rs
) to select between the different regex engines for the different use-cases, since fancy-regex is only used for matching schema-supplied RE, whileregex
is used for internal REs.lite
would switch both of these toregex-lite
. The remainder is pretty much just a few cfg attributes to disable some validators. I haven't looked at tests though, yet.The text was updated successfully, but these errors were encountered: