Hi, I followed the tutorial from:
Kotlin/JS React Official Tutorial
And set up my project by example. After including a few libraries like tailwind and our company’s components react library, the size of the bundle after `gradle build’ grew to almost 30 MB.
File size with React + React-dom + Styled components, etc. - 600 KB
File size with the setup + Component library that I use one Component from - 5.4 MB
File size with the setup + Component library + styles - 26 MB
It seemed to me that I did something wrong, so I stepped back, downloaded the repo with the example from the tutorial Kotlin/JS React Official Turorial Github.
When I run gradle build
there, the size of the bundle - 654 KB.
So, I have a few questions:
- is 600 KB typical size for a new project and if so, why is it so big?
- it seems that DCE doesn’t really work if a new component library that I pick up 1 component from occupies 5 MB. Have you experienced something like that and what are the pitfalls?
- how do you manage minimizing css (le.g. purgecss), and have you accomplished to minimize some big css to a reasonable size?
This is how I use the Component Library
@file:JsModule("@company/company-ui")
@file:JsNonModule
import react.*
@JsName("Button")
external val companyButton: RClass<ButtonProps>
external interface ButtonProps : RProps {
var scheme: String
}
and this is how I use the component and the tailwind styles
import react.*
import react.dom.*
import kotlinext.js.require
@JsExport
class App : RComponent<RProps, RState>() {
init {
require("tailwindcss/tailwind.css")
}
override fun RBuilder.render() {
companyButton {
attrs.scheme = "primary"
+"button"
}
}
}