Skip to content

Support wasm32-u-u on web via patching Cargo.toml? #674

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

Open
dhardy opened this issue May 27, 2025 · 1 comment
Open

Support wasm32-u-u on web via patching Cargo.toml? #674

dhardy opened this issue May 27, 2025 · 1 comment

Comments

@dhardy
Copy link
Member

dhardy commented May 27, 2025

As I outlined here, we could support wasm32-unknown-unknown on web via patching Cargo.toml:

We publish getrandom-js with feature all-targets:

  • For wasm32-unknown-unknown, this will assume a web (JS) target.
  • For other targets without feature all-targets, this will compile_error!.
  • For other targets with feature all-targets, this will depend on and use getrandom.

Users may enable this platform for getrandom by patching Cargo.toml as follows:

[patch.crates-io.getrandom]
version = "0.3"
package = "getrandom-wasm-js"

I think this approach will work, but it's untested. It does not support selection via cfg (e.g. env var) however.

This does not prevent us also supporting wasm32-u-u on web with the current solution (specifying getrandom_backend='wasm_js').

@dhardy
Copy link
Member Author

dhardy commented May 27, 2025

For clarification: crates like rand which cannot assume anything about their target environment would depend on getrandom; the above patch is to replace this dependency.

Crates which can assume JS (web) may use getrandom-js directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant