louiscad
09/06/2020, 1:11 AMPlease choose a JavaScript environment to build distributions and run tests.
Not choosing any of them will be an error in the future releases.
kotlin {
js {
// To build distributions for and run tests on browser or Node.js use one or both of:
browser()
nodejs()
}
}
The problem is that whenever I try to replace js()
or js { useCommonJs() }
with js(BOTH) { nodejs(); browser() }
, I get that error on build:
Could not create an instance of type org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinNodeJs.
> Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
> Cannot add task 'clean' as a task with that name already exists.
I'm a little surprised the recommendation doesn't work… what could be wrong here, and is there workarounds?darkmoon_uk
09/06/2020, 4:40 AMbinaries.executable()
to your JS section when enabling the IR compiler?
This is exactly what caught me out in the post above ☝️ as kindly advised by @Robert Jaros.
For whatever reason, this is now explicitly required for the IR compiler to output executable JS.
See Choosing Execution Environment from https://kotlinlang.org/docs/reference/js-project-setup.html#choosing-execution-environment
I know the error message you provided seems unrelated, but I got similarly misleading errors when omitting binaries.executable()
.louiscad
09/06/2020, 7:43 AMbinaries.executable()
, but I get the exact same error.
BTW, I'd rather not use it since I'm only targetting Kotlin/JS users for all my JS compatible modules for now, and enable it on a per-module basis if it makes sense to use in a Typescript/Javascript project.Ilya Goncharov [JB]
09/06/2020, 8:24 AMclean
task, do you have it? Do you have clean
task on your root project for example?louiscad
09/06/2020, 8:25 AMtask<Delete>("clean") {
delete(rootProject.buildDir)
}
or the groovy DSL equivalent created by Android Studio templates (maybe not in recent versions, but the fact is that other projects will have it)louiscad
09/06/2020, 8:26 AMclean
task if it exists instead of forcing creation I guess… should I open an issue on youtrack @Ilya Goncharov [JB]?Ilya Goncharov [JB]
09/06/2020, 8:40 AMLifecycleBasePlugin
, we just apply it
You can create issue of course, but as I understand we have such oneIlya Goncharov [JB]
09/06/2020, 8:41 AMlouiscad
09/06/2020, 8:42 AMIlya Goncharov [JB]
09/06/2020, 8:47 AMlouiscad
09/06/2020, 10:52 PM