In case anyone is interested, here's how I removed...
# javascript
c
In case anyone is interested, here's how I removed ~600kB from my JS file using the Google Closure Compiler: https://stackoverflow.com/questions/68831061/how-to-use-the-google-closure-compiler-to-optimize-kotlin-js/68831062#68831062
🆒 3
👌 1
r
Interesting, is this on legacy or ir js output? Is there a full example somewhere of your configuration?
e
can't run the wrapper scripts npm generates rather than the node binary directly? eg node_modules/.bin
c
@rnentjes I'm using IR, but since it works on the final JS file, the setup should be exactly the same. Here are the full changes I did on my project to integrate it: https://gitlab.com/arcachon-ville/formulaide/-/merge_requests/80
🙏 3
@ephemient Not sure what you're talking about. Don't hesitate to comment/answer on the SO post if you have a better version
r
Fyi, in my project the size goes from 728kb to 716kb, so that hardly seems worth the effort (this is with ir on 1.5.30-M1). I am wondering where the difference comes from, probably from not using react.
r
I think it could be Ktor client, which adds lots of unused code.
I've tried closure compiler a few months ago and the output was even bigger than standard minification.
I would be interested in using ADVANCED mode, but it didn't work for me either.
c
ADVANCED removed almost 1MB for me, but the code also doesn't run anymore.
A friend who's using Rollup with normal JS (not Kotlin) also told me the Closure compiler increased the size.
I guess it's not that common that it actually helps. I'm glad it does in my case though, 2.1MB was a bit much
n
ADVANCED failed to build for me, but SIMPLE shrunk my app from 2.1MB to 912KB, so big win!
I also use Ktor client - not sure if that’s the culprit, just sharing
e
@CLOVIS this is what I meant.
Copy code
val kotlinNodeJs = rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>()
File(kotlinNodeJs.projectPackagesDir, "node_modules/.bin/google-closure-compiler") // launcher for node entry point defined by google-closure-compiler package.json