android-studiointellij-ideakotlin-multiplatformkotlin-js

How do I add a JS target to a KMM project?


I have an AndrodiStudio KMM project and I'd like to add a JS target.

Given that JS development is only available in IntelliJ, I'd expect that I have to open the project in IDEA add a "Module" -- but I don't even know which one to choose -- none of them seem to be a "right" fit:

So my question is:

The current structure of my code corresponds 1:1 to the KMM project template in Android Studio: https://github.com/stefanhaustein/komponents

*) The error message:

Error resolving plugin [id: 'org.jetbrains.kotlin.multiplatform', version: '1.4.31']
> Plugin request for plugin already on the classpath must not include a version

Solution

  • The kotlin-js plugin had been deprecated and this works differently now:
    Migration from kotlin-js Gradle plugin to kotlin-multiplatform Gradle plugin.

    For example:

    plugins {
        alias(libs.plugins.kotlin.multiplatform)
    }
    
    kotlin {
        js(IR).browser()
    }