Skip to content

Commit

Permalink
Fix compiler error on wasm with deault features. (#129)
Browse files Browse the repository at this point in the history
* Fix compiler error on wasm.
  • Loading branch information
ar37-rs committed Oct 23, 2022
1 parent 24491f6 commit b526344
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Expand Up @@ -148,4 +148,4 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: check
args: --target wasm32-unknown-unknown --no-default-features
args: --target wasm32-unknown-unknown
9 changes: 8 additions & 1 deletion Cargo.toml
Expand Up @@ -68,11 +68,18 @@ codegen-units = 1
version_check = "0.9.4"

[dependencies]
getrandom = { version = "0.2.3", optional = true }
const-random = { version = "0.1.12", optional = true }
serde = { version = "1.0.117", optional = true }
cfg-if = "1.0"

[target."cfg(not(any(target_arch = \"wasm32\", target_abi = \"unknown\")))".dependencies.getrandom]
version = "0.2.7"
optional = true

[target."cfg(any(target_arch = \"wasm32\", target_abi = \"unknown\"))".dependencies.getrandom]
version = "0.2.7"
features = ["js"]

[target.'cfg(not(all(target_arch = "arm", target_os = "none")))'.dependencies]
once_cell = { version = "1.8", default-features = false, features = ["unstable", "alloc"] }

Expand Down

1 comment on commit b526344

@schungx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix a compilation error problem that has occurred for a while already.

However, I'm wondering: for people building for raw WASM (meaning no wasm-bindgen etc.) not intended to be used in a JavaScript environment, would pulling in getrandom/js create an import where it breaks things?

Please sign in to comment.