Reputation: 1
Some examples of building wasm use cargo build
(like the examples in the book Programming WebAssembly)
cargo build --release --target=wasm32-unknown-unknown
And others use,
wasm-pack build --target web ....
What's the different between these two methods of building a project?
Upvotes: 9
Views: 2583
Reputation: 16207
Wasm-pack is a bigger convenience application that provides more than simply building the Rust code.
Amongst other things wasm-pack provides:
cargo build --target=wasm32-unknown-unknown ...
)cargo new
)This tool seeks to be a one-stop shop for building and working with rust- generated WebAssembly that you would like to interop with JavaScript, in the browser or with Node.js. wasm-pack helps you build rust-generated WebAssembly packages that you could publish to the npm registry, or otherwise use alongside any javascript packages in workflows that you already use, such as webpack or greenkeeper. 1
Upvotes: 7