I update to last version `Kotlin 1.4-M2` and can...
# javascript
f
I update to last version
Kotlin 1.4-M2
and cant call to ':compileKotlinJs' tasks directly, Gradle module have tasks but not found in build.gradle.
Copy code
//Fail Call :compileKotlinJs tasks
tasks.compileKotlinJs{
        kotlinOptions.outputFile = "${projectDir}/routes/node/index2.js"
        kotlinOptions.metaInfo = false
        kotlinOptions.moduleKind = "commonjs"
}

//Work call to :compileKotlinJs
tasks {
    "compileKotlinJs"(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class) {
        kotlinOptions.outputFile = "${projectDir}/routes/node/index2.js"
        kotlinOptions.metaInfo = false
        kotlinOptions.moduleKind = "commonjs"
    }
}
Any idea because dont work
tasks.compileKotlinJs
If exists in Gradle module?
t
There are 3 JS modes in M2 (IR, LEGACY, BOTH) • IR -
compileKotlinJsIr
• LEGACY -
compileKotlinJs
• BOTH -
compileKotlinJs
+
compileKotlinJsIr
Plugin couldn’t create task
compileKotlinJs
by default, that is why task isn’t available in DSL
f
I tried add LEGACY but continues without found
compileKotlinJs
in DSL.
Copy code
kotlin {
    js(LEGACY) {
        nodejs { }
        binaries.executable()
    }
}
Can I do something to add in DSL?
i
Yes, unfortunately since we have several modes of working, we can’t predict correctly if
compileKotlinJs
exists. Maybe in major count of cases it will and we can register it speculatively. But it means that in cases of
both
mode it will lead to error.
t
@frank Do you have many Kotlin/JS subprojects in project?
f
Yes, I have three subprojects but I have also tried a project without subprojects and got same result.
@Ilya Goncharov [JB], If i need setting
kotlinOptions
. Do I have to use
Kotlin2JsCompile::class
and
KotlinCompile::class
until there is a stable version?
i
In fact, this task is registered after you write
Copy code
kotlin {
    js {
    }
}
You can use either
Kotlin2JsCompile
or maybe
KotlinJsCompile