The biggest problem today for Kotlin/JS is tooling...
# javascript
g
The biggest problem today for Kotlin/JS is tooling. Using ktor-js client, with really basic usage (GET, POST, …) and AFTER Kotlin DCE, I end with: kotlinx-coroutines-core.js : 362 Ko kotlinx-coroutines-io.js: 157 Ko kotlinx-io.js: 223 Ko kotlinx-serialization-kotlinx-serialization-runtime.js: 271 Ko ktor-ktor-client-core.js: 292 Ko ktor-ktor-http-cio.js 43 Ko ktor-ktor-http.js: 168 Ko ktor-ktor-utils.js: 80 Ko Waaaay too much to be able to do this call:
Copy code
val response = <http://client.post|client.post><HttpResponse>("/account/profile") {
						val jsonData = Json(JsonConfiguration.Stable).stringify(
							ProfileFormState.serializer(),
							store.state
						)
						body = jsonData
					}
☝️ 1
💯 1
r
You probably mean the second biggest after the level of documentation 😛
☝️ 1
g
😅
I know the team is working on so many parts, but still, it’s frustrating.
a
Webpack bundler is making a single bundle from all of it. Have you run it?
g
Yes, I also use webpack. But it doesn’t remove code. With the uglify plugin you gain a little bit of bandwidth but you still have unused code parsed by the browser. axios library is around 43Ko in clear code and 13Ko minified. Here, the import of ktor-http cost me more than 1Mo. Twenty five times more. It makes no sense and Kotlin/JS will never be accepted as a viable solution until this issue is fixed.
f
Dead code elimination tools can prove to be very limited, because one thing happens to eventually reference everything. For example if you use proguard with kotlin-reflect you get the full huge jar if you use one method.
g
For Kotlin Js DCE tools, the main problem is that it operates on an JS AST. The reachability of nodes is probably more difficult to estimate. At the end a lot of unused nodes is kept. Doing this analysis inside kotlin’s AST should provide a much more accurate analysis and better results.
I did some more tests on a new project with one single
println("Hello world")
line. 😭 Please vote for https://youtrack.jetbrains.com/issue/KT-21750#focus=streamItem-27-3754361.0-0
10