hey guys i have a few questions about how kotlin J...
# javascript
w
hey guys i have a few questions about how kotlin JS handles npm dependencies so for context: i am helping a friend set up a project in the kotlin JS target and we have run into a few issues, namely they require a library called mathjs, primarily for LU Decomposition (with or without partial pivoting) now, according to the docs, adding
@JsModule("mathjs")
and
@JsNonModule
was the best way to solve npm packages on the kotlin side (according to the docs https://kotlinlang.org/docs/using-packages-from-npm.html) however this didnt work and to quote my friend: "i had literally no idea if the npm install worked like there was just no feedback on it because no gradle errors but like there wasn't any positive confirmation so while everything wasn't working i wasn't even sure if the dependency worked" and "just what the sample tells me to do but it straight up didnt work and the only error was "lusolve is not a function" like it just was completely useless and there' s no error on compilation either it's just a runtime error" they ended up finding out a solution to fix the problem (linked in the pictures below) and it was an abstract external class marked with
@JsModule
and a companion object storing all of the needed functions i have two questions: i understand that kotlin JS is a relatively new target and doesnt get as much love as JVM or even native from wat ive seen, but y is documentation so poor on this? (is this something that should be brought up in #docs-revamped or is it already a known problem?) i also understand that the JS / npm / node ecosystem is very large and was wondering if these "hacks" will be the norm of doing things moving forward or if there are plans to make them better side note: sorry for the language in these pictures, it was late at night and they had spent a lot of time trying to figure this out
my case may be a bit confusing as i am just the messenger, if anything about this is confusing, i am sorry and i will try to clear it up
r
From my experience it's just something we have to live with (at least for now) 😉 There are different ways to use npm dependencies, because as I understand there are different things that can be exported from JS module (functions, objects). I just do some trials and errors every time I need to use new dependency.
w
ah makes sense, thanks!