Skip to content
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

Mark js-sys as optional for identity_core #1405

Merged

Conversation

frederikrothenberger
Copy link

Description of change

In #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 and here.

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.

Type of change

Add an x to the boxes that are relevant to your changes.

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Existing tests

Change checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

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.
@frederikrothenberger frederikrothenberger requested a review from a team as a code owner September 2, 2024 13:27
@frederikrothenberger
Copy link
Author

@itsyaasir: Sorry to bother you again, but I made a mistake in #1397 and this PR fixes it.

@itsyaasir
Copy link
Contributor

itsyaasir commented Sep 2, 2024

@frederikrothenberger
Thank you for your contribution! I noticed that in your changes, the js-sys dependency is marked as optional This means that the dependency won't be automatically included during the build process unless it is explicitly enabled (by feature IIRC). If you take a look at the github action which is building for wasm32-unknown-unkown it is failing to find the dep "js-sys" for the now_utc function. Since we are already compiling it conditionally according to the target, is the optional required here ?

@frederikrothenberger
Copy link
Author

@itsyaasir: Yes, the optional is required, otherwise you cannot compile to wasm32-unknown-unknwon without it (breaking compatibility with the ICP platform).

But we should be able to enable it by default (still gated by the target). Would that be an option?

@itsyaasir
Copy link
Contributor

@itsyaasir: Yes, the optional is required, otherwise you cannot compile to wasm32-unknown-unknwon without it (breaking compatibility with the ICP platform).

But we should be able to enable it by default (still gated by the target). Would that be an option?

That should be fine. We are also using the js-sys dependency for wasm bindings with ts

@frederikrothenberger
Copy link
Author

@itsyaasir: I made it a default feature.

@itsyaasir
Copy link
Contributor

itsyaasir commented Sep 3, 2024

@itsyaasir: I made it a default feature.

Did you forget to push the changes ? I can't see the dependency being a default feature.

You modified this default-features = true but this only activates the default features of the js-sys crate as show here

@frederikrothenberger
Copy link
Author

@itsyaasir: Yes, my bad. I got confused about the default switches. Fixed now.

identity_core/Cargo.toml Outdated Show resolved Hide resolved
@itsyaasir itsyaasir added No changelog Excludes PR from becoming part of any changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. labels Sep 4, 2024
@itsyaasir itsyaasir merged commit 84f1b7e into iotaledger:main Sep 4, 2024
16 of 17 checks passed
@frederikrothenberger frederikrothenberger deleted the frederik/fix-js-sys-optional branch September 4, 2024 08:05
@eike-hass eike-hass added Patch Change without affecting the API that requires a patch release. Part of "Patch" section in changelog and removed No changelog Excludes PR from becoming part of any changelog labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Patch Change without affecting the API that requires a patch release. Part of "Patch" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants