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

build rust_wasm_bindgen failed #1509

Closed
ImJeremyHe opened this issue Aug 11, 2022 · 0 comments
Closed

build rust_wasm_bindgen failed #1509

ImJeremyHe opened this issue Aug 11, 2022 · 0 comments
Labels

Comments

@ImJeremyHe
Copy link
Contributor

Hello! I am trying to build a wasm using bazel.
I wrote the BUILD file like this:

load("@rules_rust//rust:defs.bzl", "rust_shared_library")
load("@rules_rust//wasm_bindgen:wasm_bindgen.bzl", "rust_wasm_bindgen")
load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")

package(default_visibility = ["//visibility:public"])

rust_shared_library(
    name = "server_lib",
    aliases = aliases(),
    srcs = glob(["src/**/*.rs"]),
    edition = "2018",
    deps = all_crate_deps(normal = True),
)

rust_wasm_bindgen(
    name = "server_web_wasm",
    wasm_file = ":server_lib",
)

And I run the cmd in this folder:

bazel build :server_web_wasm

And it failed because of:

it looks like the Rust project used to create this wasm file was linked against
version of wasm-bindgen that uses a different bindgen format than this binary:

  rust wasm file schema version: 0.2.82
     this binary schema version: 0.2.81

Currently the bindgen format is unstable enough that these two schema versions
must exactly match. You can accomplish this by either updating the wasm-bindgen
dependency or this binary.

You should be able to update the wasm-bindgen dependency with:

    cargo update -p wasm-bindgen

or you can update the binary with

    cargo install -f wasm-bindgen-cli

I check the version of wasm-bindgen in the bazel-bin/external and it is 0.2.82,
which is the same as cmd wasm-bindgen -V shows.

Run the cmd wasm-pack build is ok.

Is there any wrong use about these rules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants