Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
351: Feature/wasm r=Dylan-DPC a=zrzka # Description This PR adds two new features: * `stdweb` * `wasm-bindgen` These features are kind of _passthrough_ features, because they do nothing in the `uuid` crate itself. They're just passed to the `rand` crate to make the `uuid` crate working for the `wasm32-unknown-unknown` target. # Motivation I'm unable to generate random UUID (v4) when this crate is compiled for the `wasm32-unknown-unknown` target. # Tests I just added these features ... ``` - cargo test --features "v3" - cargo test --features "v3 stdweb" - cargo test --features "v3 wasm-bindgen" ``` ... for all `v3` & `v4` & `v5` (`rand` crate is used in all these features) to the `script` section in the `.travis.yml`. Not sure if it makes sense, but it can demonstrate that it's buildable at least. I don't think that more tests are required unless you'd like to bring the whole `wasm-bindgen`, `wasm-pack`, ... machinery here. And it has no sense to do it, because goal of this PR is not to publish `uuid-rs` NPM package, just add the ability to compile & use it from the `wasm32-unknown-unknown` target. # Related Issue(s) * #350 * [now() doesn't work](balena-io-modules/balena-temen#37) # Manual tests My Cargo.toml: ``` [dependencies] uuid = { features = ["v4"], git = "https://github.com/zrzka/uuid.git", branch = "feature/wasm" } [target.wasm32-unknown-unknown.dependencies] uuid = { features = ["wasm-bindgen"], git = "https://github.com/zrzka/uuid.git", branch = "feature/wasm" } ``` My `index.js`: ``` const bt = require('balena-temen'); console.log( bt.evaluate({ "id": { "$$eval": "uuidv4()" } }) ); ``` [uuidv4() implementation](https://github.com/balena-io-modules/balena-temen/blob/master/src/builtin/function/uuidv4.rs#L9-L11). Output: ``` { id: 'cefa2919-ff48-48ef-a231-e13697e23ed2' } ``` Co-authored-by: Robert Vojta <[email protected]>
- Loading branch information