Skip to content

Commit 17d2104

Browse files
committed
docs: streamline README and fix documentation links
Simplified the README.md to focus on essential information now that comprehensive documentation is available through the docs-site. The README was reduced from 226 lines to ~45 lines (80% reduction) while retaining the core value proposition, installation, and quick example. Fixed broken documentation links in zero-to-component.mdx quick start guide that were pointing to non-existent pages, ensuring all internal links now point to actual documentation sections and examples. Also resolved unit test compilation issues where component implementation files were failing to compile for host platform due to WASM-specific bindings and export macros. Added conditional compilation directives to ensure component implementation code only compiles for WASM targets. Additional improvements: - Updated WKG configuration format to use simplified syntax - All unit tests now pass successfully - Documentation site builds without broken link warnings The streamlined README follows best practices for projects with comprehensive documentation sites, focusing on answering "should I use this?" and "how do I start?" while directing users to detailed docs for everything else.
1 parent 8d28f04 commit 17d2104

File tree

5 files changed

+31
-216
lines changed

5 files changed

+31
-216
lines changed

README.md

Lines changed: 16 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -1,224 +1,44 @@
11
# Bazel Rules for WebAssembly Component Model
22

3-
Modern Bazel rules for building and composing WebAssembly components.
3+
Modern Bazel rules for building WebAssembly components across multiple languages.
44

5-
## Features
5+
## Why Use This?
66

7-
- 🚀 **Component Model Support**: Full support for WASM Component Model and WIT
8-
- 🦀 **Rust Integration**: Seamless integration with rules_rust
9-
- 🐹 **Go Integration**: TinyGo v0.38.0 with WASI Preview 2 component support
10-
- 🔧 **Toolchain Management**: Automatic wasm-tools and wit-bindgen setup
11-
- 📦 **Composition**: WAC-based component composition with OCI registry support
12-
- 🐳 **OCI Publishing**: Publish and distribute components via container registries
13-
- 🔐 **Digital Signing**: Component signing with wasmsign2 and verification
14-
- 🏗️ **Enterprise Architecture**: Multi-registry microservices with security policies
15-
- 🎯 **Type Safety**: Strongly typed WIT interfaces
16-
-**Performance**: Optimized builds with proper caching
7+
- **Multi-language**: Build components from Rust, Go, C++, JavaScript
8+
- **Production Ready**: OCI publishing, signing, composition, optimization
9+
- **Bazel Native**: Hermetic builds, caching, cross-platform support
1710

1811
## Installation
1912

2013
Add to your `MODULE.bazel`:
2114

2215
```starlark
2316
bazel_dep(name = "rules_wasm_component", version = "1.0.0")
24-
25-
# Optional: Configure WASM toolchain version
26-
wasm_toolchain = use_extension(
27-
"@rules_wasm_component//wasm:extensions.bzl",
28-
"wasm_toolchain",
29-
)
30-
wasm_toolchain.register(
31-
name = "wasm_tools",
32-
version = "1.0.60", # Optional, defaults to latest stable
33-
)
34-
35-
# Optional: Configure TinyGo toolchain version
36-
tinygo = use_extension("//wasm:extensions.bzl", "tinygo")
37-
tinygo.register(
38-
name = "tinygo",
39-
tinygo_version = "0.38.0" # Optional, defaults to 0.38.0
40-
)
41-
```
42-
43-
## Quick Start
44-
45-
### 1. Define WIT Interfaces
46-
47-
```starlark
48-
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
49-
50-
wit_library(
51-
name = "my_interfaces",
52-
srcs = ["my-interface.wit"],
53-
deps = ["//wit/deps:wasi-io"],
54-
)
5517
```
5618

57-
### 2. Build Rust WASM Component
19+
## Quick Example
5820

5921
```starlark
60-
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component")
61-
62-
rust_wasm_component(
63-
name = "my_component",
22+
# Build a component from Rust
23+
rust_wasm_component_bindgen(
24+
name = "hello_component",
6425
srcs = ["src/lib.rs"],
65-
wit = ":my_interfaces",
66-
deps = [
67-
"//third_party/rust:wit_bindgen",
68-
],
26+
wit = ":hello_interfaces",
6927
)
7028
```
7129

