Skip to content

Commit e4a3f99

Browse files
committed
fix: correct wit_dependency_analyzer argument mismatch
- Revert to run_shell approach for proper output redirection - Tool expects single config.json argument and outputs to stdout - Fix incorrect two-argument call that caused usage errors - Restores WIT dependency validation functionality
1 parent da7fd6e commit e4a3f99

File tree

6 files changed

+133
-24
lines changed

6 files changed

+133
-24
lines changed

docs-site/astro.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ export default defineConfig({
6565
{ label: 'Go Components', slug: 'languages/go' },
6666
],
6767
},
68+
{
69+
label: 'Guides',
70+
items: [
71+
{ label: 'Advanced Features', slug: 'guides/advanced-features' },
72+
{ label: 'Toolchain Configuration', slug: 'guides/toolchain-configuration' },
73+
{ label: 'External WIT Dependencies', slug: 'guides/external-wit-dependencies' },
74+
],
75+
},
6876
{
6977
label: 'Examples',
7078
items: [

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@ title: WAC Composition
33
description: Build complex multi-component systems using WebAssembly Composition (WAC)
44
---
55

6-
Learn how to compose multiple WebAssembly components into sophisticated applications using WAC (WebAssembly Composition).
6+
## Building Applications from Components
77

8-
## Overview
8+
Think of **WAC (WebAssembly Composition)** as "wiring" for your WebAssembly components. Just like connecting electronic components on a circuit board, you can connect software components to create complete applications.
9+
10+
**The magic of composition:** You can take a Rust authentication service, a Go database connector, a JavaScript frontend, and a C++ data processor - all built as separate WebAssembly components - and wire them together into a single application.
11+
12+
**Why this matters:**
13+
- **Team independence** - Different teams can work on different components in their preferred languages
14+
- **Component reuse** - Build once, compose into multiple applications
15+
- **Easy testing** - Test components in isolation, then test the composition
16+
- **Flexible deployment** - Swap components without rebuilding everything
17+
18+
**How it works:** You write a simple "composition script" that describes which components to instantiate and how to connect their interfaces. WAC handles all the complexity of making them work together.
19+
20+
## Key Concepts
921

1022
WAC (WebAssembly Composition) allows you to:
1123

12-
- **Connect Components** - Link multiple components together
13-
- **Define Data Flow** - Specify how data moves between components
14-
- **Create Applications** - Build complete systems from component parts
15-
- **Maintain Isolation** - Components remain independent and secure
24+
- **Connect Components** - Link multiple components together through their interfaces
25+
- **Define Data Flow** - Specify how data moves between components
26+
- **Create Applications** - Build complete systems from component parts
27+
- **Maintain Isolation** - Components remain independent and secure
1628

1729
## Basic Composition
1830

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

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@ title: Getting Started
33
description: Quick start guide for building WebAssembly components with Bazel
44
---
55

6-
Get up and running with WebAssembly Component Model in minutes using Bazel.
6+
## Welcome to the Future of Software Components
7+
8+
Ready to build software that's **portable**, **secure**, and **fast**? WebAssembly components let you write code once and run it anywhere - from web browsers to servers, IoT devices to desktop apps.
9+
10+
Think of WebAssembly components as **smart LEGO blocks** for software:
11+
- **Plug-and-play**: Components from different languages work together seamlessly
12+
- **Secure by design**: Each component runs in its own sandbox
13+
- **Near-native speed**: Performance similar to compiled C/C++
14+
- **Universal deployment**: Same component runs on any platform
15+
16+
**rules_wasm_component** makes building these components as easy as traditional software - no complex WebAssembly knowledge required!
717

818
## Prerequisites
919

@@ -76,32 +86,56 @@ wit-bindgen = { version = "0.30.0", default-features = false, features = ["reall
7686

7787
## Your First Component
7888

79-
Let's create a simple "Hello World" WebAssembly component:
89+
Let's create a simple "Hello World" WebAssembly component to see how easy it is.
90+
91+
**What we're building**: A self-contained WebAssembly component that exports a "greet" function. Unlike traditional libraries, this component can be called from any language and runs in complete isolation.
92+
93+
**The process**: We'll define an interface (what functions the component provides), implement the logic in Rust, and let Bazel handle all the WebAssembly compilation magic.
8094

8195
### 1. Define the WIT Interface
8296

97+
**WIT (WebAssembly Interface Types)** is like a contract - it describes what functions your component provides and what types they use. This lets other components (in any language) know how to call your code.
98+
8399
import CodeFromFile from '@components/CodeFromFile.astro';
84100

85101
<CodeFromFile file="examples/basic/wit/hello.wit" title="examples/basic/wit/hello.wit" />
86102

103+
This defines a "world" (think of it as an API) with one function: `greet` that takes a string and returns a string.
104+
87105
### 2. Create the Build File
88106

107+
**Bazel BUILD files** tell the build system how to compile your code. Here we're saying "take this WIT interface and this Rust code, and build me a WebAssembly component":
108+
89109
<CodeFromFile file="examples/basic/BUILD.bazel" title="examples/basic/BUILD.bazel" />
90110

111+
The `wit_library` creates the interface definitions, and `rust_wasm_component` compiles your Rust code into a WebAssembly component that implements that interface.
112+
91113
### 3. Implement the Component
92114

115+
**The Rust implementation** is just normal Rust code. The `wit-bindgen` macro automatically generates the glue code that connects your Rust functions to the WebAssembly component interface:
116+
93117
<CodeFromFile file="examples/basic/src/lib.rs" title="examples/basic/src/lib.rs" />
94118

95119
### 4. Build the Component
96120

121+
**That's it!** Bazel handles downloading the WebAssembly toolchain, compiling your Rust code, and packaging everything into a component:
122+
97123
```bash
98124
# Build the component
99125
bazel build //:hello_component
100126

101-
# Test with wasmtime
127+
# Test with wasmtime (WebAssembly runtime)
102128
wasmtime run --wasi preview2 bazel-bin/hello_component.wasm
103129
```
104130

131+
**What just happened?** Bazel automatically:
132+
- Downloaded the Rust toolchain and WebAssembly tools
133+
- Compiled your Rust code to WebAssembly
134+
- Generated bindings from your WIT interface
135+
- Packaged everything into a `.wasm` component file
136+
137+
Your component is now ready to run on any platform that supports WebAssembly!
138+
105139
<div class="demo-buttons">
106140
<a href="https://stackblitz.com/github/pulseengine/rules_wasm_component/tree/main/examples/basic" class="demo-button">
107141
Try this example in StackBlitz

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,41 @@ hero:
2121

2222
import { Card, CardGrid } from '@astrojs/starlight/components';
2323

24+
## What is the WebAssembly Component Model?
25+
26+
The **WebAssembly Component Model** is a revolutionary approach to building portable, secure, and composable software. Think of it as "microservices for WebAssembly" - you can build small, focused components in any language and connect them together like LEGO blocks.
27+
28+
### Why Should You Care?
29+
30+
**🔗 Language Freedom**: Write your auth service in Rust, your API in Go, your frontend in JavaScript, and your ML pipeline in Python - all running together seamlessly.
31+
32+
**🚀 Performance**: Near-native speed with WebAssembly's efficiency, but with the safety and portability of sandboxed execution.
33+
34+
**📦 True Portability**: Build once, run anywhere - from edge devices to cloud servers, from browsers to embedded systems.
35+
36+
**🔒 Security by Default**: Each component runs in its own sandbox with explicit interfaces - no hidden dependencies or side effects.
37+
38+
### Real-World Use Cases
39+
40+
- **Microservices**: Replace Docker containers with lightweight WASM components
41+
- **Plugin Systems**: Add extensibility to your apps with secure, fast plugins
42+
- **Edge Computing**: Deploy the same code to CDN edges, IoT devices, and cloud
43+
- **Multi-language Projects**: Combine the best tools from different ecosystems
44+
45+
## Why rules_wasm_component?
46+
47+
Building WebAssembly components traditionally involves complex toolchains and manual configuration. **rules_wasm_component** makes it as easy as:
48+
49+
```python
50+
rust_wasm_component(
51+
name = "my_service",
52+
srcs = ["src/lib.rs"],
53+
wit = ":my_interfaces",
54+
)
55+
```
56+
57+
That's it! Bazel handles the complexity while you focus on building great software.
58+
2459
## Features
2560

2661
<CardGrid stagger>

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

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,35 @@ title: Rust Components
33
description: Build WebAssembly components with Rust using rules_rust integration
44
---
55

6-
Build high-performance WebAssembly components with Rust, featuring seamless rules_rust integration and wit-bindgen support.
6+
## Why Rust for WebAssembly Components?
7+
8+
Rust is the **ideal language** for WebAssembly components. Its zero-cost abstractions, memory safety, and lack of runtime overhead make it perfect for creating fast, secure, portable components.
9+
10+
**The Rust advantage:**
11+
- **Memory safety without garbage collection** - Perfect for sandboxed environments
12+
- **Zero-cost abstractions** - High-level code compiles to efficient WebAssembly
13+
- **Excellent tooling** - wit-bindgen automatically generates all the glue code
14+
- **Small binaries** - Dead code elimination keeps components lightweight
15+
- **Mature ecosystem** - Leverage existing Rust crates in your components
16+
17+
**How it works:** You write normal Rust code, define interfaces in WIT (WebAssembly Interface Types), and the toolchain handles all the WebAssembly compilation magic. The result is a portable component that can be called from any language.
718

819
## Features
920

10-
- **Full Component Model Support** - WASI Preview 2 and Component Model
11-
- **wit-bindgen Integration** - Automatic binding generation from WIT interfaces
12-
- **Multiple Build Profiles** - Debug, release, and custom configurations
13-
- **rules_rust Integration** - Leverages existing Bazel Rust ecosystem
14-
- **Incremental Builds** - Fast iteration with Bazel caching
21+
- **Full Component Model Support** - WASI Preview 2 and Component Model
22+
- **wit-bindgen Integration** - Automatic binding generation from WIT interfaces
23+
- **Multiple Build Profiles** - Debug, release, and custom configurations
24+
- **rules_rust Integration** - Leverages existing Bazel Rust ecosystem
25+
- **Incremental Builds** - Fast iteration with Bazel caching
1526

1627
## Basic Component
1728

29+
Let's build a calculator component to demonstrate the core concepts. This example shows how to:
30+
- Define a clear interface with WIT
31+
- Implement business logic in pure Rust
32+
- Handle errors properly with WebAssembly-safe types
33+
- Build and test the component
34+
1835
### WIT Interface Definition
1936

2037
```wit title="wit/calculator.wit"
@@ -357,18 +374,20 @@ bazel query 'kind(rust_wasm_component, //...)'
357374

358375
<div class="demo-buttons">
359376
<a href="https://stackblitz.com/github/pulseengine/rules_wasm_component/tree/main/examples/basic" class="demo-button">
360-
🚀 Try Rust Example
377+
Try Rust Example
361378
</a>
362379
<a href="/examples/basic/" class="demo-button">
363-
📖 Full Example
380+
Full Example
364381
</a>
365382
</div>
366383

367384
## Performance Characteristics
368385

369-
<div class="perf-indicator">⚡ 1.35-6x faster startup with Wizer</div>
370-
<div class="perf-indicator">🚀 ~2MB typical component size</div>
371-
<div class="perf-indicator">💾 Low memory footprint with wee_alloc</div>
386+
**Production-ready performance** out of the box:
387+
388+
<div class="perf-indicator">1.35-6x faster startup with Wizer</div>
389+
<div class="perf-indicator">~2MB typical component size</div>
390+
<div class="perf-indicator">Low memory footprint with wee_alloc</div>
372391

373392
Rust components offer excellent performance characteristics:
374393

wit/wit_deps_check.bzl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ def _wit_deps_check_impl(ctx):
2222
# Run dependency analysis
2323
output_file = ctx.actions.declare_file(ctx.label.name + "_analysis.json")
2424

25-
# Run dependency analysis using Bazel-native approach
26-
ctx.actions.run(
27-
executable = ctx.executable._wit_dependency_analyzer,
28-
arguments = [config_file.path, output_file.path],
25+
# Run dependency analysis using ctx.actions.run_shell for output redirection
26+
ctx.actions.run_shell(
27+
command = "$1 $2 > $3",
28+
arguments = [ctx.executable._wit_dependency_analyzer.path, config_file.path, output_file.path],
2929
inputs = [config_file, ctx.file.wit_file],
3030
outputs = [output_file],
31+
tools = [ctx.executable._wit_dependency_analyzer],
3132
mnemonic = "CheckWitDependencies",
3233
progress_message = "Checking WIT dependencies in %s" % ctx.file.wit_file.short_path,
3334
)

0 commit comments

Comments
 (0)