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