https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
u

untwisted

12/11/2018, 6:42 PM
Hello, all. I’m using multiplatform and trying to figure out how to specify the multiplatform equivalent of
compileKotlin2Js.kotlinOptions.moduleKind = "commonjs"
in the project’s
build.gradle
, but Gradle is saying that it can’t find
compileKotlin2Js
which I suspect is because this is multiplatform. Is there a way to specify this option in a multiplatform build?
Figured it out! For anyone else that has this problem I used:
Copy code
kotlin {
  targets {
    fromPreset(presets.jvm, 'jvm')
    fromPreset(presets.js, 'js') {
      compilations.all {
        tasks[compileKotlinTaskName].kotlinOptions {
          moduleKind = "commonjs"
        }
      }
    }
  }
g

gildor

12/14/2018, 8:02 AM
I believe that
tasks
is not a property of
compilation
this is just a top level property
so you can move it out of
kotlin{}
dsl block
also, you don’t need tasks to configure
kotlinOptions
, there is
kotlinOptions
inside compilation