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

now() doesn't work #37

Closed
zrzka opened this issue Nov 26, 2018 · 3 comments
Closed

now() doesn't work #37

zrzka opened this issue Nov 26, 2018 · 3 comments
Labels
Arch: wasm Web Assembly related Type: Bug Something isn't working

Comments

@zrzka
Copy link
Contributor

zrzka commented Nov 26, 2018

Not implemented for the wasm32-unknown-unknown target.

@zrzka zrzka added Type: Bug Something isn't working Arch: wasm Web Assembly related labels Nov 26, 2018
@zrzka
Copy link
Contributor Author

zrzka commented Nov 26, 2018

There's PR open with the initial wasm32 arch support. Should self fix once approved & new chrono released.

@zrzka
Copy link
Contributor Author

zrzka commented Nov 26, 2018

Works with ...

chrono = { git = "https://github.com/jjpe/chrono", branch = "wasm" }

... which is the mentioned PR branch. Waiting for the new chrono release.

This was referenced Nov 27, 2018
bors bot added a commit to uuid-rs/uuid that referenced this issue Dec 1, 2018
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 <rvojta@me.com>
@zrzka
Copy link
Contributor Author

zrzka commented Dec 1, 2018

Fixed in #39

@zrzka zrzka closed this as completed Dec 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: wasm Web Assembly related Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant