For future reference, here are the thing that I ke...
# compose-web
a
For future reference, here are the thing that I keep messing up when setting up a new Compose Web app and wasting too much time (js target. not wasm): 1. not setting the right
moduleName
and
outputFileName
on the kotlin target in
build.gradle.kts
2. Using
CanvasBasedWindow()
but forgetting to include a
<canvas>
with id=
ComposeTarget
in index.html. 3. Not placing
<canvas>
BEFORE
<script type="application/javascript" src="composeApp.js">
4. Forgetting to include
skiko.js
I really wish we get proper error messages soon because right now all is trial and error without feedback
❤️ 6
☝️ 2
💯 2
g
Btw, KMP wizard is solving all these issues. Although, it would be nice to have a "kmp doctor" to check if the setup is correct
a
no it doesn't. kmp wizard creates wasm targets, not js
g
Oh, yes, my fault. I forgot that I've generated wasm target and then converted it to js.
o
Until something else serves you better, instead of trial and error you can copy-paste from here: https://github.com/OliverO2/compose-counting-grid
m
Can someone ELI5 what is the difference between js and wasm targets when using compose for web?
g
If I understand it right, then it is the output. They should produce different "binaries".
m
is there an advantage using one vs another?
g
I had have an impression that wasm should "fix the issues of js", so it should be "faster" and more compact (don't know for sure, check yourself). However, Safari is not supporting wasm and there's no estimates when it will.
m
Oh I thought safari does support wasm as per this
🤔 1
g
Wasn't working for me couple of months ago
a
@Mantas Varnagiris ELI5: wasm & js are both possible kotlin targets. one uses wasm the other uses javascript to render the composables in the DOM wasm's performance is much better than js and I think it produces smaller apps too safari does support wasm (the tech) but it doesn't support wasm gc, which is needed by compose web's wasm target. so the difference between the two targets is: performance (wasm) over compatibility (js)
👍 3
m
Oh I see thank you
👌 1