-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Address multi-platform issues with getrandom dependency #173
Conversation
Hi. Thanks for opening this pull request.
or migrating it under Let me do some research on it too. Also, which cache are you trying to use? ( |
As for [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
getrandom = { version = "0.2" }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.2", features = ["js"] } |
I am using I actually ended up wrapping moka into our own interface that does The funny thing is that because we are using futures in I haven't tried futures as it seems to have Back to the issue at hand: Keep in mind that However, the core of the issue is that after adding What happens is that the There is currently no way around that. I tried making To summarize: the So this currently ends up being that in all cases to add The alternative solution to this issue would be to replace I can set up a small repo that demonstrates the issue if you want. Let me know. |
Thanks for providing the details.
I am OK for adding the But I believe we do not need to specify To confirm this, I created a modified version of This [features]
# ...
js = ["uuid/js"] And the package (called [features]
js = ["moka/js"]
[dependencies]
moka = { path = "../moka" } Then I confirmed that I can build $ git clone https://gitlab.com/moka-labs/moka-gh-173-js-feature/moka.git
$ git clone https://gitlab.com/moka-labs/moka-gh-173-js-feature/my-package1.git
$ cd my-package1
## Build for the default target. (For my case, aarch64-apple-darwin)
$ cargo build
$ cargo build --release
## Build for wasm32-unknown-unknown target:
$ cargo build --target wasm32-unknown-unknown --features js
$ cargo build --target wasm32-unknown-unknown --features js --release Can you please check if this works for your package? (I mean: only adding |
That is what I thought.
As for the threads part, you can make
Maybe it is worth to try. (but I do not know if there are any other problems)
In the future, we will remove the background threads and |
If you could create a tiny wasm project for me to play with moka on a web browser, that will be a great help. I will use it to figure out what needs to be done to make |
I created a mini I will do little further to check if some of the advanced functions such as time-to-live expiration and eviction listener are working in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to merge this PR. But I will create another PR to revert the change on getrandom
dependency because it broke one of the unit tests and I believe the change is unnecessary.
Thank you for contributing to Moka 😄 !
Fixes the unit test broken by #173.
With regards to the closed #172
This is the best solution I have been able to come up with. I will give this example to cargo developers. In the meantime, the way to address this would be to migrate
getrandom
fromdev-dependencies
to regulardependencies
. It will be eliminated away by the compiler and linker as it is not used anyways. In the meantime it allows one to usejs
feature.Once again, to clarify,
js
features is needed for wasm but you can not specify sub-crate features fordev-dependencies
as in release mode cargo errors out withno such dependency found for feature 'js'
...I've tried using
js = ["getrandom?/js"]
syntax, but optional dependencies (?
) are available only on the nightly channel and that would require to setgetrandom = { optional = true ... }
and then use another feature like 'testing' to trigger its inclusion, which is complex and doesn't make much sense anyways. Relocating this crate fromdev-dependencies
is the cleanest and most elegant solution for the time being.