rust - Web 组装和 Rust : cargo build vs wasm-pack

标签 rust webassembly rust-cargo wasm-pack

使用 cargo build 构建 wasm 的一些示例(如 Programming WebAssembly 书中的示例)

cargo build --release --target=wasm32-unknown-unknown
和其他人使用,
wasm-pack build --target web ....
这两种构建项目的方法有什么不同?

最佳答案

Wasm-pack 是一个更大的便利应用程序,它提供的不仅仅是构建 Rust 代码。
除其他外,wasm-pack 提供:

  • 将 Rust 项目构建到 WebAssembly(相当于 cargo build --target=wasm32-unknown-unknown ... )
  • 绑定(bind)到 Node.js
  • 将结果发布到 npm 注册表。
  • 创建新项目(如 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/

    相关文章:

    c++ - 如何从 C++ 文件中包含 WebAssembly 模块?

    rust - 针对 Cargo 工作区中的特定包

    rust - 无法使用git存储库中的alacritty依赖关系

    rust - Rust函数语法问题,示例出现在nom中

    compiler-errors - 尝试在 Rust v0.13.0 中打印整数时出现编译错误

    32bit-64bit - 在 WebAssembly 中,同时拥有 32 位和 64 位数字的基本原理是什么?

    webassembly - 学习 WebAssembly Uncaught (in Promise) TypeError : m. _init is not a function

    linux - 如何在 RHEL Linux 服务器上安装 Cargo?

    rust - 从 Box 返回 dyn Trait<dyn Trait 1 + Trait 2>

    iterator - 从通用关联函数返回对值的引用的合适方法是什么?