gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:30:53 26 4
gpt4 key购买 nike

使用 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/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com