Skip to content

Edge WASM

Build linear-memory WebAssembly from Java or Kotlin with Elide: bundle sizes, host requirements, and which runtimes run the output.

On this page

A WebImage artifact with backend = "wasm-lm" compiles Java or Kotlin to WebAssembly for JavaScript hosts that compile WebAssembly at runtime. The module keeps its heap and garbage collector in linear memory, so the host needs no WasmGC support. Like the browser build, it starts through its JavaScript loader; it is not a WASI module or component, and it does not deploy to Cloudflare Workers.

Build

Prerequisites match the browser build: Binaryen’s wasm-as on PATH, and code that meets the Native Image requirements.

amends "elide:project.pkl"
import "elide:Jvm.pkl" as jvm
import "elide:NativeImage.pkl" as nativeImage

name = "hello-edge"

artifacts {
  ["app-jar"] = new jvm.Jar {
    sources { "main" }
  }
  ["edge"] = new nativeImage.WebImage {
    from { "app-jar" }
    name = "hello"
    entrypoint = "Hello"
    backend = "wasm-lm"
    runtime = "node"
  }
}
elide build
node .dev/artifacts/native-image/hello.js

Without a manifest:

elide javac -- -d classes Hello.java
elide native-image -- --tool:wasm-lm -cp classes -o hello Hello
PropertyEdge value
backend"wasm-lm".
runtime"node" for Node-compatible APIs; "generic" also detects browser APIs.
autoRuntrue (default) runs main when hello.js loads.

Output and size

FileDeployHello-world size
hello.jsYes: the loader.42 KB
hello.js.wasmYes: the module.2.1 MB (660 KB gzipped)
hello.js.watNo: text form, for inspection.38 MB
hello.js.mapOptional: emitted with sourceMap = true.

A linear-memory module is larger than the WasmGC build of the same program, which uses the host’s garbage collector.

Host requirements

RequirementReason
WebAssembly exception handling with exnrefThe module uses it.
Compiling WebAssembly from bytes at runtimeThe loader reads hello.js.wasm and compiles it on start.
Node fs or fetchThe loader reads the module through one of them.
HostRuns the bundle
Node.js 25+Yes: node hello.js.
BunYes: bun hello.js.
Cloudflare WorkersNo: Workers compile only modules bundled at deploy time and reject the loader’s runtime compile with Wasm code generation disallowed by embedder.
WASI hosts (Fastly Compute, Wasmtime)No: the module imports from its JavaScript loader, not WASI.

Was this page helpful?