Skip to content

wasm compile of my crate generates "cannot import from modules (env) with --no-modules error #93557

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
anderslanglands opened this issue Feb 1, 2022 · 2 comments
Labels
C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@anderslanglands
Copy link

As title. I found this issue: #72758 which was a bug so assume this is a similar issue but I don't know enough about wasm to delve any further since there was no explanation in that issue.

Minimal repro:

Cargo.toml

[package]
name = "minimal_ustr_wasmpack_reproduction"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
ustr = "0.8.1"
wasm-bindgen = "0.2.78"

src/lib.rs

use ::ustr::Ustr;
use ::wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn mre() {
    Ustr::from("hello");
}

run:

cargo install wasm-pack
wasm-pack build --target no-modules

error:

error: cannot import from modules (`env`) with `--no-modules`
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit status: 1
  full command: "..../.cache/.wasm-pack/wasm-bindgen-e63eccbd87203048/wasm-bindgen" ".../target/wasm32-unknown-unknown/release/minimal_ustr_wasmpack_reproduction.wasm" "--out-dir" ".../pkg" "--typescript" "--target" "no-modules"

Meta

This happens with 1.57.0 (f1edd04 2021-11-29), 1.58.1 (db9d1b2 2022-01-20) and 1.60.0-nightly (498eeb7 2022-01-31)

@gilescope
Copy link
Contributor

I got this once as a sporadic error. Commented and then uncommented some wasm bindgen calls and the problem went away.

@jieyouxu
Copy link
Member

Triage: closing this issue for the time being because there's not sufficient info indicating it's a rustc problem and this is not actionable.

@jieyouxu jieyouxu closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

No branches or pull requests

5 participants