06/03/2020, 10:15 PM
I'm trying out Kotlin Multiplatform for the first time, i've used the IntelliJ New Module to create a JVM/JS project What is the correct way to add a new npm dependency that does have TypeScript support should i just add it in the jsMain in build.gradle
Copy code
jsMain {
            dependencies {
                implementation kotlin('stdlib-js')
                implementation npm('lit-html', '1.2.1')
or should i rather do
Copy code
mkdir lit-html-kt
cd lit-html-kt
npm init -y || exit
sudo npm install -g dukat || exit
npm install lit-html || exit
dukat node_modules/lit-html/lit-html.d.ts || exit

rm -rf ./*.json || exit
rm -rf ./node_modules || exit
which then generates kotlin files for this npm package ?


06/04/2020, 6:22 AM
If you just add the npm dependency, you won't be able to use it from Kotlin. In addition to declaring it in Gradle, you need Kotlin external declarations for it to work. These declarations can be manually generated using Dukat via CLI as you pointed out, which then requires you to put the output files as sources in your project. If these declarations don't need manual intervention, you can automate the process by making Gradle use Dukat for you. For this, you simply need to enable the Gradle property
👍 1


06/04/2020, 6:28 AM
that makes sense, thanks for this info!