Kotlin/JS 1.4, how to output a NPM package?

Say you have a simple project with just the Kotlin standard library and one dependency from NPM. What would be a good pattern to output an NPM package? Also which tasks of the Kotlin/JS plugin (or Kotlin/MPP with js()) are key to do so?

There are no such tasks in Gradle plugin yet, but we plan to add it in future. You can setup it on your own. We can task :publicPackageJson for generate package.json which can be used for publishing into NPM registry.

If you use legacy compiler, you have 2 options. You can publish compilation output js file (:compileKotlinJs). In this case you need to add all Kotlin/JS modules as dependencies to your package.json. But in fact there can be situation when some of your dependencies will not be in NPM registry. In this case you get error on npm install if your package.
So there is alternative variant, you can use webpacked version of your module. In this case you get one big bundle js file which can be used as a library. But in this case you get all NPM dependencies bundled as well, you can use configuration via webpack.config.d and Webpack externals

If you use IR compiler, you can use output of compilation, because it compile one javascript file from all Kotlin/JS modules, and using :publicPackageJson you can get valid package.json with all external npm dependencies