Skip to content

Exported functions no longer visible in JS #563

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

Closed
viktorku opened this issue Jul 26, 2018 · 5 comments
Closed

Exported functions no longer visible in JS #563

viktorku opened this issue Jul 26, 2018 · 5 comments

Comments

@viktorku
Copy link

viktorku commented Jul 26, 2018

Hi there!

I think I've hit a regression in the latest 0.2.14 release as I basically can't call any exported function from JS into Rust anymore.

Here's the module on 0.2.13:

screen shot 2018-07-26 at 17 51 47

notice my init and start export and all the boilerplate DOM API imports I've defined.

and here it is on 0.2.14:

screen shot 2018-07-26 at 17 49 59

The code is exactly the same, and pretty much as in the basic tutorial :/

Is there something I need to do to make this work?

Thanks for all the great work BTW!

[EDIT]: Here's the code: https://github.com/viktorku/kunovski/blob/master/src/lib.rs

@alexcrichton
Copy link
Contributor

Thanks for the report! @viktorku what version of the wasm-bindgen CLI tool do you have installed? You may need to update it to 0.2.14 as well I think

@viktorku
Copy link
Author

It seems it's resolved in 0.2.15 ;)

$ cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating wasm-bindgen v0.2.13 -> v0.2.15
    Updating wasm-bindgen-backend v0.2.13 -> v0.2.15
    Updating wasm-bindgen-macro v0.2.13 -> v0.2.15
    Updating wasm-bindgen-shared v0.2.13 -> v0.2.15
