Hi. When developing a Kotlin Multiplatform library...
# javascript
f
Hi. When developing a Kotlin Multiplatform library for browser usage using the new IR compiler (i.e.
js(IR) {...}
), what is the way to obtain all required files to publish the library on NPM, namely: • How is the libraries package.json created? • Is the kotlin standard library and kotlinx libraries (e.g. coroutines) bundled in the library or referenced from the created package.json?
b
#npm-publish should address most of this if not all
As for klib bundling part of the question, they're compiled down to js and included in your js lib bundle
f
Thanks. Isn't there a way to accomplish the goal without using the npm-publish plugin, i.e., just using the kotlin Multiplatform plugin?
b
Sure, you can do what npm publish does manually. i.e. collect all relevant files plus package.json into a folder and then run npm executable with appropriate args and flags via gradle's custom Exec task
You can either assume npm executable being present on the system path or use one that kmp plugin fetches
f
Thanks. Is the folder
<root>/build/js/packages/<project-name>
a good starting point? It already contains a
package.json
.
b
Not quite, that one has intermediate js output that's not yet suitable for publishing
I don't recall the correct dirs now, but you can just have a look at which directories the plugin collects and how it builds the package.json file
f
Will do. Thanks!