Can someone point me to an up to date `kotlin2js` ...
# javascript
t
Can someone point me to an up to date
kotlin2js
example with the latest kotlin version and with
react
,
react-dom
and
kotlinx-html-js
?
t
Copy code
buildscript {
    ext.kotlin_version = '1.2.21'

    repositories {
        mavenCentral()
        maven { url '<https://dl.bintray.com/kotlin/kotlin-eap>' }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.27"
    }
}

apply plugin: 'kotlin2js'
apply plugin: 'org.jetbrains.kotlin.frontend'
apply plugin: 'kotlin-dce-js'

repositories {
    mavenCentral()
    jcenter()
    maven { url '<https://kotlin.bintray.com/kotlin-js-wrappers>'}
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
    compile 'org.jetbrains:kotlin-react:16.2.0-pre.19-kotlin-1.2.20'
    compile 'org.jetbrains:kotlin-react-dom:16.2.0-pre.19-kotlin-1.2.20'
    testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}

compileKotlin2Js {
    kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js"
    kotlinOptions.moduleKind = "commonjs"
    kotlinOptions.sourceMap = true
    kotlinOptions.sourceMapEmbedSources = "always"
    kotlinOptions.main = "call"
}

kotlinFrontend {

    sourceMaps = true

    npm {
        dependency("react")
        dependency("react-dom")
    }

    webpackBundle {
        bundleName = "main"
        contentPath = file('src/main/web')
    }
}
Best part about this solution: no package.json needed 😉
t
Looks nice 👍
t
It's more flexible but less optimized than create-react-kotlin-app. You have to configure all by yourself. The DCE only works for kotlin code, not for the J's libraries (for what I understood)
f
Best part about CRKA: no build.gradle needed 😉