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)?addamsson
01/31/2020, 11:12 PMjvmJar {
dependsOn(jsBrowserWebpack)
from(new File(jsBrowserWebpack.entry.name, jsBrowserWebpack.outputPath))
}
addamsson
01/31/2020, 11:12 PMaddamsson
01/31/2020, 11:12 PMaddamsson
01/31/2020, 11:13 PMtasks {
named<Jar>("jvmJar") {
dependsOn(withType(KotlinWebpack::class.java))
}
}
It created the distributions
folder but got stuck at running my code in the browser during the build (why???)Ilya Goncharov [JB]
02/01/2020, 9:44 AMbrowserRun -t
and it will open browser with js application
If you run build
task, in distributions folder you can get your final application bundleaddamsson
02/01/2020, 9:55 AMaddamsson
02/01/2020, 9:55 AMgradle clean build
my build
folder is just deleted and there is no distributions
folderaddamsson
02/01/2020, 9:55 AMIlya Goncharov [JB]
02/01/2020, 10:10 AMaddamsson
02/01/2020, 10:10 AMaddamsson
02/01/2020, 10:10 AMaddamsson
02/01/2020, 10:12 AMaddamsson
02/01/2020, 10:12 AMIlya Goncharov [JB]
02/01/2020, 10:13 AMkotlin
extension on “js” word as you didaddamsson
02/01/2020, 10:14 AMdistributions
folderaddamsson
02/01/2020, 10:14 AMIlya Goncharov [JB]
02/01/2020, 10:15 AMaddamsson
02/01/2020, 10:53 AMjvmJar {
dependsOn(jsBrowserWebpack)
from(new File(jsBrowserWebpack.entry.name, jsBrowserWebpack.outputPath))
}
addamsson
02/01/2020, 10:53 AMkts
addamsson
02/01/2020, 11:01 AMkts
with the code from the sample project which IDEA generates and now I can confirm that this was because of the missing jvmJar
blockaddamsson
02/01/2020, 11:01 AM--no-parallel
addamsson
02/01/2020, 11:01 AMaddamsson
02/01/2020, 11:01 AMjvmJar
block to kts
?addamsson
02/01/2020, 11:25 AMaddamsson
02/01/2020, 11:25 AMaddamsson
02/01/2020, 11:25 AMaddamsson
02/01/2020, 11:25 AMaddamsson
02/01/2020, 11:25 AMaddamsson
02/01/2020, 11:33 AMaddamsson
02/01/2020, 11:33 AMIlya Goncharov [JB]
02/02/2020, 7:28 AMaddamsson
02/02/2020, 10:07 AM--continuous
is not doing anything and the generated javascript file is 12MB in size not the promised 30KB from the talkaddamsson
02/02/2020, 10:07 AMaddamsson
02/02/2020, 10:08 AMaddamsson
02/02/2020, 10:08 AMjvmJar {
dependsOn(jsBrowserWebpack)
println("entry name: ${jsBrowserWebpack.entry.name} output: ${jsBrowserWebpack.outputPath}")
from(new File(jsBrowserWebpack.entry.name, jsBrowserWebpack.outputPath))
}
addamsson
02/02/2020, 10:09 AMjsBrowserWebpack.entry.name
doesn't have the same file name as jsBrowserWebpack.outputPath
addamsson
02/02/2020, 10:09 AMaddamsson
02/02/2020, 10:09 AMaddamsson
02/02/2020, 10:10 AMaddamsson
02/02/2020, 10:10 AMaddamsson
02/02/2020, 10:10 AMjvmJar {
dependsOn(jsBrowserWebpack)
println("entry name: ${jsBrowserWebpack.entry.name} output: ${jsBrowserWebpack.outputPath}")
from(new File(jsBrowserWebpack.entry.name, jsBrowserWebpack.outputPath))
}
task run(type: JavaExec, dependsOn: [jvmJar]) {
group = "application"
main = "MyServerKt"
classpath(configurations.jvmRuntimeClasspath, jvmJar)
args = []
}
addamsson
02/02/2020, 10:10 AMIvan Kubyshkin [JetBrains]
02/03/2020, 7:56 AMSebastian Aigner
02/03/2020, 11:30 AM