hey guys! implementing a POC with
hey guys! implementing a POC with
workerd
by consuming a WASM file. I'm missing how to tell my .mjs
entrypoint to basically proxy the request to the WASM binary (proxy request from one module to the other). Why? you may ask. Because this WASM binary is a Go webserver so it knows how to handle them. Can someone point me out in the right direction?
I'll leave the files contents in a thread6 Replies
config file
and the
entrypoint.mjs
content
the app.wasm
is a Go webserver compiled with tinygo
GitHub
workerd/src/workerd/server/workerd.capnp at main · cloudflare/workerd
The JavaScript / Wasm runtime that powers Cloudflare Workers - cloudflare/workerd
Hey! 👋 In your
entrypoint.mjs
module...
app
here is an instance of WebAssembly.Module
: https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/ModuleMDN Web Docs
WebAssembly.Module - WebAssembly | MDN
A WebAssembly.Module object contains stateless WebAssembly code that has already been compiled by the browser — this can be efficiently shared with Workers, and instantiated multiple times.
thank you very much Mr!!
creator of
miniflare
wow, a validated voice to answer ahha
hey. I've been looking for 2 days on the internet but I don't seem to find information to unblock myself from this step. Maybe you know it and can point me in the right direction (again)?
this is the current entrypoint.mjs
I've created the WASM binary using this command
I don't know if this is important but sharing
(I've extensively check the MDN docs, I couldn't get unblocked)
the console log at line 2 outputs this
so I would expect that it doesn't error out when instanciating it, but it does..
also the console log at line 3 outputs this
I would expect this to have at least one value being exposed but it doesn't. Normal?Looking at the documentation here (https://tinygo.org/docs/guides/webassembly/wasm/#how-it-works), I think you'll need to import and construct a
Go
instance from the wasm_exec.js
file, then pass this to your WebAssembly.Instance
:
Using WASM
How to call WebAssembly from JavaScript in a browser.