Skip to content

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

Closed as not planned
@anderslanglands

Description

@anderslanglands

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions