How to build an NPM module with package.json from the Kotlin/JS Gradle Plugin?

Old post

I wrote a multi-platform project that works like a breeze in Android, JVM and Native. I’d like to build it as a JS library that is usable into a JS project. Unfortunately I have very little experience with the JS ecosystem so I never know if what the problem I’m facing is JS-related or not.

I’d like to export the compiled version in a single file with the package.json needed to import all it’s dependencies at compile-time for both Nodejs and browser (maybe 2 different builds?). If that is not the correct way of exporting a library, please show me how.

Is there any guide out there that I missed from Google?

I made some research and come to the conclusion that I just need to choose the right compilation type (and, umd or commons) and a package.json!

I noticed that the new Kotlin/JS plugin actually builds a package.json somewhere in the root project build directory.

Which task generates it and how I retrieve it without brutally copying it at the end of the build?

Using Gradle MPP/JS plugin version 1.3.50