File tree 5 files changed +36
-14
lines changed
5 files changed +36
-14
lines changed Original file line number Diff line number Diff line change
1
+ # pack and publish
2
+
3
+ The ` publish ` and ` pack ` commands interact with the pkg directory that's
4
+ created when you run ` wasm-pack init ` . The ` pack ` command creates a tarball
5
+ from the pkg directory and the ` publish ` command creates a tarball from the
6
+ pkg directory __ and__ publishes it to the NPM registry.
7
+
8
+ Underneath, these commands use ` npm pack ` and ` npm publish ` . You can read
9
+ more about these in the NPM documentation:
10
+
11
+ - [ ` npm pack ` ] ( https://docs.npmjs.com/cli/pack )
12
+ - [ ` npm publish ` ] ( https://docs.npmjs.com/cli/publish )
13
+
14
+ Both these commands take the path to the pkg directory as the first argument.
15
+ You can either set the argument directly to the pkg directory or to the parent
16
+ of the pkg directory:
17
+
18
+ ```
19
+ $ wasm-pack pack myproject/pkg
20
+ | 🎒 packed up your package!
21
+ $ wasm-pack pack myproject
22
+ | 🎒 packed up your package!
23
+ ```
24
+
25
+ If you try to call ` pack ` or ` publish ` on another directory, you get an error:
26
+
27
+ ```
28
+ $ wasm-pack pack myproject/src/
29
+ Unable to find the pkg directory at path 'myproject/src/', or in a child directory of 'myproject/src/'
30
+ ```
31
+
32
+ If you don't set a path, they use the current directory as the path.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ use slog::Logger;
5
5
use std:: result;
6
6
use PBAR ;
7
7
8
+ /// Executes the 'npm pack' command on the 'pkg' directory
9
+ /// which creates a tarball that can be published to the NPM registry
8
10
pub fn pack ( path : Option < String > , log : & Logger ) -> result:: Result < ( ) , Error > {
9
11
let crate_path = set_crate_path ( path) ;
10
12
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ use slog::Logger;
5
5
use std:: result;
6
6
use PBAR ;
7
7
8
+ /// Creates a tarball from a 'pkg' directory
9
+ /// and publishes it to the NPM registry
8
10
pub fn publish ( path : Option < String > , log : & Logger ) -> result:: Result < ( ) , Error > {
9
11
let crate_path = set_crate_path ( path) ;
10
12
You can’t perform that action at this time.
0 commit comments