A simple CLI for WebAssembly component workflow
1.8K
Build WebAssembly components directly from WIT contracts using Python, Go, JavaScript, Rust, or C/C++.
All languages share the same workflow:
tarawasm init --lang python --wit ./wit --world calculator .
tarawasm bind
tarawasm build
The final validated WebAssembly Component Model binary is written to:
dist/<world>.wasm
Source code and examples are available on GitHub.
Create a helper function that runs tarawasm inside Docker:
tarawasm() {
docker run --rm \
-v "$PWD:/work" \
-w /work \
mandeser0/tarawasm:latest "$@"
}
Create wit/calculator.wit:
package example:[email protected];
world calculator {
export add: func(a: s32, b: s32) -> s32;
}
Initialize the project:
tarawasm init \
--lang python \
--wit ./wit \
--world calculator \
.
Generate bindings and build the component:
tarawasm bind
tarawasm build
The result is:
dist/calculator.wasm
Tarawasm generates a starter source file from the selected world's exports. Implement the generated functions and run tarawasm build again.
| Language | --lang | Starter source | Toolchain |
|---|---|---|---|
| Python | python | main.py | componentize-py |
| Go | go | main.go | wit-bindgen-go, TinyGo |
| JavaScript | js | main.js | jco, componentize-js |
| Rust | rust | src/lib.rs | cargo-component |
| C/C++ | c | component.c | wit-bindgen, WASI SDK, wasm-tools |
The Docker image includes all required compilers, SDKs, binding generators, and WebAssembly tools.
TinyGo's wasip2 target requires the selected world to import the complete versioned wasi:cli/[email protected] interface set.
Tarawasm validates these imports before invoking TinyGo and reports any missing interfaces.
tarawasm init \
--lang <python|go|js|rust|c> \
--wit <wit-file-or-directory> \
[--world <world>] \
[project-directory]
--wit accepts either:
.wit file;If the package contains exactly one world, --world may be omitted. If several worlds are available, tarawasm lists them and requires an explicit selection.
Preview initialization without changing the filesystem:
tarawasm init \
--lang rust \
--wit ./wit \
--world calculator \
--dry-run \
.
Initialization validates the WIT package before writing files. Existing user source files are not overwritten.
Use tarawasm import when starting from an existing WebAssembly component:
tarawasm import \
--lang python \
--component ./service.wasm \
--world service \
./service-project
The input must be a WebAssembly Component Model binary. Core WebAssembly modules are rejected.
Extracted WIT is stored in:
.tarawasm/imported-wit
The original component is never modified or treated as a generated artifact.
Generate language bindings:
tarawasm bind
Build the final component:
tarawasm build
Run both steps:
tarawasm all
Use a custom output path:
tarawasm build --out ./release/service.wasm
Preview commands without changing the project:
tarawasm bind --dry-run
tarawasm build --dry-run
Pass arguments directly to the underlying language tool after --:
tarawasm build -- --verbose
Display help for the selected backend tool:
tarawasm build --tool-help
Python dependencies can be installed into the mounted project without rebuilding the Docker image:
tarawasm pip install requests
tarawasm build
Install dependencies from a file:
tarawasm pip install -r requirements.txt
tarawasm build
Packages are stored in:
.tarawasm/site-packages
They persist in the mounted project and are automatically used by componentize-py.
To select another location, pass TARAWASM_PY_SITE_PACKAGES consistently during installation and build:
docker run --rm \
-v "$PWD:/work" \
-w /work \
-e TARAWASM_PY_SITE_PACKAGES=/work/vendor \
mandeser0/tarawasm:latest \
pip install -r requirements.txt
docker run --rm \
-v "$PWD:/work" \
-w /work \
-e TARAWASM_PY_SITE_PACKAGES=/work/vendor \
mandeser0/tarawasm:latest \
build
Tarawasm uses Bytecode Alliance wkg and wkg.lock for reproducible dependency resolution.
Resolve dependencies:
tarawasm deps resolve
List locked dependencies:
tarawasm deps list
Explicitly update dependency versions:
tarawasm deps update
Downloaded packages are cached under:
.tarawasm/deps/cache
Regular bind and build commands do not update the lock file.
A typical Python project looks like this:
calculator/
├── tarawasm.json
├── wit/
│ └── calculator.wit
├── main.py
├── .tarawasm/
│ ├── artifacts.json
│ ├── build/
│ │ └── python/
│ ├── deps/
│ │ └── cache/
│ └── site-packages/
└── dist/
└── calculator.wasm
Intermediate build files are kept under .tarawasm/build.
Only the final Component Model binary is placed in dist.
Remove generated artifacts with:
tarawasm clean
Tarawasm records generated files in .tarawasm/artifacts.json.
Cleanup removes only registered generated artifacts. It does not scan for arbitrary *.wasm files and does not delete user-owned directories such as target or internal.
The container detects the owner of the bind-mounted /work directory and runs build commands using the corresponding UID and GID.
Generated files therefore remain writable by the host user. The project directory is not made world-writable.
Every command can also be invoked directly:
docker run --rm \
-v "$PWD:/work" \
-w /work \
mandeser0/tarawasm:latest \
build
For interactive toolchain inspection:
docker run --rm -it \
-v "$PWD:/work" \
-w /work \
--entrypoint /bin/bash \
mandeser0/tarawasm:latest
Ready-to-build examples for all supported languages are available in the repository:
See the complete examples guide for ready-project, WIT-first, and component import workflows.
Content type
Image
Digest
sha256:f9aa74fc6…
Size
1.7 GB
Last updated
5 days ago
docker pull mandeser0/tarawasm