1
1
# 📦✨ wasm-pack
2
- > pack up the wasm and publish it to npm !
2
+ > Your favorite rust -> wasm workflow tool !
3
3
4
4
[ ![ Build Status] ( https://travis-ci.org/ashleygwilliams/wasm-pack.svg?branch=master )] ( https://travis-ci.org/ashleygwilliams/wasm-pack )
5
5
[ ![ Build status] ( https://ci.appveyor.com/api/projects/status/7jjuo5wewu9lyyfi?svg=true )] ( https://ci.appveyor.com/project/ashleygwilliams/wasm-pack )
6
6
7
- the goal of this project is to create a portable command line tool
8
- for publishing compiled wasm projects to the npm registry for the consumption
9
- of js devs using the npm CLI, yarn, or any other CLI tool that interfaces
10
- with the npm registry.
7
+ This tool seeks to be a one-stop shop for building and working with rust-
8
+ generated WebAssembly that you would like to interop with JavaScript, in the
9
+ browser or with Node.js. ` wasm-pack ` helps you build and publish rust-generated
10
+ WebAssembly to the npm registry to be used alongside any other javascript
11
+ package in workflows that you already use, such as a bundler like
12
+ [ webpack] or [ greenkeeper] .
11
13
12
- this project is a part of the [ rust-wasm] group. you can find more info by
14
+ [ bundler-support ] : https://github.com/rustwasm/team/blob/master/goals/bundler-integration.md#details
15
+ [ webpack ] : https://webpack.js.org/
16
+ [ greenkeeper] : https://greenkeeper.io/
17
+
18
+ This project is a part of the [ rust-wasm] group. You can find more info by
13
19
visiting that repo!
14
20
15
21
[ rust-wasm ] : https://github.com/rust-lang-nursery/rust-wasm/
16
22
17
23
![ demo] ( demo.gif )
18
24
19
- ## 🔮 prerequisities
20
-
21
- this project is written in rust. [ get rust] to work on this project.
22
-
23
- [ get rust ] : https://www.rustup.rs/
24
-
25
- if you want to publish packages, you'll also need an account on [ npm] and have
26
- [ node/npm] installed.
25
+ ## 🔮 Prerequisities
27
26
28
- [ npm ] : https://www.npmjs.com
29
- [ node/npm ] : https://nodejs.org/
27
+ - [ Development Environment ] ( docs/prerequisites.md )
28
+ - [ Installation and Getting Started ] ( docs/setup.md )
30
29
31
- ## 🏃♀️ up and running
30
+ ## 🎙️ Commands
32
31
33
- 1 . fork and clone this repository
34
- 2 . install [ node/npm]
35
- 2 . ` cd wasm-pack `
36
- 3 . ` cargo run `
32
+ - [ ` init ` ] ( docs/init.md ) : Generate an npm wasm pkg from a rustwasm crate
33
+ - [ ` pack ` ] ( docs/pack.md ) : Create a tarball of your rustwasm pkg
34
+ - [ ` publish ` ] ( docs/publish.md ) : Publish your rustwasm pkg to a registry
37
35
38
- ## 💃 commands
39
- - ` help ` : display available commands
40
- - 🐣 ` init ` : create necessary files for js interop and npm publishing
41
- - optionally pass a path to a dir that contains a ` Cargo.toml ` , e.g.:
42
- ```
43
- wasm-pack init examples/js-hello-world
44
- ```
45
- - optionally pass a scope name to generate a `package.json` for a scoped pkg, e.g.:
46
- ```
47
- wasm-pack init examples/scopes-hello-world --scope test
48
- ```
49
- generates a `package.json` for an npm package called `@test/scopes-hello-world`
50
- - 🍱 `pack`: create a tarball but don't push to the npm registry (see https://docs.npmjs.com/cli/pack)
51
- - 🎆 `publish`: create a tarball and publish to the npm registry (see https://docs.npmjs.com/cli/publish)
52
-
53
- ### logging
36
+ ## 📝 Logging
54
37
55
38
We generate a ` wasm-pack.log ` file if ` wasm-pack ` errors on you, and you can
56
39
customize the log verbosity using the verbosity flag.
@@ -61,11 +44,18 @@ customize the log verbosity using the verbosity flag.
61
44
| -vv | All Debug, Info, Warn, and Errors are logged |
62
45
| -vvv | All Trace, Debug, Info, Warn, and Errors are logged |
63
46
47
+ ## 👯 Contributing
48
+
49
+ Read our [ guide] on getting up and running for developing ` wasm-pack ` , and
50
+ check out our [ contribution policy] .
51
+
52
+ [ guide ] : doc/contributing.md
53
+ [ contribution policy ] : CONTRIBUTING.md
64
54
65
- ## ⚙️ how to use
55
+ ## ⚡ Quickstart Guide
66
56
67
- 1. write a crate in Rust.
68
- 2. add `wasm-bindgen` to your `Cargo.toml`:
57
+ 1 . Write a crate in Rust.
58
+ 2 . Add ` wasm-bindgen ` to your ` Cargo.toml ` :
69
59
70
60
``` toml
71
61
[lib ]
@@ -74,7 +64,7 @@ customize the log verbosity using the verbosity flag.
74
64
[dependencies ]
75
65
wasm-bindgen = " 0.2"
76
66
```
77
- 3 . add this to the top of your ` src/lib.rs ` :
67
+ 3 . Add this to the top of your ` src/lib.rs ` :
78
68
79
69
``` rust
80
70
#![feature(proc_macro, wasm_import_module, wasm_custom_section)]
@@ -84,7 +74,7 @@ customize the log verbosity using the verbosity flag.
84
74
use wasm_bindgen :: prelude :: * ;
85
75
```
86
76
87
- 4 . annotate your public functions with ` #[wasm_bindgen] ` , for example:
77
+ 4 . Annotate your public functions with ` #[wasm_bindgen] ` , for example:
88
78
89
79
``` rust
90
80
#[wasm_bindgen]
@@ -98,10 +88,11 @@ customize the log verbosity using the verbosity flag.
98
88
}
99
89
```
100
90
101
- 5 . install this tool: ` cargo install wasm-pack `
102
- 6 . run ` wasm-pack init ` , optionally, pass a path to a dir or a scope (see above for details)
103
- 7 . this tool generates files in a ` pkg ` dir
104
- 8 . to publish to npm, run ` wasm-pack publish ` (making sure you are logged in with npm)
91
+ 5 . Install this tool: ` cargo install wasm-pack `
92
+ 6 . Run ` wasm-pack init ` , optionally, pass a path to a dir or a scope (see above for details)
93
+ 7 . This tool generates files in a ` pkg ` dir
94
+ 8 . To publish to npm, run ` wasm-pack publish ` . You may need to login to the
95
+ registry you want to publish to. You can login using ` wasm-pack login ` .`
105
96
106
97
[ rust-wasm/36 ] : https://github.com/rust-lang-nursery/rust-wasm/issues/36
107
98
[ wasm-bindgen ] : https://github.com/alexcrichton/wasm-bindgen
0 commit comments