addamsson
01/31/2020, 9:39 PMfun main() {
document.addEventListener("DOMContentLoaded", object : EventListener {
override fun handleEvent(event: Event) {
println("Foobar")
}
})
}
and the corresponding Gradle setup:
plugins {
kotlinMultiplatform
}
kotlin {
js {
browser()
}
}
but I can't see "Foobar" printed and if I just copy the generated code into my browser's console it says Error loading module 'mymodule'. Its dependency 'kotlin' was not found
. Can someone point me to the docs so I can figure out how to get this working (and also solve a bunch of other issues like how to rename my module and how to run it in dev mode)?gbaldeck
02/03/2020, 9:07 PMNikky
02/05/2020, 6:43 PMincludeBuild()
in gradle and substitute for a dev version of a dependency
this works fine for browserProductionWebpack
but it seems like browserDevelopmentWebpack
is choking on it
oh, btw i am using 1.3.70-eap-184
will try to make a simple repo for reproduction and create a issue later
this is the error the wepack process spits out:
ERROR in ./kotlin/pentagame-frontend.js
Module not found: Error: Can't resolve 'ksvg' in '/home/nikky/dev/pentagame/build/js/packages/pentagame-frontend/kotlin'
@ ./kotlin/pentagame-frontend.js 3075:370-385
@ multi ./kotlin/pentagame-frontend.js
gbaldeck
02/06/2020, 3:12 AMllsouder
02/06/2020, 3:49 AMLamberto Basti
02/06/2020, 6:12 PMtext
ERROR in D:/Progetti/Android-Application/build/js/packages_imported/firebase-multiplatform-auth/0.1.8/firebase-multiplatform-auth.js
Module not found: Error: Can't resolve 'firebase.auth.ActionCodeInfo' in 'D:\Progetti\Android-Application\build\js\packages_imported\firebase-multiplatform-auth\0.1.8'
@ D:/Progetti/Android-Application/build/js/packages_imported/firebase-multiplatform-auth/0.1.8/firebase-multiplatform-auth.js 3:4-144
@ ../my-application-kodein-di/kotlin/my-application-kodein-di.js
@ ./kotlin/my-application-web-client-2.js
@ multi ./kotlin/my-application-web-client-2.js
Now, firebase.auth.ActionCodeInfo
is actually a class from the Firebase JS library for which [Dukat](https://github.com/Kotlin/dukat/) wrote [this](https://github.com/lamba92/firebase-multiplatform/blob/9dccf3e1c8b19b5181e8f02266bf6775ecd53f2c/core/src/jsMain/kotlin/firebase/auth/index.firebase.auth.module_firebase.kt#L41-L44) (that i rearranged into packages).
Why does this infernal webpack machinery looks for it inside my library instead of the Firebase one?Matej Drobnič
02/07/2020, 11:45 AMkotlin-frontend-plugin
.
For example [modules page](https://kotlinlang.org/docs/reference/js-modules.html) mentions compileKotlin2Js
config option which is not present in the new kotlin plugin.gbaldeck
02/07/2020, 1:01 PMcorneil
02/07/2020, 3:09 PMcorneil
02/07/2020, 3:14 PMgbaldeck
02/08/2020, 3:08 AMRobert Cronin
02/08/2020, 11:25 AMopen external class Tensor {
...
}
fun Tensor.someInternalFunction() {
...
}
leandro
02/09/2020, 1:32 PMkotlin2js
& org.jetbrains.kotlin.frontend
to the new org.jetbrains.kotlin.js
plugin. Re-writing my :web
module to be the same as the newly released version for "Building Web Applications with React and Kotlin/JS" worked well, and now I want to make use of another module inside the same project. Previously, in my build.gradle
, I had the following declaration:
apply plugin: 'kotlin2js'
apply plugin: 'org.jetbrains.kotlin.frontend'
dependencies {
compile project(':api')
//...
}
and now I have, on my `build.gradle.kts`:
plugins {
id("org.jetbrains.kotlin.js")
}
group = "org.example"
version = "1.0-SNAPSHOT"
dependencies {
implementation(project(":api"))
//...
}
As I try to run ./gradlew :web:browserDevelopmentRun
, I get the error
project ':api' is not configured for JS usage
Previously it was working fine. My :api
build.gradle
is as follows:
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'kotlinx-serialization'
archivesBaseName = 'api'
kotlin {
js {
compilations.main.kotlinOptions {
moduleKind = 'umd'
}
}
sourceSets {
commonMain {
dependencies {
api deps.kotlin.stdlib.common
api deps.kotlin.coroutines.common
api project(':backend:model')
implementation deps.kotlin.serialization.common
}
}
jsMain {
dependencies {
api deps.kotlin.stdlib.js
api deps.kotlin.coroutines.js
api deps.kotlin.serialization.js
}
}
}
}
MrPowerGamerBR
02/09/2020, 3:07 PMEnumClassHere.values()
in the Kotlin/JS project, it fails with
As a workaround I added this to my enum class in the multiplatform projectTypeError: can't access property "values", $module$loritta_<http://api.net|api.net>.perfectdreams.loritta.api.commands.CommandCategory is undefined
init {
CommandCategory.values().forEach {}
}
...and it worked without any issues! Is this a known issue? (and yes, I did try disabling Kotlin DCE on my JS project, but even with it disabled the error still happened)Sean Keane
02/12/2020, 9:16 AMmirror-kt
02/12/2020, 4:06 PMWhen accessing module declarations from UMD, they must be marked by both @JsModule and @JsNonModule
I'm developping for browser, and using react-redux.
I saw react-redux code, only annotated @JsModule("react-redux")
,but no annotation @NonJsModule
.Janelle Fullen
02/13/2020, 6:28 PMgbaldeck
02/13/2020, 7:35 PMrnentjes
02/14/2020, 9:42 AMspierce7
02/15/2020, 5:35 AMkotlin.js.experimental.generateKotlinExternals=true
in my settings.gradle
, I’ve added npm dependencies:
plugins {
kotlin("js")
}
kotlin {
target {
nodejs()
}
sourceSets {
val main by getting {
dependencies {
implementation(Deps.kotlin.stdlib.js)
npm("firebase-admin", "8.6.0")
npm("firebase-functions", "3.3.0")
npm("twilio", "3.39.4")
npm("left-pad", "1.3.0")
}
}
val test by getting {
dependencies {
implementation(Deps.kotlin.test.js)
}
}
}
}
and I’m running the generateExternals
command, but I still can’t see any generated files in the build directory, or any code completion.
Anyone have any ideas? I’ve also tried the 1.3.70 eap, with no results.spierce7
02/15/2020, 4:04 PMts2kt
and the bindings that they generate. I was excited a year or so back when I read about dukat because it was recognition that ts2kt was broken, and needed to be more than just a side project, but rather a core part of the experience.
I’ve sunk about 6 hours now into dukat, and I’m walking away with about the same level experience I had with ts2kt. I’m getting several random crashes for popular js libs (like firebase), and the lib that I did get to work (twilio) has the majority of the API libs stubbed out incorrectly with Any
, defeating the entire point.ribesg
02/15/2020, 6:18 PMspierce7
02/15/2020, 7:56 PMgbaldeck
02/15/2020, 8:02 PMgbaldeck
02/15/2020, 8:22 PMSimon Heimler
02/17/2020, 9:00 AMjs("node").compilations["main"]
artifact?
Thank you for your time and effort you're putting into this!
The relevant part of our build.gradle.kts
js("node") {
nodejs {
}
compilations.all {
compileKotlinTask.kotlinOptions {
metaInfo = true
sourceMap = true
moduleKind = "commonjs"
sourceMapEmbedSources = null
}
}
}
[...]
js("node").compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion")
implementation("io.ktor:ktor-client-js:$ktorVersion")
implementation("io.ktor:ktor-client-serialization-js:$ktorVersion")
implementation("io.ktor:ktor-client-json-js:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion")
implementation("io.ktor:ktor-client-auth-js:$ktorVersion")
implementation(npm("uuid", "3.3.3"))
}
}
Gurupad Mamadapur [FH]
02/17/2020, 10:26 AMTypeError: tmp$.iterator is not a function
while iterating a nullable list type. (Kotlin/js - 1.3.61). Also, this is an MPP project using coroutines. This error occurs inside a coroutine
Ex -
val marked: List<User> = dto.accounts?.map { User(it) } ?: listOf()
// where accounts is of type List<T>?
spierce7
02/17/2020, 6:26 PMjs("{}")
and then manually populating it with data still the most convenient?spierce7
02/18/2020, 4:25 AMspand
02/18/2020, 2:43 PMobj[propName]
?spand
02/18/2020, 2:43 PMobj[propName]
?Robert Jaros
02/18/2020, 2:54 PMdynamic
are translated 1 to 1 to jsspand
02/18/2020, 2:57 PM