Probably just my knowledge gap - but I won't be th...
# webassembly
d
Probably just my knowledge gap - but I won't be the only one: I encountered something very unexpected:
wasmBrowserRun
(Everything works great!) 🎉 blob smile ❤️ wasm Yay! Now let's distribute and host it...
wasmBrowserDistribution
(What? Everything is broken!) blob scream 💔 The naming of output files has changed from
mjs
to
js
and the
<projectname>.uninstantiated.mjs
file that was apparently used to bootstrap the App is completely missing (what is this?) This means important references in the static
index.html
and
load.mjs
files are now wrong... so my WASM App won't load at all. If this is a general web/webpack difference between Development and Production file layouts, then how should we handle the necessary changes to
index.html
and
load.mjs
between these two configurations?
image.png
@Oliver.O ☝️ You may be interested in this
I've read some things about
mjs
file and the difference to
js
, but they haven't explained to this lowly native developer why we're seeing alternate types generated for Dev vs. Production and how I'm supposed to deploy a WASM App.
Due diligence: This issue isn't addressed... • ...in WASM intro documentation • ...or the Getting started guide
Trying to load my
homepage.js
file instead of the old uninstantiated one yields
Copy code
Uncaught SyntaxError: The requested module './homepage.js' does not provide an export named 'instantiate'
I'm guessing the entry point for an 'already instantiated(?)' distribution binary is different, but what should it be?
I've tried
instantiate
,
main
,
start
,
startup
and (at Google Bard's suggestion)
__wasm_bindgen_instantiate
but none work.
o
Hey, cool, looks like you're about to become the distribution expert! 🚀😃 Given the experimental stage of Wasm I am not surprised that creating a distribution might be somewhere further down on the agenda of the Kotlin/Wasm team. Also, ESModule support in Kotlin/Js is quite new. I found a good overview on this and the differences between ESModules and CommonJs in this article.
.mjs
files are really just
.js
files meant to be ESModules. The file name doesn't matter, but being declared a module does. And the
export
statement in a module must match the
import
expectations on the consumer side. I'm stil a bit puzzled how Kotlin/Wasm distributes its stuff, but I guess we'll all be learning along the way.
d
Yes, maybe this is something of a loose end for now? I'll set up my CI to deploy the Dev build in the nav time. Do you know of any major disadvantages to doing that?
o
No, though I really don't know, as I'm running that stuff locally only.
d
It's only my toy homepage as well, just a small thrill to make some wasm 'live ' 🙂