使用 cargo build
构建 wasm 的一些示例(如 Programming WebAssembly 书中的示例)
cargo build --release --target=wasm32-unknown-unknown
和其他人使用,wasm-pack build --target web ....
这两种构建项目的方法有什么不同?
最佳答案
Wasm-pack 是一个更大的便利应用程序,它提供的不仅仅是构建 Rust 代码。
除其他外,wasm-pack 提供:
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
关于rust - Web 组装和 Rust : cargo build vs wasm-pack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62585840/