I'm developing a Project with Node and it is faili...
# javascript
f
I'm developing a Project with Node and it is failing build with Gradle when i configure with JDK more higher than 10. Dont show any error but not generate outputFile and other gradle tasks fail. Any limits on the version of the JDK in Kotlin/JS or node?
Copy code
plugins {
        id("org.jetbrains.kotlin.js") version "1.4-M1"
}

repositories {
    maven("<https://dl.bintray.com/kotlin/kotlin-eap>")
    jcenter()
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib-js"))
}

kotlin.target {
    useCommonJs()
    nodejs()
}
tasks.compileKotlinJs {
        kotlinOptions.outputFile = "routes/node/index2.js"
        kotlinOptions.metaInfo = false
}
My Enviroment: - Gradle: 6.4.1 (compatible with JDK 14) - IDEA last eap. (With previus versions the same) - Kotlin 1.4-M1(I tried with old versions)
i
Could you please provide what error it is?
v
Hi @Ilya Goncharov [JB], frank said "Dont show any error but not generate outputFile and other gradle tasks fail."
i
In fact it can be related with changing of
outputFile
In fact I don’t recommend to do it because now NPM project is build, and compilation output in part of this NPM project. It is necessary now to setup build infrastructure and so on. If you want, you can create
Copy
task, which can copy compilation output after compile task.
f
Hi @Ilya Goncharov [JB] , If I understand, you are in development with kotlin / JS. Do I have to create some tasks manually? I'm noob in kotlin/JS and follow books or tutorials for Node but all used old plugin(kotlin2js) or they do bad practices. Can you suggest me any book, tutorial or sample project with Node?
i
Yes, for now you need to manually create Gradle task It can be something like
Copy code
tasks.register("syncCompileKotlinJs", Copy::class.java) {
    val compile = tasks.withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class.java).named("compileKotlinJs")
    into("routes/node") {
        from(
            compile
            .map {
                it.outputFile.parentFile
            }
        )
    }

    into("$buildDir")

    dependsOn(compile)
}
f
thx @Ilya Goncharov [JB], I will continue with your sample and official guide of Kotlin/JS.
i
Feel free to share your experience here or anyway else. And if you want, you can explain your use case, because we interesting of different cases of applying Kotlin/JS in Node.JS environment.