2

I currently have a problem with the file size of kotlin js. I have one multiplatform lib which has around 160Kb and integrate it in the kotlin js project. The kotlin js project itself does not have that much code. After assembling (which should enable also DCE for shrinking) the Js file size is up to 2.5MB. I really don't know why it bloats up like that. I hope anybody has a clue. Following is my gradle.config, maybe I forgot something to add.

Short update: We found out when serving the file of 2.5MB from CDN githack. The file is optimized to 500KB. How is that even possible. Does that mean that the actual DCE of kotlin isn't working at all?

plugins {
  kotlin("js") version "1.4.10"
}

group = "me.at"
version = "1.0-SNAPSHOT"

repositories {
  mavenLocal()
  mavenCentral()
  jcenter()
  maven {
    url = uri("https://dl.bintray.com/kotlin/kotlinx")
  }
  maven {
    url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
  }
  maven {
    url = uri("https://dl.bintray.com/ekito/koin")
  }
}
dependencies {
  implementation(kotlin("stdlib-js"))

  implementation("org.jetbrains:kotlin-styled:1.0.0-pre.110-kotlin-1.4.10")
  implementation(npm("styled-components", "~5.1.1"))
  implementation(npm("inline-style-prefixer", "~6.0.0"))
  implementation("com.mp.multi:multi:1.1")
  implementation("org.koin:koin-core:3.0.0-alpha-4")
  implementation(npm("html-webpack-plugin", "3.2.0"))
}

kotlin {
  js {
    browser {
        binaries.executable()
        webpackTask {
            cssSupport.enabled = true
        }
        runTask {
            cssSupport.enabled = true
        }
        testTask {
            useKarma {
                useChromeHeadless()
                webpackConfig.cssSupport.enabled = true
            }
        }
    }
}
}
coffeLord
  • 85
  • 1
  • 12

0 Answers0