The JavaScript snippet from the README did not work for me. The following code successfully instantiated and executed the generated module:
import fs from 'fs';
const bytes = fs.readFileSync('add.wasm');
const { instance } = await WebAssembly.instantiate(
bytes,
{
Math: { pow: Math.pow }
}
);
console.log(instance.exports.add(5, 3));
The Math: { pow: Math.pow } import appears to be required. Without it, the example did not work in my setup.
The Julia code from the README worked unchanged:
using WasmTarget
function add(a::Int32, b::Int32)::Int32
return a + b
end
wasm_bytes = compile(add, (Int32, Int32))
write("add.wasm", wasm_bytes)
Environment
OS: Linux (x86_64-linux-gnu)
Julia: 1.12.6
WasmTarget.jl: v0.3.15
Node.js: v26.3.1
I don't have any prior experience with either this package or WebAssembly, so I may be missing something. I'm simply reporting what I observed while following the README example and sharing the changes that made it work on my system.
The JavaScript snippet from the README did not work for me. The following code successfully instantiated and executed the generated module:
The
Math: { pow: Math.pow }import appears to be required. Without it, the example did not work in my setup.The Julia code from the README worked unchanged:
Environment
I don't have any prior experience with either this package or WebAssembly, so I may be missing something. I'm simply reporting what I observed while following the README example and sharing the changes that made it work on my system.