Skip to content

Commit e63b3d1

Browse files
committed
PR feedback about console vs sh and warnings
1 parent 688bbbd commit e63b3d1

File tree

1 file changed

+20
-18
lines changed
  • component-model/src/language-support

1 file changed

+20
-18
lines changed

component-model/src/language-support/rust.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ the component's implementation language.
1111
## 1. Setup
1212

1313
Install [`cargo-component`][cargo-component-install]:
14-
```console
14+
```sh
1515
cargo install --locked cargo-component
1616
```
1717
Install [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools#installation):
18-
```console
18+
```sh
1919
cargo install --locked wasm-tools
2020
```
2121
Install [`wasmtime`](https://github.com/bytecodealliance/wasmtime#installation):
22-
```console
22+
```sh
2323
curl https://wasmtime.dev/install.sh -sSf | bash
2424
```
2525
Clone the [component-docs](https://github.com/bytecodealliance/component-docs) repo:
26-
```console
26+
```sh
2727
git clone https://github.com/bytecodealliance/component-docs
2828
```
2929

@@ -35,12 +35,12 @@ by the [`adder` world][docs-adder] world in the
3535
[package](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#package-names).
3636

3737
First `cd` into the `tutorial` directory found in the repo we just cloned:
38-
```console
38+
```sh
3939
cd component-docs/component-model/examples/tutorial
4040
```
4141

4242
Now create a new WebAssembly component package called `add`:
43-
```console
43+
```sh
4444
cargo component new add --lib && cd add
4545
```
4646

@@ -64,7 +64,7 @@ package = "docs:adder"
6464
Now that we've updated our `world.wit` and `Cargo.toml`, we can re-generate
6565
bindings with the command below:
6666

67-
```console
67+
```sh
6868
cargo component bindings
6969
```
7070

@@ -85,13 +85,21 @@ code should look something like the following:
8585

8686
Now, let's build our component, being sure to optimize with a release build:
8787

88-
```console
88+
```sh
8989
cargo component build --release
9090
```
9191

92+
> [!WARNING]
93+
> Building with `--release` removes all debug-related information from the resulting .wasm file.
94+
>
95+
> When prototyping or testing locally, you might want to avoid `--release` to
96+
> obtain useful backtraces in case of errors (for example, with
97+
> `wasmtime::WasmBacktraceDetails::Enable`). Note: the resulting .wasm file
98+
> will be considerably larger (likely 4MB+).
99+
92100
You can use `wasm-tools` to output the WIT package of the component:
93101

94-
```console
102+
```sh
95103
wasm-tools component wit target/wasm32-wasip1/release/add.wasm
96104
```
97105

@@ -110,10 +118,6 @@ package docs:[email protected] {
110118
}
111119
```
112120

113-
> [!WARNING]
114-
> Building with `--release` removes all debug-related information from the resulting .wasm file.
115-
>
116-
> When prototyping or testing locally, you might want to avoid `--release` to obtain useful backtraces in case of errors (for example, with `wasmtime::WasmBacktraceDetails::Enable`). Note: the resulting .wasm file will be considerably larger (likely 4MB+).
117121

118122
### Running a Component
119123

@@ -123,7 +127,7 @@ component targeting the [`adder` world](#adding-the-wit-world).
123127
The application uses [`wasmtime`](https://github.com/bytecodealliance/wasmtime) crates to generate
124128
Rust bindings, bring in WASI worlds, and execute the component.
125129

126-
```sh
130+
```console
127131
$ cd examples/example-host
128132
$ cargo run --release -- 1 2 ../add/target/wasm32-wasip1/release/adder.wasm
129133
1 + 2 = 3
@@ -175,9 +179,7 @@ world calculator {
175179

176180
### Referencing the package to import
177181

178-
Because the `docs:adder` package is in a different project, we must first tell
179-
`cargo component` how to find it. To do this, add the following to the
180-
`Cargo.toml` file:
182+
Because the `docs:adder` package is in a different project, we must first tell `cargo component` how to find it. To do this, add the following to the `Cargo.toml` file:
181183

182184
```toml
183185
[package.metadata.component.target.dependencies]
@@ -313,7 +315,7 @@ As mentioned above, `cargo component build` doesn't generate a WIT file for a co
313315
314316
6. Run the composed component:
315317
316-
```sh
318+
```console
317319
$ wasmtime run ./my-composed-command.wasm
318320
1 + 1 = 579 # might need to go back and do some work on the calculator implementation
319321
```

0 commit comments

Comments
 (0)