Hi! Can I compile kotlin into a single wasm file f...
# webassembly
d
Hi! Can I compile kotlin into a single wasm file for the browser (and/or nodejs) without using, nodejs, npm and webpack? I'm really annoyed with npm install, setup node and other redundant scripts. My web project is set up separately and uses Yarn PnP, I also don't plan on importing js into kotlin wasm, so I'd like to know how I can do the most simplified build option possible to get just one single wasm file and maybe js bindings. I would be very grateful if you could help me solve this problem or if you could tell me why it cannot be solved.
s
Hi! You can use
compileProductionExecutableKotlinWasm
or
compileDevelopmentExecutableKotlinWasm
gradle tasks and then use build artefacts from
<rootProject>/build/js/packages/<project-name>
d
Thank you, that sounds like what I need. How can I output these files to the specified directory? Also, how do I generate typescript (.d.ts)?
s
Our Gradle plugin is a little bit inflexible in this area. I would recommend copying files to desired directory. Gradle has
Copy
or
Sync
task types for this. K/Wasm doesn’t produce .d.ts files yet.