bytebox - v1.0.0
    Preparing search index...

    Function load

    • Compiles and instantiates a TeaVM WebAssembly GC module.

      Call this at module scope. workerd permits WebAssembly compilation only during module evaluation; the same call inside a request handler throws CompileError: Wasm code generation disallowed by embedder. The whole path is synchronous on purpose, because the asynchronous forms are unavailable at module scope: a WebAssembly.compile promise never settles there, and WebAssembly.compileStreaming refuses outright as asynchronous I/O.

      TeaVM's runtime has the same constraint for a second reason. Its JavaScript interop builds @JSBody bodies with new Function, which workerd allows during module evaluation and answers with EvalError in a request.

      Parameters

      Returns ByteboxModule

      import * as runtime from './app.wasm-runtime.js';
      import bytes from './app.wasmbin';
      import { load } from 'bytebox/loader';

      const app = load({ runtime, bytes });

      export default {
      fetch() {
      app.call('main', []);
      app.drain();
      return new Response('ok');
      }
      };