Archie
08/31/2023, 3:30 PMimplementation(npm(<name>, <version>)
to add in the library, but other than that I can’t seem to figure our how to properly access them. I’ve looked into the Kotlin/JS docs and looks like I need to write wrappers to access the imported libraries but I can’t seem to figure out how to start.
Anyone has links to tutorial I could look into? or any guidance would be very much appreciated.
Thanks in advance.Robert Jaros
08/31/2023, 3:34 PMRobert Jaros
08/31/2023, 3:36 PMArchie
08/31/2023, 3:45 PMimplementation(npm(…))
I will need to write either a NPM Package Object
or NPM Package File
to access them.. is that correct?Robert Jaros
08/31/2023, 4:02 PMArchie
08/31/2023, 5:20 PMJames Yox
08/31/2023, 5:51 PMdynamic
when creating your wrappers. This can let you get to calling your JS libs quickly.
You'll want to eventually write proper type definitions. You certainly can just write definitions for the specific functions or objects you need to reference though.
I was messing around with chart.js at one point and the wrapper I needed was as simple as
external val Chart: dynamic
Obviously this would be better if I had real type definitions but you can do this for testing purposes!James Yox
08/31/2023, 5:53 PMjson(...)
in KotlinJS to pass JS objects to functions, etc. Again, this isn't exactly something I would advise in production code but you can cobble together JS libs pretty fast if you are just prototyping.