Skip to content

Targeting Deno #879

Closed
Closed
@eliorivero

Description

@eliorivero

🐛 Bug description

I saw this https://rustwasm.github.io/docs/wasm-bindgen/reference/deployment.html#deno mentioning that you could pass --target deno and build to Deno. I tried:

wasm-pack build --target deno

and got

error: Invalid value for '--target <target>': Unknown target: deno

🤔 Expected Behavior

A package suitable to be used in Deno should've been created.

👟 Steps to reproduce

cargo new rust-deno-test --lib
cd rust-deno-test

Edit src/lib.rs and replace its contents with:

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn factorial( x: u64 ) -> u64 {
    match x {
        0 | 1 => 1,
        _ => x * factorial( x - 1 ),
    }
}

Edit Cargo.toml and merge:

[dependencies]
wasm-bindgen = "0.2.65"

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

Then run

wasm-pack build --target deno

🌍 Your environment

wasm-pack version: 0.9.1
rustc version: 1.44.1

Notes

The tool ssvmup can successfully convert the same code to a package that's usable by Deno, with a similar command ssvmup build --target deno.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions