Skip to content

Commit 9420da1

Browse files
committed
fix: correct Rust rule names throughout documentation
Resolves #23 - Critical documentation inconsistency where all tutorials and examples used the wrong rule name. ## Changes Made - **All tutorial/example docs**: `rust_wasm_component` → `rust_wasm_component_bindgen` - **Load statements**: Updated to import correct rule - **BUILD examples**: Updated to use high-level rule with automatic WIT binding generation - **Attribute cleanup**: Removed deprecated attributes, use `profiles` for optimization ## Files Updated - getting-started.mdx: Fixed main onboarding example - first-component.md: Fixed step-by-step tutorial - index.mdx: Fixed homepage examples - examples/basic.md: Fixed basic example documentation - workflow/development-flow.mdx: Fixed workflow examples - composition/wac.md: Fixed composition examples - guides/external-wit-dependencies.mdx: Fixed dependency examples - languages/rust.md: Fixed Rust language guide - docs-site/BUILD.bazel: Fixed embedded examples - examples/using_external_wit_BUILD_example: Fixed example BUILD file ## Rule Clarification - `rust_wasm_component_bindgen`: High-level rule with automatic WIT binding generation (recommended for users) - `rust_wasm_component`: Lower-level rule requiring manual bindings (documented in reference/rules.mdx) All user-facing documentation now uses the correct high-level rule that matches working examples.
1 parent bc0a549 commit 9420da1

File tree

10 files changed

+25
-48
lines changed

10 files changed

+25
-48
lines changed

docs-site/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ genrule(
127127
<div class="feature">
128128
<h3>📦 Quick Start Example</h3>
129129
<div class="example">
130-
<pre><code>load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
130+
<pre><code>load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
131131
132-
rust_wasm_component(
132+
rust_wasm_component_bindgen(
133133
name = "hello_component",
134134
srcs = ["src/lib.rs"],
135135
wit = "component.wit",

docs-site/src/content/docs/composition/wac.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Let's start with a simple example to understand the fundamentals of component co
3939

4040
```python title="BUILD.bazel"
4141
load("@rules_wasm_component//wac:defs.bzl", "wac_compose")
42-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
42+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
4343
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
4444

4545
# Frontend component
@@ -49,11 +49,10 @@ wit_library(
4949
package_name = "frontend:[email protected]",
5050
)
5151

52-
rust_wasm_component(
52+
rust_wasm_component_bindgen(
5353
name = "frontend_component",
5454
srcs = ["src/frontend.rs"],
5555
wit = ":frontend_interfaces",
56-
deps = ["@crates//:wit-bindgen"],
5756
)
5857

5958
# Backend component
@@ -63,11 +62,10 @@ wit_library(
6362
package_name = "backend:[email protected]",
6463
)
6564

66-
rust_wasm_component(
65+
rust_wasm_component_bindgen(
6766
name = "backend_component",
6867
srcs = ["src/backend.rs"],
6968
wit = ":backend_interfaces",
70-
deps = ["@crates//:wit-bindgen"],
7169
)
7270

7371
# Compose them together

docs-site/src/content/docs/examples/basic.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Think of this as defining a microservice API, but one that works across any lang
6262

6363
```python title="BUILD.bazel"
6464
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
65-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
65+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
6666

6767
# Define WIT library target
6868
wit_library(
@@ -72,13 +72,10 @@ wit_library(
7272
)
7373

7474
# Build Rust WebAssembly component
75-
rust_wasm_component(
75+
rust_wasm_component_bindgen(
7676
name = "basic_component",
7777
srcs = ["src/lib.rs"],
7878
wit = ":hello_interfaces",
79-
deps = [
80-
"@crates//:wit-bindgen",
81-
],
8279
)
8380

8481
# Test the component
@@ -91,7 +88,7 @@ rust_wasm_component_test(
9188
**What each target does:**
9289

9390
- **`wit_library`** - Processes your WIT file and validates the interface
94-
- **`rust_wasm_component`** - Compiles your Rust code into a WebAssembly component
91+
- **`rust_wasm_component_bindgen`** - Compiles your Rust code into a WebAssembly component
9592
- **`rust_wasm_component_test`** - Creates tests for your component
9693

9794
The build system handles all the complexity: downloading toolchains, generating bindings, compiling to WebAssembly, and packaging as a component.

docs-site/src/content/docs/first-component.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Set up your `BUILD.bazel`:
118118

119119
```python title="BUILD.bazel"
120120
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
121-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component", "rust_wasm_component_test")
121+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen", "rust_wasm_component_test")
122122

123123
# WIT interface library
124124
wit_library(
@@ -128,13 +128,10 @@ wit_library(
128128
)
129129

130130
# Rust WebAssembly component
131-
rust_wasm_component(
131+
rust_wasm_component_bindgen(
132132
name = "greeting_component",
133133
srcs = ["src/lib.rs"],
134134
wit = ":greeting_interfaces",
135-
deps = [
136-
"@crates//:wit-bindgen",
137-
],
138135
)
139136

140137
# Component test

docs-site/src/content/docs/getting-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ This defines a "world" (think of it as an API) with one function: `greet` that t
108108

109109
<CodeFromFile file="examples/basic/BUILD.bazel" title="examples/basic/BUILD.bazel" />
110110

111-
The `wit_library` creates the interface definitions, and `rust_wasm_component` compiles your Rust code into a WebAssembly component that implements that interface.
111+
The `wit_library` creates the interface definitions, and `rust_wasm_component_bindgen` compiles your Rust code into a WebAssembly component that implements that interface.
112112

113113
### 3. Implement the Component
114114

docs-site/src/content/docs/guides/external-wit-dependencies.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ Reference external dependencies in your build targets:
775775

776776
```starlark title="BUILD.bazel"
777777
load("@rules_wasm_component//wit:defs.bzl", "wit_library", "wit_markdown")
778-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
778+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
779779

780780
# WIT library with external dependencies
781781
wit_library(
@@ -797,10 +797,9 @@ wit_markdown(
797797
)
798798

799799
# Build component with all dependencies resolved
800-
rust_wasm_component(
800+
rust_wasm_component_bindgen(
801801
name = "my_service",
802802
srcs = ["src/lib.rs"],
803-
world = "my-service-world",
804803
wit = ":my_service_wit",
805804
)
806805
```

docs-site/src/content/docs/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The **WebAssembly Component Model** is a revolutionary approach to building port
4747
Building WebAssembly components traditionally involves complex toolchains and manual configuration. **rules_wasm_component** makes it as easy as:
4848

4949
```python
50-
rust_wasm_component(
50+
rust_wasm_component_bindgen(
5151
name = "my_service",
5252
srcs = ["src/lib.rs"],
5353
wit = ":my_interfaces",
@@ -103,15 +103,15 @@ Create your first WebAssembly component in just a few steps:
103103

104104
```python title="BUILD.bazel"
105105
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
106-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
106+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
107107

108108
wit_library(
109109
name = "hello_interfaces",
110110
srcs = ["hello.wit"],
111111
package_name = "hello:[email protected]",
112112
)
113113

114-
rust_wasm_component(
114+
rust_wasm_component_bindgen(
115115
name = "hello_component",
116116
srcs = ["src/lib.rs"],
117117
wit = ":hello_interfaces",

docs-site/src/content/docs/languages/rust.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,18 @@ world calculator {
5555

5656
```python title="BUILD.bazel"
5757
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
58-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
58+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
5959

6060
wit_library(
6161
name = "calculator_interfaces",
6262
srcs = ["wit/calculator.wit"],
6363
package_name = "calculator:[email protected]",
6464
)
6565

66-
rust_wasm_component(
66+
rust_wasm_component_bindgen(
6767
name = "calculator_component",
6868
srcs = ["src/lib.rs"],
6969
wit = ":calculator_interfaces",
70-
deps = [
71-
"@crates//:wit-bindgen",
72-
"@crates//:anyhow", # For error handling
73-
],
7470
# Multiple build profiles
7571
profiles = ["debug", "release"],
7672
)
@@ -238,15 +234,11 @@ bazel build //:calculator_component_release
238234
### Custom Profile
239235

240236
```python title="BUILD.bazel"
241-
rust_wasm_component(
237+
rust_wasm_component_bindgen(
242238
name = "calculator_optimized",
243239
srcs = ["src/lib.rs"],
244240
wit = ":calculator_interfaces",
245-
rustc_flags = [
246-
"-C", "opt-level=3",
247-
"-C", "lto=fat",
248-
"-C", "codegen-units=1",
249-
],
241+
profiles = ["release"], # Use release profile for optimization
250242
)
251243
```
252244

@@ -371,7 +363,7 @@ calculator_component_bindings::export!(Calculator with_types_in calculator_compo
371363

372364
```bash
373365
# Check available profiles
374-
bazel query 'kind(rust_wasm_component, //...)'
366+
bazel query 'kind(rust_wasm_component_bindgen, //...)'
375367
```
376368

377369
<div class="demo-buttons">

docs-site/src/content/docs/workflow/development-flow.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,11 @@ bazel build //examples/wizer_example:optimized_component
139139
### Build Optimizations
140140

141141
```python
142-
rust_wasm_component(
142+
rust_wasm_component_bindgen(
143143
name = "optimized_component",
144144
srcs = ["lib.rs"],
145145
wit = ":interfaces",
146-
# Release optimizations
147-
compilation_mode = "opt",
148-
# Link-time optimization
149-
rustc_flags = ["-C", "lto=fat"],
150-
# Size optimization
151-
wasm_opt = True,
146+
profiles = ["release"], # Release optimizations
152147
)
153148
```
154149

examples/using_external_wit_BUILD_example

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ wit_markdown(
2121
)
2222

2323
# Use in your actual component build
24-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
24+
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
2525

26-
rust_wasm_component(
26+
rust_wasm_component_bindgen(
2727
name = "my_component",
2828
srcs = ["src/lib.rs"],
29-
world = "my-component-world",
3029
wit = ":my_component_wit", # All dependencies automatically included
3130
)

0 commit comments

Comments
 (0)