72-
### 2b. Build Go WASM Component
73-
74-
```starlark
75-
load("@rules_wasm_component//go:defs.bzl", "go_wasm_component")
76-
77-
go_wasm_component(
78-
name = "my_go_component",
79-
srcs = ["main.go", "logic.go"],
80-
wit = "my-interface.wit",
81-
world = "my-world",
82-
go_mod = "go.mod",
83-
adapter = "//wasm/adapters:wasi_snapshot_preview1",
84-
)
85-
```
86-
87-
### 3. Compose Components
88-
89-
```starlark
90-
load("@rules_wasm_component//wac:defs.bzl", "wac_compose")
91-
92-
wac_compose(
93-
name = "my_system",
94-
components = {
95-
"frontend": ":frontend_component",
96-
"backend": ":backend_component",
97-
},
98-
composition = """
99-
let frontend = new frontend:component { ... };
100-
let backend = new backend:component { ... };
101-
102-
connect frontend.request -> backend.handler;
103-
104-
export frontend as main;
105-
""",
106-
)
107-
```
108-
109-
## Rules
110-
111-
### WIT Rules
112-
113-
- `wit_library` - Process WIT interface files
114-
- `wit_bindgen` - Generate language bindings from WIT
115-
116-
### Rust Rules
117-
118-
- `rust_wasm_component` - Build Rust WASM components
119-
- `rust_wasm_component_test` - Test WASM components
120-
121-
### Go Rules
122-
123-
- `go_wasm_component` - Build Go WASM components with TinyGo
124-
- `go_wit_bindgen` - Generate Go bindings from WIT interfaces
125-
126-
### Composition Rules
127-
128-
- `wac_compose` - Compose multiple components
129-
- `wac_compose_with_oci` - Compose local and OCI registry components
130-
- `wac_microservices_app` - Microservices composition pattern
131-
- `wac_distributed_system` - Distributed system composition pattern
132-
- `wasm_component_new` - Convert modules to components
133-
134-
### OCI Publishing Rules
135-
136-
- `wasm_component_oci_image` - Prepare OCI images for components
137-
- `wasm_component_publish` - Publish components to registries
138-
- `wasm_component_from_oci` - Pull components from OCI registries
139-
- `wkg_registry_config` - Configure registry authentication
140-
- `wkg_multi_registry_publish` - Publish to multiple registries
141-
142-
### Security Rules
143-
144-
- `wasm_keygen` - Generate signing key pairs
145-
- `wasm_sign` - Sign WebAssembly components
146-
- `wasm_security_policy` - Define security policies
147-
- `wasm_component_secure_publish` - Policy-enforced publishing
148-
149-
### Analysis Rules
150-
151-
- `wasm_validate` - Validate WASM components
152-
- `wit_lint` - Lint WIT interfaces
153-
154-
## Examples
155-
156-
See the [`examples/`](examples/) directory for complete examples:
157-
158-
### Core Examples
159-
160-
- [Basic Component](examples/basic/) - Simple component with WIT
161-
- [Go Component](examples/go_component/) - TinyGo WASM components
162-
- [JavaScript Component](examples/js_component/) - JS components with ComponentizeJS
163-
- [C++ Component](examples/cpp_component/) - Native C++ component development
164-
165-
### Composition and Architecture
166-
167-
- [WAC Remote Compose](examples/wac_remote_compose/) - Remote component composition
168-
- [WAC + OCI Composition](examples/wac_oci_composition/) - OCI registry integration
169-
- [Microservices Architecture](examples/microservices_architecture/) - Production-ready microservices
170-
- [Multi-Language Composition](examples/multi_language_composition/) - Polyglot component systems
171-
172-
### OCI and Distribution
173-
174-
- [OCI Publishing](examples/oci_publishing/) - Container registry publishing
175-
- [Component Signing](examples/wasm_signing/) - Digital signatures with wasmsign2
176-
177-
### Advanced Features
178-
179-
- [Wizer Pre-initialization](examples/wizer_example/) - Startup optimization
180-
- [Wasmtime Runtime](examples/wasmtime_runtime/) - Custom runtime integration
181-
- [Multi-Profile Components](examples/multi_profile/) - Development vs production builds
182-
18330
## Documentation
18431

