kpgalligan
11/05/2018, 9:31 PMankushg
11/05/2018, 9:51 PMkpgalligan
11/05/2018, 10:03 PMankushg
11/05/2018, 11:22 PMJson
objects instead of real instances of classes, you end up having to do stuff like wrap your external methods with facades that basically just transform your `data class`es to/from Json
objects.
Another thing that's tricky/annoying with Kotlin/JS is that most of the JS-specific tooling that Jetbrains is investing in is focused on building full-on apps, rather than libraries written in Kotlin/JS and designed to be consumed from real JS. Kotlin spits out ES 5.1 modules, and not the newer ES2015 modules. ES2015 modules support webpack's tree-shaking, which is pretty much the standard dead-code elimination technique in the web world. If you want to keep your JS bundle size small (which anyone using Kotlin/JS in production does) you basically are stuck with Kotlin/JS's Dead Code Elimination instead of being able to use more industry-standard tooling.
Kotlin's DCE tool is pretty decent at picking out what things are used and what things are unused for webapps. With libraries written in Kotlin and distributed as JS though, it gets a bit more annoying. You have to manually specify what methods you want it to keep (and not mangle the names of), and the process for doing so is clunky, even compared to Proguard on Android.
Additionally, since you're stuck using Kotlin's DCE instead of more standard JS DCE tools, it complicates distributing these libraries internally via NPM. We basically have to DCE the Kotlin/JS Standard Lib against our codebase and redistribute it internally, instead of being able to pull the real, official, un-DCEd library from NPM.
Finally, the last real issue we've had is that we currently use Flow (https://flow.org/) for static type-checking in JS, and Kotlin/JS is completely agnostic of both Flow and Typescript. This means that folks working on libraries designed to be consumed from more modern JS projects basically have to handwrite these definitions themselves.
That being said, all of these problems are things we've been able to work around... it's just not ideal and I haven't seen much public commentary from Jetbrains on this use case.kpgalligan
11/05/2018, 11:28 PMankushg
11/06/2018, 3:16 AMcoletz
11/06/2018, 10:26 AMkpgalligan
11/06/2018, 12:53 PMcoletz
11/06/2018, 1:22 PM