You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AOT: instantiate .wasm ES module imports (import * as wasm from './x.wasm') and expose its exports #5234
Context: real apps import compiled WebAssembly as ESM modules (wasm-bindgen "bundler"/"web" target). e.g. opencode pulls @silvia-odwyer/photon-node, whose photon_rs_bg.js does import * as wasm from "./photon_rs_bg.wasm" and calls wasm.someExport(...). The import is expected to yield the instantiated module's named exports.
Goal
Support import * as wasm from "./x.wasm" (and named/default forms) by instantiating the WebAssembly module at module-init and exposing its exports as the module's named exports, wired to the importing JS glue's imports object (wasm-bindgen creates a circular glue↔wasm import relationship). perry already has a runtime WASM host — crates/perry-runtime/src/webassembly.rs (WebAssembly.instantiate(bytes) works via perry_wasm_host_*) — to build on.
Self-contained repro
Minimal module exporting add(i32,i32)->i32. Create add.wasm from this base64, then main.ts:
Node (with a wasm-ESM loader) and bundlers print 5. perry today fails earlier — see # (it currently can't even read the .wasm); after deferral it would throw-on-use. This issue is the real integration that makes wasm.add(2,3) return 5.
Scope notes
Instantiation at module-init; named exports surfaced (functions, and memory/global/table as appropriate).
The wasm imports object: for a bare .wasm with no imports (like the repro) it's empty; for wasm-bindgen, the glue provides imports — handle the circular case (glue imports wasm exports; wasm imports glue functions).
Companion to the cheaper deferral (#), which keeps the build moving until this lands.
Activity
feat(compile): defer `.wasm` ESM imports to throw-on-call stubs (#5235)…
proggeramlug commentedon Aug 17, 2026
I verified this still reproduces on current main and found no assignee, active branch/worktree, or PR implementing it. I am working on a fix now.