Is there a way to split in chunks the generated js...
# javascript
w
Is there a way to split in chunks the generated js file? I've this config
Copy code
js("js", IR) {
        browser()
        binaries.executable()
        useCommonJs()
    }
and I'm using compileProductionExecutableKotlinJs to create the .js and d.ts that I copy to a typescript react project, but the js is super large (near 4mb)
t
Do you use
js
from
build/distributions
?
w
no, from build/compileSync/main/productionExecutable/kotlin/
t
It’s non-optimized
js
and you can use optimized with excluded examples (
react
for example)
w
the js in build/distribution is still 2mb.. I will check if it works but isn't there a way to remove unused code?
looking at the chrom dev tools I have 85% of unused code from that
t
Legacy or IR?
w
IR with
Copy code
browser()
binaries.executable()
useCommonJs()
t
w
i'll try, thanks!
t
the js in build/distribution is still 2mb.
Do you exclude
react
and related libs from dist?
w
I don't have npms in the jsMain dependencies
Copy code
sourceSets["jsMain"].dependencies {
    implementation(Deps.Ktor.js)
    implementation(Deps.Ktor.jsCore)
    implementation(Deps.Ktor.jsJson)
    implementation(Deps.Ktor.jsLogging)
    implementation(Deps.Ktor.jsSerialization)
    implementation(Deps.Coroutines.js)
    implementation(kotlin("stdlib-js"))
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.5")
}
only this
t
FYI - Ktor update = -1MB approximately
w
ouch! many thanks 😄
t
I don’t have npms in the jsMain dependencies
But Ktor has 😈
w
🙃
137 Views