This example builds one command-surface wasm artifact and loads that exact file in both environments:
- browser harness:
browser-demo.html - WasmEdge harness:
wasmedge-demo.mjs
The source artifact definition lives in:
The build step writes the shared artifact to:
examples/isomorphic-loader/generated/dist/isomorphic/module.wasm
Run from the repo root:
node ./examples/isomorphic-loader/build-demo.mjsThat compiles runtimeTargets: ["browser", "wasmedge"], which now defaults to
the shared single-thread artifact profile rather than the WasmEdge pthread
profile.
Start a static file server from the repo root after the build step:
python3 -m http.server 4173Then open:
http://127.0.0.1:4173/examples/isomorphic-loader/browser-demo.html
The browser demo uses:
loadModule(...)fromsrc/host/isomorphicLoader.js- browser edge shims from
src/host/browserEdgeShims.js - browser host adapter from
src/host/browserHost.js
Install the wasmedge CLI and run:
node ./examples/isomorphic-loader/wasmedge-demo.mjsThat script uses the same generated/dist/isomorphic/module.wasm artifact the browser
page loads. loadModule(...) detects that the artifact is a standalone
command-surface module and drives WasmEdge through raw stdin/stdout command
execution rather than the runner protocol.
To run the live same-artifact browser/WasmEdge parity test:
SPACE_DATA_MODULE_SDK_ENABLE_WASMEDGE_PARITY=1 node --test ./test/browser-harness.test.js