I'm getting the following error in my CI and in my...
# javascript
f
I'm getting the following error in my CI and in my local development environment as well:
Copy code
> Task :frontend:compileKotlinJs FAILED
w: Module "kotlin-react-dom" is defined in more than one file
w: Module "kotlin-react-router-dom" is defined in more than one file
w: Module "kotlin-react" is defined in more than one file
w: Module "kotlin-extensions" is defined in more than one file
w: Module "kotlinx-html-js" is defined in more than one file
e: warnings found and -Werror specified

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':frontend:compileKotlinJs'.
> Compilation error. See log for more details
Any idea how can I debug this error or disable the warnings? I will write the
build.gradle
in the thread
👀 1
Copy code
group 'com.github.felipehjcosta'
version '1.0-SNAPSHOT'

apply plugin: "org.jetbrains.kotlin.js"
apply plugin: 'kotlin-dce-js'

repositories {
    maven { url "<https://kotlin.bintray.com/kotlin-js-wrappers/>" }
}

kotlin {
    target {
        browser {
            configure([compilations.main, compilations.test]) {
                kotlinOptions {
                    metaInfo = true
                    sourceMap = true
                    moduleKind = 'commonjs'
                    main = "call"
                    allWarningsAsErrors = true
                }
            }
            webpackTask {
                runTask {
                    //todo: use dsl after KT-32016 will be fixed
                    devServer = new org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.DevServer(
                            true, false, true, true, false,
                            8081,
                            ["/api": "<http://0.0.0.0:8082>"],
                            ["$projectDir/src/main/resources".toString()]
                    )
                    outputFileName = "chatapp-frontend.js"
                }
            }
            testTask {
                useKarma {
                    usePhantomJS()
                }
            }
        }
    }
    sourceSets {
        main {
            kotlin.srcDirs += 'src/main/kotlin'
            dependencies {
                implementation project(":common:client")
                implementation kotlin("stdlib-js")

                implementation "org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60"
                implementation "org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60"
                implementation "org.jetbrains:kotlin-react-router-dom:4.3.1-pre.89-kotlin-1.3.60"
                implementation "org.jetbrains:kotlin-extensions:1.0.1-pre.89-kotlin-1.3.60"

                implementation npm("kotlinx-html", "0.6.12")
                implementation npm("@jetbrains/kotlin-react", "16.9.0-pre.89")
                implementation npm("@jetbrains/kotlin-react-dom", "16.9.0-pre.89")
                implementation npm("@jetbrains/kotlin-react-router-dom", "4.3.1-pre.89")
                implementation npm("@jetbrains/kotlin-extensions", "1.0.1-pre.89")
                implementation npm("react", "16.9.0")
                implementation npm("react-dom", "16.9.0")
                implementation npm("react-router-dom", "4.3.1")
            }
        }
        test {
            dependencies {
                implementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
            }
        }
    }
}
i
@fcosta Hi! I failed to reproduce the problem. Can you attach a link to your project on github? Also, we have bugreports in our issuetracker with warnings like you have: https://youtrack.jetbrains.com/issue/KT-21348 and https://youtrack.jetbrains.com/issue/KT-25284
f
@Ivan Kubyshkin [JetBrains] Thanks! Sure! Here is the link to the project: https://github.com/felipehjcosta/chat-app and for the CI Job: https://circleci.com/gh/felipehjcosta/chat-app/538
i
@fcosta You should use either download npm packages or download these dependencies from bintray. So you can just delete this part:
Copy code
implementation "org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60"
implementation "org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60"
implementation "org.jetbrains:kotlin-react-router-dom:4.3.1-pre.89-kotlin-1.3.60"
implementation "org.jetbrains:kotlin-extensions:1.0.1-pre.89-kotlin-1.3.60"
f
Now I got the following error
👀 1
Untitled
i
There are 2 problems: 1) https://youtrack.jetbrains.com/issue/KT-31807 . You should add
'kotlin-react-router-dom': '@jetbrains/kotlin-react-router-dom'
into
webpack.config.d/03.resolve.js
2) https://youtrack.jetbrains.com/issue/KT-30619. You should add
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.3"
into
build.gradle
But for now the best way to download js dependency from
npm
and
@jetbrains/{something}
from maven.
So in your case is better to delete
Copy code
//                implementation npm("kotlinx-html", "0.6.12")
//                implementation npm("@jetbrains/kotlin-react", "16.9.0-pre.89")
//                implementation npm("@jetbrains/kotlin-react-dom", "16.9.0-pre.89")
//                implementation npm("@jetbrains/kotlin-react-router-dom", "4.3.1-pre.89")
//                implementation npm("@jetbrains/kotlin-extensions", "1.0.1-pre.89")
and leave
Copy code
implementation "org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60"
                implementation "org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60"
                implementation "org.jetbrains:kotlin-react-router-dom:4.3.1-pre.89-kotlin-1.3.60"
                implementation "org.jetbrains:kotlin-extensions:1.0.1-pre.89-kotlin-1.3.60"
Also, don't forget to delete workaround from
webpack.config.d/03.resolve.js
f
It worked! Thanks!