Skip to content

Commit

Permalink
add test and some documentation for custom extra options passed to bu…
Browse files Browse the repository at this point in the history
…ild command
  • Loading branch information
torkve committed Dec 18, 2018
1 parent 57eb5ac commit 5ea80e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/src/commands/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ wasm-pack build examples/js-hello-world --mode no-install
|---------------|------------------------------------------------------------------------------------------|
| `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`. |

## Extra options

The `build` command can pass extra options straight to `cargo build` even if they are not
supported in wasm-pack. To use them you should add standalone `--` argument at the very
end of your command, and all the arguments you want to pass to cargo should go after.
For example to build previous example using unstable cargo offline feature:

```
wasm-pack build examples/js-hello-world --mode no-install -- -Z offline
```
17 changes: 17 additions & 0 deletions tests/all/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,20 @@ fn build_with_and_without_wasm_bindgen_debug() {
);
}
}

#[test]
fn build_with_arbitrary_cargo_options() {
let fixture = utils::fixture::js_hello_world();
fixture.install_local_wasm_bindgen();

let cli = Cli::from_iter_safe(vec![
"wasm-pack",
"build",
&fixture.path.display().to_string(),
"--",
"--no-default-features",
])
.unwrap();
fixture.run(cli.cmd).unwrap();
}

0 comments on commit 5ea80e1

Please sign in to comment.