Wasm-pack: Targeting Deno

Created on 19 Jul 2020  路  1Comment  路  Source: rustwasm/wasm-pack

馃悰 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.

Most helpful comment

wasm-bingen seems to have recently gained support for deno target, but the option is not forwarded to it by wasm-pack.

I have quickly hacked a patch which seems to work at first glance. It does a bit more than required, even: for example, it generates a package.json, which Deno doesn't use.

I could work on a PR, but consider the fact that I only had a proper look at Deno yesterday.

>All comments

wasm-bingen seems to have recently gained support for deno target, but the option is not forwarded to it by wasm-pack.

I have quickly hacked a patch which seems to work at first glance. It does a bit more than required, even: for example, it generates a package.json, which Deno doesn't use.

I could work on a PR, but consider the fact that I only had a proper look at Deno yesterday.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TorstenStueber picture TorstenStueber  路  3Comments

pablosichert picture pablosichert  路  4Comments

RReverser picture RReverser  路  3Comments

marcoscaceres picture marcoscaceres  路  3Comments

xtuc picture xtuc  路  5Comments