You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use quickjs-emscripten inside a Service Worker that is written as an ECMAScript module (ESM).
However, it fails to execute due to the use of dynamic import() inside the library.
// worker.jsimport{getQuickJS}from'https://esm.sh/[email protected]';asyncfunctionmain(){constQuickJS=awaitgetQuickJS()constvm=QuickJS.newContext()constworld=vm.newString("world")vm.setProp(vm.global,"NAME",world)world.dispose()constresult=vm.evalCode(`"Hello " + NAME + "!"`)if(result.error){console.log("Execution failed:",vm.dump(result.error))result.error.dispose()}else{console.log("Success:",vm.dump(result.value))result.value.dispose()}vm.dispose();}main();
<!-- index.html --><!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Quick.js Example in Service Worker</title></head><body><script>navigator.serviceWorker.register("/worker.js",{scope: "/",type: "module"});</script></body></html>
The text was updated successfully, but these errors were encountered:
I'm trying to use quickjs-emscripten inside a Service Worker that is written as an ECMAScript module (ESM).
However, it fails to execute due to the use of dynamic import() inside the library.
Since dynamic imports are not allowed in Service Workers, is there any workaround to make quickjs-emscripten work in this environment?
example:
The text was updated successfully, but these errors were encountered: