I started migrating from `kotlin2js` & `org.je...
# javascript
l
I started migrating from
kotlin2js
&
org.jetbrains.kotlin.frontend
to the new
org.jetbrains.kotlin.js
plugin. Re-writing my
:web
module to be the same as the newly released version for "Building Web Applications with React and Kotlin/JS" worked well, and now I want to make use of another module inside the same project. Previously, in my
build.gradle
, I had the following declaration:
Copy code
apply plugin: 'kotlin2js'
apply plugin: 'org.jetbrains.kotlin.frontend'

dependencies {
  compile project(':api')
  //...
}
and now I have, on my `build.gradle.kts`:
Copy code
plugins {
  id("org.jetbrains.kotlin.js")
}

group = "org.example"
version = "1.0-SNAPSHOT"

dependencies {
  implementation(project(":api"))
  //...
}
As I try to run
./gradlew :web:browserDevelopmentRun
, I get the error
Copy code
project ':api' is not configured for JS usage
Previously it was working fine. My
:api
build.gradle
is as follows:
Copy code
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'kotlinx-serialization'

archivesBaseName = 'api'

kotlin {
  js {
    compilations.main.kotlinOptions {
      moduleKind = 'umd'
    }
  }

  sourceSets {
    commonMain {
      dependencies {
        api deps.kotlin.stdlib.common
        api deps.kotlin.coroutines.common
        api project(':backend:model')
        implementation deps.kotlin.serialization.common
      }
    }
    jsMain {
      dependencies {
        api deps.kotlin.stdlib.js
        api deps.kotlin.coroutines.js
        api deps.kotlin.serialization.js
      }
    }
  }
}
And the full stack-trace
i
Hi! You need to declare
browser
or
nodejs
suntergat in your
api
module
Copy code
kotlin {
   js {
       nodejs() // for example
   }
}
l
Thank you Ilya, that worked! Just to add to your answer, I had to cascade adding
browser()
to every single module that was multiplatform and declared the
js{}
block.
i
Yes, it is necessary because we leave
js{}
in compatibility aims But for mpp you should to declare
browser
or
nodejs
explicitly It additionally setup test environment
👍 1