185-
### For Developers
186-
187-
- [Rule Reference](docs/rules.md)
188-
- [Migration Guide](docs/migration.md)
189-
- [Best Practices](docs/best_practices.md)
190-
- [Troubleshooting](docs/troubleshooting.md)
191-
192-
### For AI Agents
32+
📚 **[Complete Documentation →](https://github.com/pulseengine/rules_wasm_component/tree/main/docs-site)**
19333

194-
- [**AI Agent Guide**](docs/ai_agent_guide.md) - Structured documentation for AI coding assistants
195-
- [**Rule Schemas**](docs/rule_schemas.json) - Machine-readable rule definitions
196-
- [Examples](docs/examples/) - Progressive complexity examples:
197-
- [Basic](docs/examples/basic/) - Fundamental patterns
198-
- [Intermediate](docs/examples/intermediate/) - Cross-package dependencies
199-
- [Advanced](docs/examples/advanced/) - Complex compositions and custom rules
34+
- **[Zero to Component in 2 Minutes](/docs-site/src/content/docs/zero-to-component.mdx)** - Fastest way to get started
35+
- **[Language Guides](/docs-site/src/content/docs/languages/)** - Rust, Go, C++, JavaScript tutorials
36+
- **[Production Deployment](/docs-site/src/content/docs/production/)** - OCI publishing, signing, optimization
37+
- **[Examples](examples/)** - Working examples from basic to advanced
20038

20139
## Contributing
20240

203-
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
204-
205-
### Development Setup
206-
207-
This project uses pre-commit hooks for code quality:
208-
209-
```bash
210-
# Install pre-commit
211-
pip install pre-commit
212-
213-
# Install hooks
214-
pre-commit install
215-
pre-commit install --hook-type commit-msg
216-
217-
# Test setup
218-
pre-commit run --all-files
219-
```
220-
221-
See [Pre-commit Instructions](.pre-commit-instructions.md) for detailed setup.
41+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
22242

22343
## License
22444

docs-site/src/content/docs/zero-to-component.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ bazelisk run @wasm_tools_toolchains//:wasm_tools -- component wit bazel-bin/hell
9090
## Next Steps (Pick Your Adventure)
9191

9292
### 🚀 **Want to understand what you just did?**
93-
[Understanding Your First Component](/first-component/) - Deep dive into the concepts
93+
[Code Explained Line by Line](/tutorials/code-explained/) - Deep dive into every line of code
9494

9595
### 💻 **Want to try different languages?**
9696
[Go Components](/languages/go/) - Build the same thing with TinyGo
9797
[C++ Components](/languages/cpp/) - Try native C++ development
9898
[JavaScript Components](/languages/javascript/) - Use ComponentizeJS
9999

100100
### 🏗️ **Want to build something more complex?**
101-
[Calculator Example](/examples/calculator/) - Error handling and multiple functions
102-
[HTTP Service](/examples/http-service/) - Web service component
103-
[Component Composition](/composition/wac/) - Combine multiple components
101+
[Multi-Language Composition](/examples/multi-language-composition/) - Combine Rust, Go, and JavaScript components
102+
[Microservices Architecture](/examples/microservices-architecture/) - Service composition patterns
103+
[OCI Publishing](/examples/oci-publishing/) - Deploy to container registries
104104

105105
### 🐛 **Something not working?**
106-
[Troubleshooting Guide](/troubleshooting/) - Common issues and solutions
106+
[Troubleshooting Guide](/troubleshooting/common-issues/) - Common issues and solutions
107107

108108
### 📚 **Want the full tutorial?**
109109
[Guided Rust Tutorial](/tutorials/rust-guided-walkthrough/) - Complete step-by-step explanation
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
#[cfg(target_arch = "wasm32")]
12
use test_component_with_deps_bindings::exports::test::consumer::advanced::Guest;
3+
#[cfg(target_arch = "wasm32")]
24
use test_component_with_deps_bindings::test::simple::math;
35

46
struct Component;
57

8+
#[cfg(target_arch = "wasm32")]
69
impl Guest for Component {
710
fn compute(x: u32, y: u32) -> u32 {
811
let sum = math::add(x, y);
912
sum * 2
1013
}
1114
}
1215

16+
#[cfg(target_arch = "wasm32")]
1317
test_component_with_deps_bindings::export!(Component with_types_in test_component_with_deps_bindings);

test/unit/fixtures/simple_impl.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
#[cfg(target_arch = "wasm32")]
12
use test_component_simple_bindings::exports::test::simple::math::Guest;
23

34
struct Component;
45

6+
#[cfg(target_arch = "wasm32")]
57
impl Guest for Component {
68
fn add(a: u32, b: u32) -> u32 {
79
a + b
810
}
911
}
1012

13+
#[cfg(target_arch = "wasm32")]
1114
test_component_simple_bindings::export!(Component with_types_in test_component_simple_bindings);

wkg/defs.bzl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ def _wkg_fetch_impl(ctx):
1717
config_content = ""
1818
if ctx.attr.registry:
1919
config_content = """
20-
[registry]
21-
default = "{registry}"
22-
23-
[registries."{registry}"]
24-
url = "{registry}"
20+
default_registry = "{registry}"
2521
""".format(registry = ctx.attr.registry)
2622

2723
config_file = None
@@ -154,11 +150,7 @@ def _wkg_lock_impl(ctx):
154150
config_content = ""
155151
if ctx.attr.registry:
156152
config_content = """
157-
[registry]
158-
default = "{registry}"
159-
160-
[registries."{registry}"]
161-
url = "{registry}"
153+
default_registry = "{registry}"
162154
""".format(registry = ctx.attr.registry)
163155

164156
config_file = None
@@ -248,11 +240,7 @@ version = "{version}"
248240
config_content = ""
249241
if ctx.attr.registry:
250242
config_content = """
251-
[registry]
252-
default = "{registry}"
253-
254-
[registries."{registry}"]
255-
url = "{registry}"
243+
default_registry = "{registry}"
256244
""".format(registry = ctx.attr.registry)
257245

258246
config_file = None

0 commit comments

Comments
 (0)