Does anyone have a working example of evaluating JavaScript via WASM?
(This is a spin-off from workers-and-pages-helpHow can I enable support for `eval()` in Workers?, which ultimately asks a different question and has become quite lengthy.)
I need to evaluate some JavaScript, but understand that
But I'm struggling to implement a working example of JS evaluation via WASM in Workers. I'm completely new to WASM and am focusing on packages that do the heavy lifting for you. Here's what I've tried, using quickjs-emscripten:
This throws no error but simply never gets into the callback.
I've also tried wasm-jseval, via:
But this errors - it seems the package seems to think I'm working in the browser, as the error pertains to it trying to access
So does anyone have a working cut-and-paste version of evaluating JS via a package like this I could use?
I'd be most grateful!
I need to evaluate some JavaScript, but understand that
eval() / new Function() is blocked on workers. I understand my only route to evalulation is via WASM.But I'm struggling to implement a working example of JS evaluation via WASM in Workers. I'm completely new to WASM and am focusing on packages that do the heavy lifting for you. Here's what I've tried, using quickjs-emscripten:
This throws no error but simply never gets into the callback.
I've also tried wasm-jseval, via:
But this errors - it seems the package seems to think I'm working in the browser, as the error pertains to it trying to access
location.href.So does anyone have a working cut-and-paste version of evaluating JS via a package like this I could use?
I'd be most grateful!