GithubHelp home page GithubHelp logo

frewsxcv / wasm-pack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rustwasm/wasm-pack

0.0 1.0 0.0 2.52 MB

๐Ÿ“ฆโœจ pack up the wasm and publish it to npm!

License: Apache License 2.0

Rust 100.00%

wasm-pack's Introduction

๐Ÿ“ฆโœจ wasm-pack

pack up the wasm and publish it to npm!

Build Status Build status

the goal of this project is to create a portable command line tool for publishing compiled wasm projects to the npm registry for the consumption of js devs using the npm CLI, yarn, or any other CLI tool that interfaces with the npm registry.

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

๐Ÿ”ฎ prerequisities

this project is written in rust. get rust to work on this project.

๐Ÿƒโ€โ™€๏ธ up and running

  1. fork and clone this repository
  2. cd wasm-pack
  3. cargo run

๐Ÿ’ƒ commands

  • help: display available commands
  • ๐Ÿฃ init: create necessary files for js interop and npm publishing
    • optionally pass a path to a dir that contains a Cargo.toml, e.g.:
      wasm-pack init examples/js-hello-world
      
    • optionally pass a scope name to generate a package.json for a scoped pkg, e.g.:
      wasm-pack init examples/scopes-hello-world --scope test
      
      generates a package.json for an npm package called @test/scopes-hello-world

to be implemented

  • ๐Ÿฑ pack: create a tarball but don't push to the npm registry [NOT IMPLEMENTED]
  • ๐ŸŽ† publish: create a tarball and publish to the npm registry [NOT IMPLEMENTED]

โš™๏ธ how to use

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

  [dependencies]
  wasm-bindgen = { git = 'https://github.com/alexcrichton/wasm-bindgen' }
  1. add this to the top of your src/lib.rs:
  #![feature(proc_macro)]

  extern crate wasm_bindgen;

  use wasm_bindgen::prelude::*;
  1. annotate your public functions with #[wasm_bindgen], for example:
#[wasm_bindgen]
extern {
    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 init, optionally, pass a path to a dir or a scope (see above for details)
  3. this tool generates files in a pkg dir. to publish to npm, cd pkg and then npm publish (in the future you'll be able to use this tool to publish)

wasm-pack's People

Contributors

ashleygwilliams avatar mgattozzi avatar sendilkumarn avatar steveklabnik avatar yoshuawuyts avatar

Watchers

 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.