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

Mass rename anyref to externref #2142

Merged
merged 1 commit into from
May 18, 2020

Conversation

alexcrichton
Copy link
Contributor

Updates a mess of dependencies and tracks the most recent version of the
reference types specification.

Updates a mess of dependencies and tracks the most recent version of the
reference types specification.
@alexcrichton alexcrichton merged commit 996e92f into rustwasm:master May 18, 2020
@alexcrichton alexcrichton deleted the rename-anyref branch May 18, 2020 14:36
@zancas
Copy link

zancas commented May 27, 2020

Hi @alexcrichton ! It seems like this change may have broken our build (though I don't know how a variable name change could have).

Our project provides the following build error when we try to build against the latest wasm-bindgen:

+ TARGET=target/wasm32-unknown-unknown/debug
+ cargo build --features=fail-on-warnings --target wasm32-unknown-unknown
   Compiling wasm-bindgen-shared v0.2.62 (https://github.com/rustwasm/wasm-bindgen.git#3dd8f3d2)
   Compiling wasm-bindgen v0.2.62 (https://github.com/rustwasm/wasm-bindgen.git#3dd8f3d2)
   Compiling zcash_client_backend v0.2.0 (https://github.com/zcash/librustzcash.git#5ff85627)
   Compiling wasm-bindgen-backend v0.2.62 (https://github.com/rustwasm/wasm-bindgen.git#3dd8f3d2)
   Compiling wasm-bindgen-macro-support v0.2.62 (https://github.com/rustwasm/wasm-bindgen.git#3dd8f3d2)
   Compiling wasm-bindgen-macro v0.2.62 (https://github.com/rustwasm/wasm-bindgen.git#3dd8f3d2)
   Compiling js-sys v0.3.39 (https://github.com/rustwasm/wasm-bindgen.git#3dd8f3d2)
   Compiling console_error_panic_hook v0.1.6
   Compiling wasm-bindgen-futures v0.4.12
   Compiling web-sys v0.3.39
   Compiling web-extension v0.1.0 (https://gitlab.com/ZingO-Labs/tab-organizer.git?branch=rust#9a3e3924)
   Compiling wasm-bindgen-test v0.3.12
   Compiling zingo_webextension v0.0.1 (/home/pherder/ZingOLabs/webextension)
    Finished dev [unoptimized + debuginfo] target(s) in 34.74s
+ rm -rf wasms
+ wasm-bindgen --out-name bindgens.wasm --out-dir ./wasms --target no-modules target/wasm32-unknown-unknown/debug/zingo_webextension.wasm
error: cannot import from modules (`__wbindgen_externref_xform__`) with `--no-modules`

Since our WASM is running in a webextension we don't have a straight-forward way to support ES6 modules.

Any feedback, much appreciated!

@Pauan
Copy link
Contributor

Pauan commented May 27, 2020

@zancas I've written several WebExtensions with Rust, and ES6 modules with --target web do work:

I recommend using our Rollup plugin since it is fast, lightweight, easy to setup, supports multiple crates, supports watch mode, can automatically bundle your extension as a .zip, etc.

@alexcrichton
Copy link
Contributor Author

I'd second what @Pauan says, it looks like @zancas you're manually running Cargo and wasm-bindgen, and the error here is probably a mismatch of the wasm-bindgen CLI version and crate version you're linking in.

@AloeareV
Copy link

https://bugzilla.mozilla.org/show_bug.cgi?id=1536094 According to this, there's a firefox-specific bug where content scripts are incapable of importing EC6 modules.

Our wasm-bindgen --version and the wasm bindgen version = in the Cargo.lock are both 0.2.62, so that's not likely the issue

@AloeareV
Copy link

AloeareV commented May 27, 2020

If y'all can't replicate the --target no-modules error, then there's something weird going on in our local state we need to debug, but --target web solution as far as I can tell doesn't work in Firefox.

@Pauan
Copy link
Contributor

Pauan commented May 28, 2020

@AloeareV In that case you can use Rollup with iife output, or Webpack. That will compile it into regular ES5 code. If you're doing that, then you don't need the dynamic import() anymore.

If you don't want to use Webpack or Rollup, you should be using wasm-pack. It isn't really intended to run wasm-bindgen manually.

I can successfully use --target no-modules with the latest version of wasm-bindgen, so it must be a problem with your setup (which is probably fixed by using Webpack, Rollup, or wasm-pack).

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

Successfully merging this pull request may close these issues.

None yet

4 participants