taso
02/02/2018, 12:54 PMreact
project with KotlinJs. https://github.com/novoda/spikes/blob/master/game-of-life-multiplatform/web/build.gradle
The below gradle script is something we copy pasted. When I upgrade to Kotlin version 1.2.21
, the task mentioned in the very bottom copyDependenciesKotlinJs
is gone. Since I don’t understand the setup, I’m really not sure how to fix it.
task copyStatic(type: Copy) {
from "$rootDir/src/web"
into "$buildDir/web"
}
task buildBundle(type: NpmTask, dependsOn: [npmInstall, runDceKotlinJs]) {
args = ["run", "dist"]
}
task copyKotlinJs(type: Copy, dependsOn: compileKotlin2Js) {
def workDir = "$buildDir/classes/main/"
from(workDir) {
include "*.js"
include "*.js.map"
}
into "$workDir/dependencies"
}
task devBuild(dependsOn: [npmInstall, copyStatic, copyKotlinJs])
assemble.dependsOn buildBundle, copyStatic
afterEvaluate {
copyKotlinJs.dependsOn copyDependenciesKotlinJs
}
taso
02/02/2018, 12:54 PMkotlin2js
example with the latest kotlin version and with react
, react-dom
and kotlinx-html-js
?Tristan Caron
02/02/2018, 7:44 PMsabag.ronen
02/03/2018, 6:21 AMsabag.ronen
02/03/2018, 11:08 AMbenleggiero
02/05/2018, 1:39 AMgaetan
02/05/2018, 2:39 PMinterface GeoJson{
val type:String
val coordinates:Array<*>
fun asPoint() = Point(coordinates as Array<Double>)
}
data class Point(val coordinates:Array<Double>)
fun main(args: Array<String>) {
val json = """{"type":"Point", "coordinates":[1.0, 2.0]}"""
val obj = JSON.parse<GeoJson>(json).asPoint()
println("${obj.coordinates}")
}
https://try.kotlinlang.org/#/UserProjects/2fobglofrrpnr9b0pru299uu31/6d1saqhqrbndev90djqurmuiv0chadmorrow
02/06/2018, 5:08 PMUncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Invalid referrer policy
marcinmoskala
02/07/2018, 5:38 AMkotlin-frontend-plugin
?
https://github.com/Kotlin/kotlin-frontend-pluginspand
02/07/2018, 9:16 AMFilipp Riabchun
02/07/2018, 9:22 AMexternal class Foo {
// instance members
}
JsName("Foo")
external object FooConstructor {
// static members
}
spand
02/07/2018, 10:36 AMFrancis
02/07/2018, 3:39 PMKotlin.defineModule is not a function
. In the console :`Object.kt:20 Uncaught TypeError: Kotlin.defineModule is not a function`Filipp Riabchun
02/07/2018, 3:46 PMrm -rf node_modules/.cache
. Unfortunately we haven't found a permanent fix at the momentmmaillot
02/07/2018, 3:50 PMval request = XMLHttpRequest()
request.open("GET", endpoint, false)
request.send(null)
if (request.status.toInt() == 200) {
return JSON.parse(request.responseText)
}
And I get this error : XMLHttpRequest is not defined
. My code run on NodeJS and NodeJS doesn't have XMLHttpRequest...
Should I use another lib and wrap it ?spierce7
02/07/2018, 5:58 PMUse jsonreader.setlenient(true) to accept malformed json at line 1 column 1 path $
. Should I be using the "Attach to Node.js/Chrome" configuration, or is there a better way? I can see my kotlin sources and everything in the browser, just trying to get it to work in the IDE as well.gaetan
02/07/2018, 11:31 PMmodule.exports = function(config) {
config.set({
frameworks: ['qunit', 'browserify'],
reporters: ['mocha'],
files: [
'build/classes/kotlin/main/*.js',
'build/classes/kotlin/test/*.js',
'build/node_modules/*.js',
{pattern: 'build/classes/kotlin/test/*.json', watched: true, served: true, included: false}
],
colors: true,
logLevel: config.LOG_INFO,
browsers: [
// 'ChromeHeadless',
// 'PhantomJS',
'Chrome'
],
// singleRun: true,
singleRun: false,
autoWatch: false,
captureTimeout: 5000,
// singleRun: false, // Karma captures browsers, runs the tests and exits
preprocessors: {
'**/*.js': ['browserify']
}
})
};
Using Chrome instead of PhantomJS or ChromeHeadless with singleRun: false
will launch chrome with the debug interface. You can then launch the test and use the chrome dev tools.gaetan
02/07/2018, 11:33 PMspierce7
02/07/2018, 11:42 PMCannot find module "kotlinx-coroutines-core-js"
. How should I be packaging the coroutine library (or any library written in kotlin for that matter)? My instinct was to check npm, but didn't find anything.
If I use the DCE plugin, it outputs all the JS files in one place which is nice, but how do I get the non-minified js files for kotlin-js libraries I'm using? Right now, the only thing I can think of is to check out the github.alexcouch
02/08/2018, 8:25 AMspand
02/08/2018, 9:38 AMnew $.Zebra_Tooltips(elm, {});
Is the only way to call new to have a class constructor in Kotlinjs ?lewik
02/08/2018, 12:50 PMkarelpeeters
02/08/2018, 12:59 PMvar
and set it to null
?Tristan Caron
02/08/2018, 1:07 PMjs("'undefined'")
araqnid
02/08/2018, 5:32 PMrequire
(i.e. clearly for side-effect) rather than assigning it to a val?gbaldeck
02/08/2018, 9:18 PMgaetan
02/09/2018, 10:47 AMFemi Sotonwa
02/09/2018, 12:23 PMczyzby
02/10/2018, 12:24 PMsrc/main/kotlin
not being marked as source folder in IntelliJ when using Gradle?
plugins {
id("kotlin2js")
}
dependencies {
compile(kotlin("stdlib-js"))
}
czyzby
02/10/2018, 3:06 PMczyzby
02/10/2018, 3:06 PM