mix raxol.wasm (Raxol v2.0.1)

View Source

Compiles Raxol to WebAssembly for web deployment.

Usage

mix raxol.wasm [options]

Options

  • --watch - Watch for changes and rebuild automatically
  • --optimize - Enable WASM optimization (default: true)
  • --release - Build in release mode with maximum optimization
  • --clean - Clean build artifacts before building
  • --serve - Start a web server to test the WASM build

Examples

# Build WASM module
mix raxol.wasm

# Build with watch mode for development
mix raxol.wasm --watch

# Build optimized release version
mix raxol.wasm --release

# Clean and rebuild
mix raxol.wasm --clean

# Build and serve for testing
mix raxol.wasm --serve

Configuration

Configure WASM build in config/wasm.exs:

config :raxol, :wasm,
  output_dir: "priv/static/wasm",
  optimization_level: 2,
  initial_memory: 16,
  maximum_memory: 256

Requirements

Requires Rust toolchain with wasm32-unknown-unknown target:

rustup target add wasm32-unknown-unknown

Optional: wasm-opt for optimization:

npm install -g wasm-opt

Output

Generates the following files:

  • priv/static/wasm/raxol.wasm - WebAssembly module
  • priv/static/js/raxol-terminal.js - JavaScript bindings
  • priv/static/wasm/index.html - Demo HTML page

Deployment

Copy the generated files to your web server:

cp -r priv/static/wasm/* /var/www/html/
cp -r priv/static/js/* /var/www/html/js/

Or use with a bundler like Webpack or Vite:

import { RaxolTerminal } from './raxol-terminal.js';

const terminal = new RaxolTerminal(80, 24);
await terminal.initialize('/wasm/raxol.wasm');