pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

Cargo Features to slim down transitive dependencies for simpler cases #290

Closed markdingram closed 1 year ago

markdingram commented 1 year ago

(from https://pact-foundation.slack.com/archives/CA2S7E6KC/p1686600740215599)

Has there ever been any discussion whether it would be desirable/feasible to slim down the transitive dependencies of the Pact crates for simpler use cases?

I find myself reluctant to add Pact right now to the main project workspace as the deps added to the Cargo.lock dwarf the (admittedly simple) set that are currently used in my Axum / JSON Rest service. I wonder if I’m missing the intended usage pattern?

See the attached graph from the pact_consumer crate cargo depgraph --root pact_consumer --build-deps --filter-platform x86_64-unknown-linux-gnu --dedup-transitive-deps | dot -Tpng > pact_consumer_graph.svg

rholshausen commented 1 year ago

pact_consumer 1.0.2 now has a number of features to remove functionality and associated dependencies.

markdingram commented 1 year ago

Thanks for this, it's looking really promising.

I get an error with:

pact_consumer = { version = "=1.0.2", default-features = false }
error[E0432]: unresolved import `pact_models::time_utils`
 --> /Users/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pact_consumer-1.0.2/src/patterns/date_time.rs:7:18
  |
7 | use pact_models::time_utils::parse_pattern;
  |                  ^^^^^^^^^^ could not find `time_utils` in `pact_models`

Works fine with

pact_consumer = { version = "=1.0.2", default-features = false, features = ["datetime"] }

but that of course pulls in a few extra crates once more.

rholshausen commented 1 year ago

So sorry, I don't know how I missed that. Try 1.0.3

markdingram commented 1 year ago

1.0.3 works great - on my test Axum project running cargo clean && cargo test --timings before and after these changes gives:

Total Units: 391 > 263 - 33% reduction Total Time: 76 > 56s - 26% reduction

Thanks!