zachmz35
CDCloudflare Developers
•Created by zachmz35 on 10/13/2024 in #workers-help
Preloading Emscripten-generated JS module in a Worker
I'm having issues preloading a JS/WASM library in a CF Worker - the JS library starts as C++ and then gets transpiled to JS with Emscripten and CMake. I'm transpiling with ES6_SYNTAX and MODULARIZED enabled.
I include this JS/WASM library
sparks.js
into the Cloudflare Worker project which I called hello-wrangler
.
Below is my index.ts
in the hello-wrangler
project. I do the imports and then I call loadModule()
in a useEffect
in hopes to have the module load proactively.
It should be available for any route or action.
I'm trying to setup an action on localhost:8787/
to print out the module instance, libptr
.
I always end up with the null condition, return c.text("No libptr");
One thing I already tried to do is to add await loadModule()
which did not succeed (instead got 500 error). Thanks.2 replies