As mentioned in the title the cargo build fails to generate the pkg directory. I am following a tutorial where I run the command cargo build --target wasm-unknown-unknown
which runs fine and I get no errors there. Then in my index.js file I would need to import the wasm file with the following statement: import './pkg/rust_3d_demo'
. But there is no pkg directory generated after running the cargo build command. The tutorial is only 3 days old on youtube by Mr Doug Milford so there are no version issues here and my rustc and rustup and cargo are all up to date. Any thoughts on the matter? Much appreciated.
Here is my Cargo.toml file:
[package]
name = "rust-3d-demo"
version = "0.1.0"
authors = ["Steel"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
console_error_panic_hook = "=0.1.5"
js-sys = "0.3.19"
lazy_static = "1.3.0"
nalgebra = "0.18.0"
wasm-bindgen = "0.2.44"
[dependencies.web-sys]
version = "0.3.4"
features = [
'Document',
'Element',
'EventTarget',
'HtmlCanvasElement',
'MouseEvent',
'WebGlBuffer',
'WebGlProgram',
'WebGlRenderingContext',
'WebGlShader',
'WebGlUniformLocation',
'Window'
]
and the devDependencies section in my package.json file here:
"devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^1.1.0",
"html-webpack-plugin": "^3.2.0",
"text-encoding": "^0.7.0",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.1"
}
Other info that might help:
rustc --version
=> rust 1.40.0 (73528e339 2019-12-16)
rustup --version
=> rust 1.21.1
cargo --version
=> cargo 1.40.0
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
2.- add a new instance in the plugins section:new WasmPackPlugin({ crateDirectory: path.resolve(__dirname, ".") })
After this the pkg directory is generated :) – Joey Vico