$ ./build
 Downloading wasm-bindgen v0.2.15
 Downloading wasm-bindgen-macro v0.2.15
 Downloading wasm-bindgen-shared v0.2.15
 Downloading wasm-bindgen-backend v0.2.15
   Compiling wasm-bindgen-shared v0.2.15
   Compiling wasm-bindgen-backend v0.2.15
   Compiling wasm-bindgen-macro v0.2.15
   Compiling wasm-bindgen v0.2.15
   Compiling kunovski v0.1.0 (file:///Users/viktor/projects/kunovski)
    Finished release [optimized] target(s) in 19.13s

If I downgrade to 0.2.14:

$ cargo update -p wasm-bindgen --precise 0.2.14
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating wasm-bindgen v0.2.15 -> v0.2.14
    Updating wasm-bindgen-backend v0.2.15 -> v0.2.14
    Updating wasm-bindgen-macro v0.2.15 -> v0.2.14
    Updating wasm-bindgen-shared v0.2.15 -> v0.2.14
$ ./build
   Compiling wasm-bindgen-shared v0.2.14
   Compiling wasm-bindgen-backend v0.2.14
   Compiling wasm-bindgen-macro v0.2.14
   Compiling wasm-bindgen v0.2.14
   Compiling kunovski v0.1.0 (file:///Users/viktor/projects/kunovski)
    Finished release [optimized] target(s) in 18.79s

My wasm-bindgen-cli was at 0.2.12 tho, so you're right. But that version works good with wasm-bindgen at 0.2.15...

@viktorku
Copy link
Author

This probably deserves a separate issue, but when I try to upgrade wasm-bindgen-cli I always get this compilation error. When I did upgrade it to 0.2.12 last week, I had to clone and build tempfile from source (I thought that was failing upstream for some reason), and only when I built it successfully, I was able to upgrade wasm-bindgen-cli. Very weird. Is this some intricate bug in the dependency resolution of cargo?

$ cargo +nightly install wasm-bindgen-cli --force
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing wasm-bindgen-cli v0.2.15
 Downloading wasm-bindgen-cli-support v0.2.15
 Downloading wasm-gc-api v0.1.9
   Compiling unicode-xid v0.0.4
   Compiling unicode-xid v0.1.0
   Compiling quote v0.3.15
   Compiling serde v1.0.70
   Compiling void v1.0.2
   Compiling libc v0.2.42
   Compiling rustc-demangle v0.1.9
   Compiling ucd-util v0.1.1
   Compiling lazy_static v1.0.2
   Compiling rand_core v0.2.1
   Compiling regex v1.0.2
   Compiling cfg-if v0.1.4
   Compiling wasm-bindgen-shared v0.2.15
   Compiling byteorder v1.2.3
   Compiling itoa v0.4.2
   Compiling safemem v0.2.0
   Compiling utf8-ranges v1.0.0
   Compiling nan-preserving-float v0.1.0
   Compiling memory_units v0.3.0
   Compiling remove_dir_all v0.5.1
   Compiling dtoa v0.4.3
   Compiling strsim v0.7.0
   Compiling unreachable v1.0.0
   Compiling memchr v2.0.1
   Compiling proc-macro2 v0.4.9
   Compiling synom v0.11.3
   Compiling log v0.4.3
   Compiling regex-syntax v0.6.2
   Compiling rand v0.5.4
   Compiling parity-wasm v0.31.1
   Compiling base64 v0.9.2
   Compiling thread_local v0.3.5
   Compiling aho-corasick v0.6.6
   Compiling backtrace v0.3.9
   Compiling syn v0.11.11
   Compiling tempfile v3.0.3
error[E0425]: cannot find function `create` in module `imp`
  --> /Users/viktor/.cargo/registry/src/github.com-1ecc6299db9ec823/tempfile-3.0.3/src/file/mod.rs:98:10
   |
98 |     imp::create(dir.as_ref())
   |          ^^^^^^ not found in `imp`
help: possible candidate is found in another module, you can import it into scope
   |
1  | use dir::create;
   |

error[E0425]: cannot find function `persist` in module `imp`
   --> /Users/viktor/.cargo/registry/src/github.com-1ecc6299db9ec823/tempfile-3.0.3/src/file/mod.rs:234:20
    |
234 |         match imp::persist(&self.path, new_path.as_ref(), true) {
    |                    ^^^^^^^ not found in `imp`

error[E0425]: cannot find function `persist` in module `imp`
   --> /Users/viktor/.cargo/registry/src/github.com-1ecc6299db9ec823/tempfile-3.0.3/src/file/mod.rs:297:20
    |
297 |         match imp::persist(&self.path, new_path.as_ref(), false) {
    |                    ^^^^^^^ not found in `imp`

error[E0425]: cannot find function `reopen` in module `imp`
   --> /Users/viktor/.cargo/registry/src/github.com-1ecc6299db9ec823/tempfile-3.0.3/src/file/mod.rs:707:14
    |
707 |         imp::reopen(self.as_file(), NamedTempFile::path(self))
    |              ^^^^^^ not found in `imp`

error[E0425]: cannot find function `create_named` in module `imp`
   --> /Users/viktor/.cargo/registry/src/github.com-1ecc6299db9ec823/tempfile-3.0.3/src/file/mod.rs:798:10
    |
798 |     imp::create_named(&path).map(|file| NamedTempFile {
    |          ^^^^^^^^^^^^ not found in `imp`
help: possible candidate is found in another module, you can import it into scope
    |
1   | use file::create_named;
    |

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `tempfile`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `wasm-bindgen-cli v0.2.15`, intermediate artifacts can be found at `/var/folders/dp/h6rhdfds7ss6sfm7yjngvh800000gn/T/cargo-install7D5KJt`

Caused by:
  build failed

@richard-uk1
Copy link
Contributor

richard-uk1 commented Jul 27, 2018

98 |     imp::create(dir.as_ref())
   |          ^^^^^^ not found in `imp`

I haven't looked at the code, but imp normally indicates different implementations for different platforms. What platform are you compiling on?

e.g. it could be trying to compile the cli on wasm32-unknown-unknown when it should be on host platform.

@alexcrichton
Copy link
Contributor

Ok thanks for the info @viktorku! In that case I think I'm going to close this.

I also think for that build failure @derekdreery hit the nail on the head, you're likely running into rust-lang/cargo#2507 where .cargo/config mentions the default target is wasm perhaps?

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

3 participants