is there a way to instantiate a kotlin-wasm-module...
# webassembly
b
is there a way to instantiate a kotlin-wasm-module from a web-worker ? it currently fails because of
Copy code
const isBrowser = !isNodeJs && !isStandaloneJsVM && (typeof window !== 'undefined');
in
...uninstantiated.mjs
. If I just set that to true it works, but I guess there's a reason for it ?
i
Well, the WamsJs STD lib uses some JS API from a browser or NodeJs. So you can mock this API before initialising the module to and it start working as in browser (or nodejs).
b
ok thank you!
i
If you dont use any specific API (i.e. uninitilized.mjs file have no JS code that Web-Worker does not support) you can just define
window
as
{}
as a simple workaround.
b
oh that's good as it wouldnt require modifications to uninstantiated.mjs. nice!
s
Looks like a bug with browser environment detection, filed a ticket: https://youtrack.jetbrains.com/issue/KT-68453/K-Wasm-Supported-JS-engine-not-detected-in-Web-Worker
👍 1