// Regression: a bundle can name a module of bridge imports only its app has. // // The stdlib host answers what the framework knows - DOM, IDB, WS, SW, storage, // timers, subtle - and a real application always needs more: a store worker's // message loop, an extension's storage, a protocol shim. Those entries cannot // be passed from the page to the Worker (a function is not structured // cloneable), so the Worker imports a module the page names when it loads the // bundle: `load('./app.wasm', { appBridge: './app-bridge.mjs' })`. // // This fixture imports a symbol the host does NOT provide. It instantiates only // if the app bridge arrived, and prints what the bridge computed, so the proof // is the value crossing three layers (wasm import -> bridge module -> wasm). // // It lives in tests/wasm/fixtures/ rather than the regression directory because // it has no native build: a wasm import has nothing to resolve against off // target. tests/wasm/emit_check.sh builds it for wasm and runs it with a bridge. package main //:wasmimport bridge app_bridge_probe func wasmProbe(n int32) (r int32) func main() { // Termination: a batch program must still be stoppable, so the entry // handles the channel the runtime closes on SIGINT/SIGTERM. select { case <-shutdown: return default: } println("probe:", wasmProbe(41)) }