5 releases
new 0.1.4 | Apr 28, 2025 |
---|---|
0.1.3 | Apr 27, 2025 |
0.1.2 | Apr 27, 2025 |
0.1.1 | Apr 27, 2025 |
0.1.0 | Apr 27, 2025 |
#92 in Development tools
129 downloads per month
2.5MB
567 lines
Chakra
Chakra is a lightweight tool that lets you run WebAssembly (WASM) modules directly in your browser with zero configuration.
Features
- 🚀 Simple: Just point Chakra at your .wasm file and go
- 🌐 Browser-based: Instantly opens your default browser
- 📊 Interactive console: View execution results and logs
- 🔍 Smart detection: Identifies common entry points [slightly buggy]
- 🧩 Diagnostic tools: Helps troubleshoot WASM modules [TODO]
Installation
From Cargo (Recommended)
cargo install chakra
From Source
git clone https://github.com/anistark/chakra.git
cd chakra
cargo install --path .
Usage
Basic Usage
Run a WebAssembly file directly:
chakra --path ./path/to/your/file.wasm
Custom Port
Specify a custom port (default is 8420
):
chakra --path ./path/to/your/file.wasm --port 3000
Stop Server
Stop any running Chakra server:
chakra stop
How It Works
When you run Chakra with a WASM file:
- It starts a lightweight HTTP server
- Opens your default browser
- Serves the WASM file along with a nice UI
- Attempts to instantiate and run the WebAssembly module
- Shows execution results and console logs
Supported WASM Types
Chakra works best with:
- Simple C/C++ compiled WASM files
- Rust WASM files compiled without wasm-bindgen
- Any WASM that doesn't require extensive JavaScript bindings
For complex WASM modules (like those compiled with wasm-bindgen), Chakra will detect this and provide helpful information, but may not be able to execute them fully.
Examples
Running a simple C-compiled WASM file:
# Compile C to WASM (requires emscripten)
emcc -O2 hello.c -o hello.wasm
# Run with Chakra
chakra --path hello.wasm
Running a simple Rust WASM file:
# Build a WASM file from Rust
cargo build --target wasm32-unknown-unknown --release
# Run with Chakra
chakra --path ./target/wasm32-unknown-unknown/release/yourapp.wasm
Troubleshooting
- "Port is already in use": Try specifying a different port with
--port
- "No WASM entry point found": Your WASM file might not have standard entry points like
main()
or_start()
- "This appears to be a wasm-bindgen module": Try using the original JavaScript loader that came with your WASM file
License
Credits
Chakra is built with:
Dependencies
~3–13MB
~150K SLoC