Hi all! I've been doing some research into Kotlin/...
# javascript
k
Hi all! I've been doing some research into Kotlin/JS use in production and am looking for any good info on JS output size. I know this is a "it depends" kind of question, but if anybody has links to posts or discussions on the topic, that would be much appreciated. (I can trade for good info on Kotlin-iOS binary size 🙂 )
👀 2
t
It depends on: • Compiler type (Legacy or IR) • Valid DCE configuration (for Legacy) • Kotlin libraries JS adoption • Declarations quality (if you use declarations) • Your programming style In future: • NPM dependencies format
k
Compiler, IR. Libraries, that's kind of a "it depends" situation. I'm aware Ktor adds quite a bit, so we'd probably abstract the network layer in the shared code to avoid that. I guess what I'm really looking for is how people measure it accurately? I'm concerned that just looking at the js on disk is missing optimizations, and will give me the wrong impression. Debug vs release, dead code elimination (if any), etc. In the native/iOS world, you can't just look at binary on disk. There's a non-trivial process to get a real-world number. I'm wondering if there's kind of the same here. I assume I'll probably have to just dig in and learn that the hard way, but was hoping somebody had a blog post 🤞
b
Js is much simpler, since the generated production file is exactly what's sent over the network. Common practice to further optimuize that is to gzip it before sending or serving it
k
No webpack, tree shaking optimizations?
ORG_GRADLE_PROJECT_isProduction=true
? Just want to make sure I'm not missing anything that's going to have a significant impact.
t
Webpack tree shaking locked with: 1. Missed ES6/ES modules 2. Missed root export
For simple GET/POST requests
fetch
prefferred in Kotlin/JS
👍 2
IR DCE doesn’t work for my projects now
k
Ah, this is great. Thanks!
t
Do you use
react
?
k
We will (probably) use react, but not from Kotlin. The idea is to have the UI talk to a shared lib that comes from Kotlin/KMP
t
For React Query
fetch
also more comfortable Kotlin wrappers already exist (if will be required)