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

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

Open
anderslanglands opened this issue Feb 1, 2022 · 1 comment
Labels
C-bug Category: This is a bug. needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.

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.

@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.
Projects
None yet
Development

No branches or pull requests

3 participants