I just created a kotlin multiplatform library for ...
# javascript
s
I just created a kotlin multiplatform library for android, ios and Javascript which uses the Ktor client for all three. These are my dependencies for the javascript library
Copy code
// MPP - JS & common dependencies

    sourceSets["commonMain"].dependencies {
        implementation(kotlin("stdlib-common", Versions.KOTLIN))
        implementation(Deps.Ktor.COMMON_CORE)
        implementation(Deps.Ktor.COMMON_JSON)
        implementation(Deps.Coroutines.COMMON)
        implementation(Deps.MP_SETTINGS)
        implementation(Deps.Ktor.COMMON_SERIALIZER)
        implementation(Deps.Serialization.COMMON)
        implementation(Deps.Stately.COMMON)
        implementation(Deps.Stately.CONCURRENCY)
    }    

    sourceSets["jsMain"].dependencies {
        implementation((kotlin("stdlib-js", Versions.KOTLIN)))
        implementation(Deps.Ktor.JS_CORE)
        implementation(Deps.Ktor.JS_JSON)
        implementation(Deps.Coroutines.JS)
        implementation(Deps.Ktor.JS_SERIALIZER)
        implementation(Deps.Serialization.JS)
    }


// Front-End react app dependencies
    implementation(kotlin("stdlib-js"))

    //React, React DOM + Wrappers (chapter 3)
    implementation("org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70")
    implementation("org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70")
    implementation(npm("react", "16.13.1"))
    implementation(npm("react-dom", "16.13.1"))

    //Kotlin Styled (chapter 3)
    implementation("org.jetbrains:kotlin-styled:1.0.0-pre.94-kotlin-1.3.70")
    implementation(npm("styled-components"))
    implementation(npm("inline-style-prefixer"))

    //Video Player (chapter 7)
    implementation(npm("react-player"))

    //Share Buttons (chapter 7)
    implementation(npm("react-share"))

    // Shared Library: Nautilus
    implementation(project(":MarianaKit"))

    //Coroutines (chapter 8)
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.7")
When I import the javascript library into the Jetbrains starter React app, the dev distribution size 27MiB and the production distribution size is 1.5 MiB. Is anyone else having such large distribution sizes? Is this normal? Or am I doing something on my end to cause this?
r
This is the size one would expect. You are using a lot of large libraries (e.g. Ktor, Coroutines, Serialization).
t
ES6 will improve this situation. It will unlock optimization for webpack
Also you can update react wrappers and remove transitive npm dependencies
Also export logic update required
s
Thanks everyone. I’m not a javascript developer so I didn’t know what to expect. Will work on evaluating how I can improve this.
t
Votes required :)