-
Notifications
You must be signed in to change notification settings - Fork 472
Open
Description
🐛 Bug description
Dependencies declared in a package.json next to Cargo.toml do not get copied over to pkg/package.json. This should be supported according to rustwasm/rfcs#8.
Content of handwritten package.json:
{
"dependencies": {
"@tensorflow/tfjs": "^1.7.4"
}
}Content of generated pkg/package.json:
{
"name": "npm-dep-test",
"collaborators": [
"Benjamin Minixhofer <[email protected]>"
],
"version": "0.1.0",
"files": [
"npm_dep_test_bg.wasm",
"npm_dep_test.js",
"npm_dep_test.d.ts"
],
"module": "npm_dep_test.js",
"types": "npm_dep_test.d.ts",
"sideEffects": false
}🤔 Expected Behavior
I would have expected pkg/package.json to have a "dependencies" key which lists "@tensorflow/tfjs" as dependency.
👟 Steps to reproduce
To reproduce:
- Generate a new project:
cargo generate --git https://github.com/rustwasm/wasm-pack-template - Create a file
package.jsonnext toCargo.tomlat the project root, which has the content:
{
"dependencies": {
"@tensorflow/tfjs": "^1.7.4"
}
}- (probably optional) add some code to
src/lib.rswhich uses the dependency to make sure it doesn't get optimized out, e. g.
#[wasm_bindgen(module = "@tensorflow/tfjs")]
extern {
fn sequential() -> JsValue;
}
#[wasm_bindgen]
pub fn greet() {
alert(&format!("{:#?}", sequential()));
}- Run
wasm-pack buildand look at the content ofpkg/package.json.
Alternatively, run git clone https://github.com/bminixhofer/npm-dep-test to skip steps 1-3.
🌍 Your environment
Include the relevant details of your environment.
wasm-pack version: wasm-pack 0.9.1
rustc version: rustc 1.43.0 (4fb7144ed 2020-04-20)
Related
- RFC: Enable depending on NPM packages rustwasm/rfcs#8.
- Support for NPM dependencies in wasm_bindgen: Implement transitive support for NPM dependencies wasm-bindgen/wasm-bindgen#1305.
- Is this really implemented? According to discussion on Discord it is, but Implement support for RFC 8, transitive NPM dependencies #606 is still open.
Metadata
Metadata
Assignees
Labels
No labels