Expand description
WebAssembly component builder with multi-language support
This module provides functionality to build WebAssembly components from various source languages, with support for both WASI Preview 1 and Preview 2 (component model) targets.
§Supported Languages
- Rust:
cargo build --target wasm32-wasip1orcargo component build - Go:
TinyGocompiler with WASI target - Python: componentize-py for component model
- TypeScript/JavaScript: jco/componentize-js
AssemblyScript: asc compiler- C: Clang with WASI SDK
- Zig: Native WASI support
§Usage
use std::path::Path;
use zlayer_builder::wasm_builder::{build_wasm, WasmBuildConfig, WasiTarget};
let config = WasmBuildConfig {
language: None, // Auto-detect
target: WasiTarget::Preview2,
optimize: true,
..Default::default()
};
let result = build_wasm(Path::new("./my-plugin"), config).await?;
println!("Built {} WASM at {}", result.language, result.wasm_path.display());Structs§
- Wasm
Build Config - Configuration for building a WASM component
- Wasm
Build Result - Result of a successful WASM build
Enums§
- Wasi
Target - WASI target version
- Wasm
Build Error - Error types for WASM build operations
- Wasm
Language - Supported source languages for WASM compilation
Functions§
- build_
wasm - Build a WASM component from source
- detect_
language - Detect the source language from files in the given directory
- get_
build_ command - Get the build command for a specific language and target
- get_
build_ command_ with_ config - Get the build command with full config support (world, features, etc.)
- optimize_
wasm - Optimize a WASM binary using wasm-opt.
Type Aliases§
- Result
- Result type for WASM build operations