Using libs outside of IntelliJ

Dear all,
is there any possibility to use the built multiplatform js file (build/distribution/FILE.js) in other IDE, for example, Visual Studio Code, to write JS and HTML in their natural environment?
It seems that VSC is not recognized Kolin functions.

Any suggestions?

Thanks

Kotlin creates a webpack-minified JS bundles, which could not be (in general) used further in development (it could be considered a binary). You can use a library mode in IR though to turn it on use

kotlin{
  js(IR){
    binaries.library()
  }
}

it will produce a library code alongside with TS typings that could be used as a general TS library.

Hello darksnake ,

Regarding your answer to my question, I have more questions.

See attachmentts



I have a very simple .kt class and I want to use it in VCS. I can not see, clearly, what happened in the productioLlibrary, but I can not see my function.

Do I need to do more?

Thanks

You need to annotate all exported functions with @JsExport annotation. Otherwise, they are cut with DCE.

I have still nothing annotated with @JsExport

The library mode is still experimental, but it worked fine when I used it. Try to make a clean build, ensure that you use IR compiler, not the LEGACY, and see outputs in productionLibrary directory. Since the option is still mostly undocumented, it is better to get some help in kotlin slack.

1 Like

I found a problem, and it is now OK with generating files.
I have three files (.js. d.ts, and package.json). Is it enough to import only .js in VSC or I have to to more?

Still, my own function is not recognized in HTML.

Thanks

Would You, please, share a working code?

This projects generates output library: visionforge/build.gradle.kts at dev · mipt-npm/visionforge · GitHub. You also need to remember that it is a JS library. It needs to be built by NodeJS/webpack to be used in application.

I don’t know if this helps at all, but your problems sounds a lot like a problem I had. You might want to read this thread. Then again, you might not, because it might be different.

Thanks for sharing thread. Problem is not the same or similar. But, somehow I resolved that issue.
The problems were how to call function from JS, I found a solution and now that part is ok.

But, now I have the another one. Generic classes, abstract classes will not convert to JS, or maybe will but I do not now how to use them.

So, my question is, how to make inheritance of some abstract classes exported from Kotlin to JS ?
This sounds very complicated because there isn’t exists some popUp suggestion like in IntelliJ. Pure JS and HTML and imported JS.