How can I keep the comments when building a Kotlin/JS library?

Hello everyone,

I am writing a wrapper for reduxjs, but when I build the project, all the comments go away. It would be nice to keep the comments in the .kjsm file.

Could someone tell me how to do that or if it isn’t possible?

Here is a link to the project https://github.com/srmico/kotlin-redux-js

Thanks!

@srmico Just to be clear, are you talking about the IDE experience? I.e. how your library code looks like when a user performs “navigate to code”? Or is it about the resulting .js file?

I would like to have the comments in the compiled js code, so that if I “navigate to code” I can see the documentation of the function, class or module.

In this particular case, since it is a wrapper library that will only be used from Kotlin projects, “navigate to code” brings me to the .kjsm file, so the comments should be there.

AFAIK at the moment the only solution is to distribute the source code alongside with the library. If IDEA knew the source file locations it would navigate to those instead of decompiling the kjsm files.

In case of gradle there is a standard way and kotlin plugin should detect sources automatically.

In case of NPM there is no standard way of distributing the sources. For example, if you are using create-kotlin-react-app the sources are not downloaded unfortunately. You could configure a custom sources location in IDEA, but that’s not super convenient.

We are aware there should be a way to distribute documentation without open sourcing the code. Unfortunately there is no working solution at the moment (AFAIK).