Giter Club home page Giter Club logo

wasm-pack's Introduction

๐Ÿ“ฆโœจ wasm-pack

Your favorite rust -> wasm workflow tool!

Build Status Build status

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 and publish rust-generated WebAssembly to the npm registry to be used alongside any other javascript package in workflows that you already use, such as webpack or greenkeeper.

This project is a part of the rust-wasm group. You can find more info by visiting that repo!

demo

๐Ÿ”ฎ Prerequisities

This project requires Rust 1.30.0 or later.

๐ŸŽ™๏ธ Commands

  • init (โš ๏ธ DEPRECATED): This command has been deprecated since release 0.5.0, in favor of build. 0.4.2 and previous use this command.
  • build: Generate an npm wasm pkg from a rustwasm crate
  • pack and publish: Create a tarball of your rustwasm pkg and/or publish to a registry

๐Ÿ“ Logging

We generate a wasm-pack.log file if wasm-pack errors on you, and you can customize the log verbosity using the verbosity flag.

Verbosity Result
-v All Info, Warn, and Errors are logged
-vv All Debug, Info, Warn, and Errors are logged
-vvv All Trace, Debug, Info, Warn, and Errors are logged

๐Ÿ‘ฏ Contributing

Read our guide on getting up and running for developing wasm-pack, and check out our contribution policy.

โšก Quickstart Guide

  1. Write a crate in Rust.
  2. Add wasm-bindgen to your Cargo.toml:
[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
  1. Add this to the top of your src/lib.rs:
extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;
  1. Annotate your public functions with #[wasm_bindgen], for example:
#[wasm_bindgen]
extern {
    pub fn alert(s: &str);
}

#[wasm_bindgen]
pub fn greet(name: &str) {
    alert(&format!("Hello, {}!", name));
}
  1. Install this tool: cargo install wasm-pack
  2. Run wasm-pack build, optionally, pass a path to a dir or a scope (see above for details)
  3. This tool generates files in a pkg dir
  4. To publish to npm, run wasm-pack publish. You may need to login to the registry you want to publish to. You can login using wasm-pack login.

wasm-pack's People

Contributors

alexcrichton avatar andy-bell avatar ashleygwilliams avatar csmoe avatar data-pup avatar djfarly avatar drager avatar fitzgen avatar goto-bus-stop avatar huangjj27 avatar itsybitesyspider avatar kohensu avatar kwonoj avatar mackiovello avatar mciantyre avatar mgattozzi avatar migerh avatar mstallmo avatar mtharrison avatar nikgraf avatar noahlemen avatar robertohuertasm avatar sendilkumarn avatar spencerwilson avatar steveklabnik avatar tomashubelbauer avatar twilco avatar xmclark avatar xtuc avatar yoshuawuyts avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.