What is the status on using multiplatform to publi...
# multiplatform
e
What is the status on using multiplatform to publish npm modules? I read https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#publishing-a-multiplatform-library, but that didn't make me any wiser. I've read https://medium.com/swlh/kotlin-to-jar-and-npm-87a5b0ca2dff, which has a solution, but that feels like a bit of a hack. Also, publishing maven artifacts with Javadoc seems to have become easier since that was written.
s
I have the same issue. Any feedback or samples would be a massive help
e
It sort of works out of the box in
1.3.61
, except that you have to unzip the jar and publish to a npm registry manually. I also haven't found a better way to override the namespace the package is imported into, so you still have to do something like the
package.json
+
index.js
"hack" described in that article to "unwrap" your package (unless you're fine with your consumers having to do that), but at least you don't have to explicitly require
kotlin
anymore, since the generated module does that for you.
s
This is exactly the type of thing I wanted to hear. I've got as far as generating a jar. That's where my confusion started. But thank you for clearing it up for me. I'll give it a go today and hopefully get a "hello world" string shared on all three platforms
e
Good luck! Hopefully things will get even better in 1.4, when type definitions are supposed to be generated as well.
🎉 1
s
Sorted!
👍 1
g
Isn’t it better to run
jsBrowserWebpack
, copy the js file into a folder, create a package.json then zip them together to have an npm module?
e
I'm not sure if that was an option when we were doing this, but I moved onto webpack a while back, and it works like a charm.
I haven't merged it into my master branch yet though.
s
Yep, it didnt exist last month
👍 1