Create a library that compiles to NPM and Jar with Kotlin Multiplatform

Alon Kashtan
Jul 4, 2019 · 8 min read

A tutorial of building a Kotlin project that compiles to an NPM package (for both NodeJS and browser) and a JVM Jar

Recently I started to write a simple library for unit conversion¹ for our organization. This brought up an interesting dilemma: we are using both Java and Javascript, and it is important that the conversion will be the same in all places. Writing two libraries and making sure they are functioning the same seemed not very maintainable even for such a small project.
But then I remembered: Kotlin