Hello guys, I'm facing this rare issue: ```ERROR ...
# javascript
s
Hello guys, I'm facing this rare issue:
Copy code
ERROR in ../node_modules_imported/kotlin-extensions/kotlin-extensions.js
Module not found: Error: Can't resolve 'core-js/features/object/assign' in '/home/sergio/projects/timesheet/js/build/node_modules_imported/kotlin-extensions'
 @ ../node_modules_imported/kotlin-extensions/kotlin-extensions.js 112:37-78
 @ ../node_modules_imported/kotlin-react-dom/kotlin-react-dom.js
 @ ./output.js
Any help? It's rare because I have another project with exactly the same structure and works fine I'll paste the build.gradle file on the thread
Copy code
apply plugin: 'org.jetbrains.kotlin.frontend'
apply plugin: 'kotlin2js'
apply plugin: 'kotlinx-serialization'

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile project(":common")

    compile "org.jetbrains.kotlinx:kotlinx-html-js:0.6.11"
    compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version"

    compile "org.jetbrains:kotlin-react:16.6.0-pre.71-kotlin-1.3.31"
    compile "org.jetbrains:kotlin-react-dom:16.6.0-pre.71-kotlin-1.3.31"
    compile 'org.jetbrains:kotlin-extensions:1.0.1-pre.71-kotlin-1.3.31'

    testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}

sourceSets {
    main.kotlin.srcDirs += 'src/main/kotlin'
}

kotlinFrontend {
    downloadNodeJsVersion = "8.11.2"
    sourceMaps = false

    npm {
        replaceVersion "kotlinx-html-js", "$kotlin_version"
        replaceVersion "kotlinx-html-shared", "$kotlin_version"
        replaceVersion "kotlin-js-library", "$kotlin_version"
        replaceVersion "kotlin-extensions", "$kotlin_version"

        dependency "react", "16.6.0"
        dependency "react-dom", "16.6.0"
    }

    webpackBundle {
        bundleName = "main"
        contentPath = file('src/main/resources')
        proxyUrl = "<http://localhost:9090>"
    }
}

compileKotlin2Js {
    kotlinOptions.metaInfo = true
    kotlinOptions.outputFile = "$project.buildDir.path/js/output.js"
    kotlinOptions.sourceMap = true
    kotlinOptions.sourceMapEmbedSources = "always"
    kotlinOptions.moduleKind = 'commonjs'
    kotlinOptions.main = "call"
}
l
You have to add
core-js
to your npm dependencies.
s
I'll try, how do start the project?
With
./gradlew js:run
or
npm start
??
r
force version 3.0.0 of
core-js
, probably your project is using the older version
Copy code
npm {
    dependency("core-js", "3.0.0")
}
🔝 1
s
I've just added
replaceVersion "core-js", "3.0.1"
But seems to be not working, I'll check yours
It works! Thanks! 🙂
n
Is that npm block example the Gradle Kotlin DSL version?
r
@napperley No, standard groovy version.