mix compile.exclosured (exclosured v0.1.4)

Copy Markdown

Mix compiler that builds Rust crates into WebAssembly.

Add :exclosured to your project's compilers list:

def project do
  [
    compilers: [:exclosured] ++ Mix.compilers(),
    ...
  ]
end

Configuration

config :exclosured,
  source_dir: "native/wasm",        # where Cargo.toml crates live
  output_dir: "priv/static/wasm",   # where .wasm + .js output goes
  optimize: :none,                  # :none | :size | :speed (wasm-opt)
  modules: [
    my_mod: [],
    heavy_compute: [features: ["simd"]],
    sqlite: [
      no_default_features: true,
      features: ["bundled"],
      env: [CC_wasm32_unknown_unknown: "/usr/bin/clang"],
      cargo_args: ["--locked"]
    ]
  ]

Module Options

Each module accepts the following options:

  • features - List of cargo features to enable (passed as --features a,b,c)
  • no_default_features - If true, passes --no-default-features to cargo
  • env - Keyword list of environment variables for the cargo build (e.g., [CC_wasm32_unknown_unknown: "/usr/bin/clang"])
  • cargo_args - List of extra arguments forwarded directly to cargo build (e.g., ["--locked", "--offline"])
  • lib - If true, marks this as a library crate (not compiled standalone)
  • canvas - If true, enables canvas integration
  • subscribe - List of event subscriptions