-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split init into init and build #216
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7cbfc2e
cmd(init/build): split init and build
csmoe edbd6f4
cmd(init/build): cargo fmt
csmoe 0a61662
cmd(init/build): cargo clippy
csmoe d0ac2fa
cmd(init/build): update docs
csmoe ddab496
cmd(init/build): rebase
csmoe 022b787
cmd(init/build): deprecate init
csmoe 3bccad9
Merge branch 'master' into build
ashleygwilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# wasm-pack build | ||
|
||
The `wasm-pack build` command creates the files neccessary for JavaScript | ||
interoperability and for publishing a package to npm. This involves compiling | ||
your code to wasm and generating a pkg folder. This pkg folder will contain the | ||
wasm binary, a JS wrapper file, your `README`, and a `package.json` file. | ||
|
||
## Path | ||
|
||
The `wasm-pack build` command can be given an optional path argument, e.g.: | ||
|
||
``` | ||
wasm-pack build examples/js-hello-world | ||
``` | ||
|
||
This path should point to a directory that contains a `Cargo.toml` file. If no | ||
path is given, the `build` command will run in the current directory. | ||
|
||
## Debug | ||
|
||
The init command accepts an optional `--debug` argument. This will build the | ||
output package using cargo's | ||
[default non-release profile][cargo-profile-sections-documentation]. Building | ||
this way is faster but applies few optimizations to the output, and enables | ||
debug assertions and other runtime correctness checks. | ||
|
||
The exact meaning of this flag may evolve as the platform matures. | ||
|
||
[cargo-profile-sections-documentation]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections | ||
|
||
## Target | ||
|
||
The `build` command accepts a `--target` argument. This will customize the output files | ||
to align with a particular type of JS module. This allows wasm-pack to generate either | ||
ES6 modules or CommonJS modules for use in browser and in NodeJS. Defaults to `browser`. | ||
The options are: | ||
|
||
``` | ||
wasm-pack build --target nodejs | ||
``` | ||
|
||
| Option | Description | | ||
|-----------|-----------------------------------------------------------------------------------------------------------------| | ||
| `nodejs` | Outputs JS that uses CommonJS modules, for use with a `require` statement. | | ||
| `browser` | Outputs JS that uses ES6 modules, primarily for use with `import` statements and/or bundlers such as `webpack`. | | ||
|
||
## Scope | ||
|
||
The init command also accepts an optional `--scope` argument. This will scope | ||
your package name, which is useful if your package name might conflict with | ||
something in the public registry. For example: | ||
|
||
``` | ||
wasm-pack build examples/js-hello-world --scope test | ||
``` | ||
|
||
This command would create a `package.json` file for a package called | ||
`@test/js-hello-world`. For more information about scoping, you can refer to | ||
the npm documentation [here][npm-scope-documentation]. | ||
|
||
[npm-scope-documentation]: https://docs.npmjs.com/misc/scope | ||
|
||
## Mode | ||
|
||
The `build` command accepts an optional `--mode` argument. | ||
``` | ||
wasm-pack build examples/js-hello-world --mode no-install | ||
``` | ||
|
||
| Option | Description | | ||
|---------------|------------------------------------------------------------------------------------------| | ||
| `no-install` | `wasm-pack init` implicitly and create wasm binding without installing `wasm-bindgen`. | | ||
| `normal` | do all the stuffs of `no-install` with installed `wasm-bindgen`. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# wasm-pack init | ||
# wasm-pack init(Deprecated) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: space before |
||
|
||
The `wasm-pack init` command creates the files neccessary for JavaScript | ||
interoperability and for publishing a package to npm. This involves compiling | ||
your code to wasm and generating a pkg folder. This pkg folder will contain the | ||
wasm binary, a JS wrapper file, your `README`, and a `package.json` file. | ||
interoperability and for publishing a package to npm. This involves | ||
generating a pkg folder. This pkg folder will contain the | ||
`README` and a `package.json` file. | ||
|
||
## Path | ||
|
||
|
@@ -46,27 +46,4 @@ This command would create a `package.json` file for a package called | |
`@test/js-hello-world`. For more information about scoping, you can refer to | ||
the npm documentation [here][npm-scope-documentation]. | ||
|
||
## Debug | ||
|
||
The init command accepts an optional `--debug` argument. This will build the | ||
output package using cargo's | ||
[default non-release profile][cargo-profile-sections-documentation]. Building | ||
this way is faster but applies few optimizations to the output, and enables | ||
debug assertions and other runtime correctness checks. | ||
|
||
The exact meaning of this flag may evolve as the platform matures. | ||
|
||
[npm-scope-documentation]: https://docs.npmjs.com/misc/scope | ||
[cargo-profile-sections-documentation]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections | ||
|
||
## Skipping build | ||
|
||
The init command accepts an optional `--skip-build` argument. | ||
|
||
This will deactivate those steps: | ||
- installing wasm target (via cargo) | ||
- compiling the code to wasm | ||
- installing wasm-bindgen (via rustup) | ||
- running wasm-bindgen on the built wasm | ||
|
||
Basically it will remains only the steps that update the metadata of `package.json`. | ||
[npm-scope-documentation]: https://docs.npmjs.com/misc/scope |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this line wasn't removed despite having added the deprecated tag