Skip to content

Commit

Permalink
Mark js-sys as optional for identity_core (iotaledger#1405)
Browse files Browse the repository at this point in the history
* Mark `js-sys` as optional for identity_core

In iotaledger#1397 my intention was to make the `js-sys` dependency mutually
exclusive with the feature `custom_time`. As it turns out, it's not that
simple and mixing target specific dependencies with feature specific
dependencies does not actually work. See [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
and [here](https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features).

So this removes the broken feature reference in the dependency declaration
and instead marks it as `optional`. Also, the feature `custom_time` takes
precedence over `js-sys` so these do not actually conflict and one
_could_ enable both.

* Make js-sys a default feature

* Fix defaults switch

* Don't expose `js-sys` feature

Co-authored-by: Yasir <[email protected]>

---------

Co-authored-by: Yasir <[email protected]>
  • Loading branch information
Frederik Rothenberger and itsyaasir authored Sep 4, 2024
1 parent b355b47 commit 84f1b7e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions identity_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ time = { version = "0.3.23", default-features = false, features = ["std", "serde
url = { version = "2.4", default-features = false, features = ["serde"] }
zeroize = { version = "1.6", default-features = false }

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(feature = "custom_time")))'.dependencies]
js-sys = { version = "0.3.55", default-features = false }
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
js-sys = { version = "0.3.55", default-features = false, optional = true }

[dev-dependencies]
proptest = { version = "1.0.0" }
Expand All @@ -39,6 +39,7 @@ rustdoc-args = ["--cfg", "docsrs"]
workspace = true

[features]
default = ["dep:js-sys"]
# Enables a macro to provide a custom time (Timestamp::now_utc) implementation, see src/custom_time.rs
custom_time = []

Expand Down

0 comments on commit 84f1b7e

Please sign in to comment.