https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
javascript
  • s

    spierce7

    07/17/2020, 8:32 PM
    Has anyone seen an error like this?
    Cannot destructure property `AbortController` of 'undefined' or 'null'
    j
    t
    i
    • 4
    • 14
  • s

    spierce7

    07/18/2020, 2:24 AM
    I’m getting another weird error now. I’ve solved the AbortController problem, but now I’m getting
    Error loading module 'node-fetch': Error: Cannot find module 'node-fetch'
    .
    • 1
    • 1
  • j

    janvladimirmostert

    07/18/2020, 8:24 AM
    is it just me or does kotlinx.serializable on a Kotlin class really makes the generated JS explode in size? without Kotlin serialization
    -rw-rw-r-- 1 vlad vlad  79K Jul 18 10:22 register.e2a243ea.js
    with serialization
    -rw-rw-r-- 1 vlad vlad  349K Jul 18 09:21 register.6e5afb3d.js
    might be more efficient to just use JS's stringify on the frontend and gson / jackson on the backend removing serialization completely, all the annotations and and imports and it drops down to 17K, so that's a 300kB+ penalty for using serialization
    r
    t
    • 3
    • 19
  • n

    Nico

    07/18/2020, 10:55 AM
    Hi! I am playing with 1.4-M3 and noticed that
    @JsExport
    is actually quite restrictive. I am wondering whether there are any plans to relax this in the future? I am mostly thinking supporting enums and properties without fields. At the moment I cannot export a class annotated with
    @Serializable
    . The specific use case is sharing a data class between my TS and Kotlin/jvm codebases Otherwise amazing work with 1.4, it's amazing to have TS definitions for kotlin code
    j
    t
    d
    • 4
    • 20
  • m

    Michal Janos

    07/18/2020, 3:28 PM
    Hi I'm new with kotlin, so my question may be stupid, but are there someone, who have correctly implement
    klock
    to multiplatform? I have implemented 1.11.13, everything works fine, with using
    npm link
    , but it is not possible to publish it to my private nexus NPM repo what I try, is to change package.json, and change it to my scope before publish, this help me with
    kotlin-source-map-loader
    , but
    klock
    create
    require('klock-root-klock')
    on end of generated js file
    j
    • 2
    • 2
  • f

    frank

    07/19/2020, 9:32 PM
    [Solved] I'm testing with
    Socket IO
    and I'm having trouble with connection in server. It appears to make the connection 3 times. Could someone give me a hint? I have tried with others projects and I have the same problem. Server Connection:
    Server Starting!
    Chat Server listening on port <http://localhost:8000>
    socket connection
    socket connection
    socket connection
    Resume Configuration IO:
    val express = require("express")
    val app = express()
    app.set("port", port)
    
    val server = require("http").createServer(app)
    server.listen(port)
    
    val io     = require("<http://socket.io|socket.io>")(server)
    io.on("connect") { socket ->
        console.log("socket connection") 
    }
    JavaScript Generated:
    function main$lambda_0(closure$users, closure$numOfUsers) {
     return function (socket) {
       console.log('socket connection');
       socket.on('join', main$lambda$lambda(socket, closure$users, closure$numOfUsers));
       socket.on('disconnect', main$lambda$lambda_0(closure$users, socket, closure$numOfUsers));
       return socket.on('new_message', main$lambda$lambda_1(closure$users, socket));
     };
    }
    
    function main() {
      var numOfUsers = {v: 0};
      println('Server Starting!');
      var express = require('express');
      var app = express();
      var path = require('path');
      var bodyParser = require('body-parser');
      var debug = require('debug')('kotlin_react_chat:server');
      var port = normalizePort(process.env.PORT);
      app.use(bodyParser.json());
      app.set('port', port);
      app.set('views', path.join(__dirname, '../../webapp'));
      app.set('view engine', 'ejs');
      app.use(express.static('webapp'));
      app.use('/', router());
      var server = require('http').createServer(app);
      server.listen(port, main$lambda(port));
      var io = require('<http://socket.io|socket.io>')(server);
      var users = ArrayList_init();
      io.on('connect', main$lambda_0(users, numOfUsers));
    }
    t
    • 2
    • 2
  • t

    Tristan

    07/19/2020, 9:44 PM
    Hello, is there a browser compatibility table for the code generated?
    s
    • 2
    • 2
  • j

    ja.son

    07/20/2020, 12:15 AM
    Are there any Fritz2 users?
    a
    h
    +2
    • 5
    • 7
  • f

    Friedger

    07/20/2020, 1:23 PM
    The compiler converts a list property
    entries
    to something like:
    object.entries.array_hd7ov6$_0
    . Is there a way to give it a nice name via
    @jsname
    ? Or should I just use Arrays instead of Lists?
    j
    • 2
    • 2
  • k

    Kroppeb

    07/20/2020, 7:11 PM
    Adding
    implementation(npm("brigadier-ts"))
    to my multiplatform jsMain (kotlin dsl) breaks my project structure. The only msg I get is the following:
    <ij_msg_gr>Gradle import errors<ij_msg_gr><ij_nav>K:\Minecraft\fabric\Brigadier\build.gradle.kts<ij_nav><i><b>root project 'Brigadier': Unable to build Kotlin project configuration</b><eol>Details: org.gradle.internal.operations.BuildOperationQueueFailure: There was a failure while populating the build operation queue: NPM project resolved without org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager@4d5bb864<eol>Caused by: java.lang.IllegalStateException: NPM project resolved without org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager@4d5bb864</i>
    a
    t
    • 3
    • 7
  • h

    Harald Pehl

    07/21/2020, 9:28 AM
    I'd like to use a local SCSS file in my Kotlin/JS application. I'm already using external npm dependencies:
    import kotlinext.js.require
    
    require("@patternfly/patternfly/patternfly.css")
    require("@patternfly/patternfly/patternfly-addons.css")
    require("highlight.js/lib/core")
    require("highlight.js/lib/languages/kotlin")
    Now I'd like to use a SCSS file from
    src/main/resources/showcase.scss
    . But webpack won't find the file. I've already tried different paths:
    require("./src/main/resources/showcase.scss")
    require("./resources/showcase.scss")
    require("./showcase.scss")
    w/o success. Anybody knows how to process local SCSS files with Kotlin/JS & Webpack?
    t
    • 2
    • 2
  • d

    Devil Ster 1

    07/21/2020, 2:19 PM
    Hi. Is there any documentation about KotlinJS? or only hands-on ? thx
    s
    j
    f
    • 4
    • 6
  • s

    spierce7

    07/21/2020, 8:04 PM
    Am I imagining things, or does the new IR compiler compile much slower?
    t
    b
    • 3
    • 16
  • j

    Johannes Goslar

    07/22/2020, 3:19 PM
    Hey everyone, my company is in the process of trying out Kotlin to have a shared data layer between the different frontends (android, iOS, web). The main development effort will happen on iOS first, but I am wanna try to get something running on web as early as possible in parallel. Is now the right time to try to do so? Or should one wait for the next (some future) release, which is gonna make everything much easier?
    t
    b
    +2
    • 5
    • 9
  • d

    Darren Bell

    07/23/2020, 11:33 AM
    Hi. Using gradle, how publish the jsJar of a javascript library project to a maven repository?
    t
    • 2
    • 2
  • m

    Mazugrin

    07/23/2020, 1:45 PM
    Hi y'all, I'm new to both Kotlin and KotlinJS. I have the simplest project set up, and am having an issue with the webpack dev server. When I run it with
    gradlew run --continuous
    , it seems to work as it should - I can make a code change, and then refresh the browser and see that change. However - if there's a compiler error at any point, it never recovers. So if I make a code change that's bogus (but don't realize it) and then save my changes, I have to kill the dev server and start over.
    r
    • 2
    • 12
  • o

    Omar Mainegra

    07/23/2020, 7:47 PM
    Hi everyone, I'm having issues with
    kotlin.Number
    :
    Cannot read property 'prototype' of undefined
    This is the code (generated JS):
    BigDecimal.prototype = Object.create(Number_0.prototype)
    And
    Number_0
    :
    var Number_0 = Kotlin.kotlin.Number;
    t
    r
    • 3
    • 87
  • r

    Robert Jaros

    07/24/2020, 7:58 PM
    What's the best way to report a bug in the IR compiler backend? Is the exception stack trace enough to report to YT?
    s
    • 2
    • 3
  • r

    Robert Jaros

    07/25/2020, 10:52 AM
    Why is "Both-mode" (https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-4-m1-released/#both-mode) better then publishing two different versions of a library (e.g.
    1.0.0
    and
    1.0.0-IR
    ) and just let users choose the one they want to use? In my opinion "both-mode" makes a lot of mess for a Kotlin/JS project (e.g. strange module names).
    h
    b
    i
    • 4
    • 24
  • t

    Theo

    07/25/2020, 2:13 PM
    I'm struggling to find a good example of adding a
    nodejs
    target to my existing iOS/Android mpp setup and building a node package to use, the official docs don't seem to cover it, anyone have any links or pointers?
    b
    a
    • 3
    • 12
  • a

    andylamax

    07/26/2020, 5:23 PM
    Same explanation is found here:https://github.com/JetBrains/kotlin-wrappers/issues/321 Hello all, anyone knows how to use
    kotlin-styled
    for animations?
    keyframe animations
    per se? When I do
    animation(duration = 0.5.s) {
      0 {
        top = 50.vh
      }  
    
      00 {
        top = 0.vh  
      }
    }
    I get this in the console
    react-dom.development.js:22665 Uncaught Error: It seems you are interpolating a keyframe declaration (lbMCNJ) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\`\` helper which ensures the styles are injected correctly
    t
    • 2
    • 3
  • w

    Wajahat Karim

    07/26/2020, 7:23 PM
    Hey Folksً, I am stuck in a problem with Kotlin Multiplatform in Kotlin JS. Is anyone here who has worked on Kotlin JS or frontend dev in Kotlin?
    a
    • 2
    • 1
  • s

    Siddhartha Juluru

    07/26/2020, 10:35 PM
    Does anyone know how to implement a npm dev dependency? I know that in the legacy kotlin-frontend plugin you would use devDependency() but I don't know what it has changed to.
    t
    s
    • 3
    • 2
  • b

    Brandon Saunders

    07/27/2020, 11:21 AM
    Hi here, question about code splitting. We have a scenario where we're loading some kotlin produced JS in a multiplatform project on machine that reloads the js file and has issues with super low memory. That's less important, just context. To that end having the giant JS file caused issues, so we broke it up by defining optimization.splitChunk values in our webpack file. All good, it's split up. But now I'm confused what the right way to enter into those files is. Normally I'd have an index.js file for exporting items and use that as my entry point, defining it as entry in the webpack and as main in the package.json, but we don't have that (or at least don't have that currently) with our Kotlin project. What is the correct setup for defining the entry in a chunked Kotlin project?
    t
    • 2
    • 14
  • b

    Big Chungus

    07/27/2020, 7:02 PM
    Getting the following error for all
    org.w3c.dom
    stdlib package when using BOTH compiler mode on
    1.4.0-rc
    . Does anyone know a fix?
    scratch.txt
    i
    • 2
    • 8
  • b

    Big Chungus

    07/27/2020, 7:55 PM
    Is anyone getting
    Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$DuplicateTaskException: Cannot add task 'clean' as a task with that name already exists.
    when specifying js flavour with 1.4.0-rc?
    t
    • 2
    • 15
  • v

    Vlad

    07/28/2020, 12:32 PM
    Any reason this happens on JS
    suspend fun networkCall(): Int {
        delay(100)
        return Random.nextInt(0,100)
    }
    
    GlobalScope.launch {
        val s1 = async { networkCall() }
        val s2 = async { networkCall() }
        val s3 = async { networkCall() }
        val s4 = async { networkCall() }
        println("${s1.await()} ${s2.await()} ${s3.await()} ${s4.await()}")
    }
    output is always same of one value doesn't matter what network call returns
    7 7 7 7
    But this one is fine
    GlobalScope.launch {
        val s1 = async { networkCall() }
        val s2 = async { networkCall() }
        val s3 = async { networkCall() }
        val s4 = async { networkCall() }
    
        val s1a = s1.await()
        val s2a = s2.await()
        val s3a = s3.await()
        val s4a = s4.await()
        
        println("$s1a $s2a $s3a $s4a")
    }
    First one works fine on JVM
    g
    a
    +2
    • 5
    • 14
  • a

    andylamax

    07/28/2020, 7:34 PM
    Webcomponent's with kotlin/js is a pain. Mostly coz extending HTMLElement requires you to implement a bunch of methods, some of them from interfaces with external optional methods and implementation. Code looks like so and that is just boiler plate.
    class TestElement : HTMLElement() {
        override val childElementCount: Int
            get() = TODO("Not yet implemented")
        override val children: HTMLCollection
            get() = TODO("Not yet implemented")
        override var contentEditable: String
            get() = TODO("Not yet implemented")
            set(value) {}
        override val isContentEditable: Boolean
            get() = TODO("Not yet implemented")
        override val style: CSSStyleDeclaration
            get() = TODO("Not yet implemented")
    
        override fun after(vararg nodes: dynamic) {
            TODO("Not yet implemented")
        }
    
        override fun append(vararg nodes: dynamic) {
            TODO("Not yet implemented")
        }
    
        override fun before(vararg nodes: dynamic) {
            TODO("Not yet implemented")
        }
    
        override fun convertPointFromNode(point: DOMPointInit, from: dynamic, options: ConvertCoordinateOptions): DOMPoint {
            TODO("Not yet implemented")
        }
    
        override fun convertQuadFromNode(quad: dynamic, from: dynamic, options: ConvertCoordinateOptions): DOMQuad {
            TODO("Not yet implemented")
        }
    
        override fun convertRectFromNode(rect: DOMRectReadOnly, from: dynamic, options: ConvertCoordinateOptions): DOMQuad {
            TODO("Not yet implemented")
        }
    
        override fun getBoxQuads(options: BoxQuadOptions): Array<DOMQuad> {
            TODO("Not yet implemented")
        }
    
        override fun prepend(vararg nodes: dynamic) {
            TODO("Not yet implemented")
        }
    
        override fun querySelector(selectors: String): Element? {
            TODO("Not yet implemented")
        }
    
        override fun querySelectorAll(selectors: String): NodeList {
            TODO("Not yet implemented")
        }
    
        override fun remove() {
            TODO("Not yet implemented")
        }
    
        override fun replaceWith(vararg nodes: dynamic) {
            TODO("Not yet implemented")
        }
    }
    Can't the HTMLElement class be declared to show that these methods are already implemented externally?
    b
    t
    i
    • 4
    • 8
  • f

    frank

    07/29/2020, 6:58 AM
    There are samples projects of new lib: Kotlinx-nodejs?
    t
    l
    b
    • 4
    • 7
  • d

    Darren Bell

    07/29/2020, 11:27 AM
    Hi I am having issues with the latest RC version and WebPack. I am receiving the error:
    Uncaught ReferenceError: React is not defined
    When I look at the package.json that is produced, the appropriate package "react" is present in there. And in the browser it "look like" the package is loaded there also. I'm also using the new IR compilation
    t
    i
    • 3
    • 18
Powered by Linen
Title
d

Darren Bell

07/29/2020, 11:27 AM
Hi I am having issues with the latest RC version and WebPack. I am receiving the error:
Uncaught ReferenceError: React is not defined
When I look at the package.json that is produced, the appropriate package "react" is present in there. And in the browser it "look like" the package is loaded there also. I'm also using the new IR compilation
t

turansky

07/29/2020, 11:38 AM
Do you use distribution?
d

Darren Bell

07/29/2020, 12:05 PM
@turansky Excuse my ignorance. I dont follow what you are asking. I can supply my build.gradle.kts if that helps
t

turansky

07/29/2020, 12:11 PM
If you need independent js - use dist from
build/distributions
d

Darren Bell

07/29/2020, 12:20 PM
I think I follow now. I am actually getting this error when I run the
jsBrowserDevelopmentRun
gradle task
i

Ilya Goncharov [JB]

07/29/2020, 2:26 PM
Could you please provide your build script?
d

Darren Bell

07/29/2020, 2:27 PM
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack

plugins {
    kotlin("multiplatform") version "1.4.0-rc"
    kotlin("plugin.serialization") version "1.4.0-rc"

    id("io.quarkus") version "1.6.0.Final"
    id("org.jetbrains.kotlin.plugin.allopen") version "1.3.41"
    id("com.adarshr.test-logger") version "2.0.0"
    id("io.gitlab.arturbosch.detekt") version "1.10.0"
    id("com.github.jk1.dependency-license-report") version "1.13"
}
group = "com.nanthealth"
version = "1.0-SNAPSHOT"

val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project
val quarkusPluginVersion: String by project
val kotlinVersion: String by project
val kotlinxVersion: String by project
val kotinResultVersion: String by project
val kotlinxCoroutinesTestVersion: String by project

val kotlinJsExtensionsVersion = "1.0.1-pre.109-kotlin-1.4.0-rc" // M3?
val kotlinReactVersion = "16.13.1-pre.109-kotlin-1.4.0-rc"
val kotlinReactDomVersion = "16.13.1-pre.109-kotlin-1.4.0-rc"
val kotlinReactRouterDomVersion = "5.1.2-pre.109-kotlin-1.4.0-rc"
val kotlinReduxVersion = "4.0.0-pre.109-kotlin-1.4.0-rc"
val kotlinReactReduxVersion = "5.0.7-pre.109-kotlin-1.4.0-rc"
val kotlinCssVersion = "1.0.0-pre.109-kotlin-1.4.0-rc"
val ktorVersion = "1.3.2-1.4.0-rc"
val kotlinJsSerializationVersion = "1.0-M1-1.4.0-rc"
val kotlinReactMdwcVersion = "1.0.0-SNAPSHOTX"
val kotlinxCoroutinesCoreVersion = "1.3.8-1.4.0-rc"
val klockVersion = "2.0.0-alpha-1.4.0-rc"
val kotlinxHtmlJvmVersion = "0.7.1-1.4.0-rc"
val kotlinJacksonModuleVersion = "2.11.0"

val restAssuredVersion = "4.3.1"
val assertjCoreVersion = "3.16.1"
val slf4jTestVersion = "1.0.0"

repositories {
    mavenCentral()
    jcenter()
    maven {
        url = uri("<https://dl.bintray.com/kotlin/ktor>")
    }
    maven {
        url = uri("<https://dl.bintray.com/kotlin/kotlin-eap>")
    }
    maven {
        url = uri("<https://dl.bintray.com/kotlin/kotlin-js-wrappers>")
    }
    maven {
        url = uri("<https://dl.bintray.com/michaelbull/maven>")
    }
    maven {
        url = uri("<https://gitlab.com/api/v4/groups/zsinz-kotlin/-/packages/maven>")
        name = "GitLab"
    }
    maven("<https://dl.bintray.com/kotlin/kotlin-eap>")
}

configurations.forEach { it.exclude("javax.annotation", "javax.annotation-api") }

kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "11"
        }
        withJava()
    }
    js(IR) {
        useCommonJs()
        nodejs {}
        browser {
            binaries.executable()
            webpackTask {
                cssSupport.enabled = true
            }
            runTask {
                cssSupport.enabled = true
                devServer = devServer?.copy(
                    port = 8081
                )
            }
            testTask {
                useKarma {
                    useChromeHeadless()
                    webpackConfig.cssSupport.enabled = true
                }
            }
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))

                implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlinJsSerializationVersion")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val jvmMain by getting {
            dependencies {
                implementation(kotlin("stdlib-jdk8"))
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesCoreVersion")

                implementation(
                    project.dependencies.enforcedPlatform(
                        "$quarkusPlatformGroupId:$quarkusPlatformArtifactId:$quarkusPlatformVersion"
                    ))
                implementation("io.quarkus:quarkus-resteasy:$quarkusPlatformVersion")
                implementation("io.quarkus:quarkus-resteasy-jackson:$quarkusPlatformVersion")
                implementation("io.quarkus:quarkus-resteasy-mutiny:$quarkusPlatformVersion")
                implementation("io.quarkus:quarkus-kotlin:$quarkusPlatformVersion")
                implementation("io.quarkus:quarkus-smallrye-health:$quarkusPlatformVersion")
                implementation("io.quarkus:quarkus-logging-json:$quarkusPlatformVersion")
                implementation("io.quarkus:quarkus-jackson:$quarkusPlatformVersion")
                implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$kotlinJacksonModuleVersion")
                implementation("com.michael-bull.kotlin-result:kotlin-result:$kotinResultVersion")

                implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:$kotlinxHtmlJvmVersion")
            }
        }
        val jvmTest by getting {
            dependencies {
                implementation("io.quarkus:quarkus-junit5:$quarkusPlatformVersion")
                implementation("io.rest-assured:rest-assured:$restAssuredVersion")

                implementation("org.assertj:assertj-core:$assertjCoreVersion")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesTestVersion")
                implementation("uk.org.lidalia:slf4j-test:$slf4jTestVersion")

                implementation(kotlin("test"))

                implementation(kotlin("test-junit"))
            }
        }
        val jsMain by getting {
            dependencies {
                implementation(npm("core-js", "3.2.1"))
                implementation(kotlin("stdlib-js"))
                implementation(
                    "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlinJsSerializationVersion"
                )
                implementation("org.jetbrains:kotlin-extensions:$kotlinJsExtensionsVersion")
                implementation("org.jetbrains:kotlin-react:$kotlinReactVersion")

                implementation("org.jetbrains:kotlin-react-dom:$kotlinReactDomVersion")
                implementation("org.jetbrains:kotlin-redux:$kotlinReduxVersion")
                implementation("org.jetbrains:kotlin-react-redux:$kotlinReactReduxVersion")
                implementation("org.jetbrains:kotlin-react-router-dom:$kotlinReactRouterDomVersion")
                implementation("org.jetbrains:kotlin-css:$kotlinCssVersion")
                implementation("org.jetbrains:kotlin-styled:$kotlinCssVersion")

                implementation("com.soywiz.korlibs.klock:klock-js:$klockVersion")
                implementation("com.zsinz:kotlin-react-mdwc:$kotlinReactMdwcVersion")

                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-js:$ktorVersion")
                implementation("io.ktor:ktor-client-json-js:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization-js:$ktorVersion")
                implementation("io.ktor:ktor-client-auth-basic-js:$ktorVersion")

                implementation(npm("css-loader", "3.4.2"))

                implementation(npm("react", "16.13.1"))
                implementation(npm("react-dom", "16.13.1"))
                implementation(npm("react-router-dom", "5.2.0"))
                implementation(npm("redux", "4.0.5"))
                implementation(npm("react-redux", "7.2.0"))

                implementation(npm("react-is", "16.13.1"))
                implementation(npm("inline-style-prefixer", "5.1.0"))
                implementation(npm("css-in-js-utils", "3.0.4"))
                implementation(npm("style-loader", "1.1.3"))
                implementation(npm("styled-components", "5.0.0"))
                implementation(npm("material-components-web", "3.2.0"))
                implementation(npm("rmwc", "5.7.1"))
            }
        }
        val jsTest by getting {
            dependencies {
                implementation(kotlin("test-js"))
            }
        }
    }
}

tasks {
    "test"(Test::class) {
        useJUnitPlatform()
    }
}

allOpen {
    annotation("javax.ws.rs.Path")
    annotation("javax.enterprise.context.ApplicationScoped")
    annotation("io.quarkus.test.junit.QuarkusTest")
}

quarkus {
    setSourceDir("$projectDir/src/jvmMain/kotlin")
    setOutputDirectory("$projectDir/build/classes/kotlin/jvm/main")
}

detekt {
    toolVersion = "1.10.0"
    buildUponDefaultConfig = true
}

tasks {
    quarkusDev {
        setSourceDir("$projectDir/src/jvmMain/kotlin")
    }
}

tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack") {
    destinationDirectory =
        File("$projectDir/build/classes/kotlin/jvm/main/META-INF/resources") // Allow the javascript to be accessible
    outputFileName = "kotlin-multiplatform-quarkus.js"
}

tasks.getByName<Jar>("jvmJar") {
    dependsOn(tasks.getByName("jsBrowserProductionWebpack"))
    val jsBrowserProductionWebpack = tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack")
    from(File(jsBrowserProductionWebpack.destinationDirectory, jsBrowserProductionWebpack.outputFileName))

    doLast {
        copy {
            from("$projectDir/src/jsMain/resources")
            into("$projectDir/build/classes/kotlin/jvm/main/META-INF/resources")
        }
    }
}
And the properties:
kotlin.code.style=official

kotlin.js.experimental.generateKotlinExternals=false

kotlinVersion=1.4.0-rc
kotlinxVersion=1.3.7-1.4.0-rc
slf4jVersion=1.7.25

kotlinxCoroutinesTestVersion=1.3.8-1.4.0-rc
kotinResultVersion=1.1.4
quarkusPlatformArtifactId=quarkus-universe-bom
quarkusPlatformGroupId=io.quarkus
quarkusPlatformVersion=1.6.1.Final
i

Ilya Goncharov [JB]

07/29/2020, 3:04 PM
Did you try with 1.4-M3 version? And if yes, did you have such problems?
d

Darren Bell

07/29/2020, 3:44 PM
Well it did work fine for M3. But I hadnt changed it to IR in that version
i

Ilya Goncharov [JB]

07/29/2020, 3:56 PM
Could you please tell, do you overwrite
webpack
configuration in
webpack.config.d
? Could you please send
build/reports/webpack
?
And if possible, if you change something in
webpack.config.d
folders, point what do you change?
d

Darren Bell

07/29/2020, 4:05 PM
I dont change anything. The only change I make is to the port of the devServer
{
  mode: 'development',
  resolve: {
    modules: [
      'node_modules'
    ]
  },
  plugins: [
    ProgressPlugin {
      profile: false,
      handler: [Function: handler],
      modulesCount: 500,
      showEntries: false,
      showModules: true,
      showActiveModules: true
    },
    TeamCityErrorPlugin {}
  ],
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          'source-map-loader'
        ],
        enforce: 'pre'
      },
      {
        test: /\.css$/,
        use: [
          {
            loader: 'style-loader',
            options: {}
          },
          {
            loader: 'css-loader',
            options: {}
          }
        ]
      }
    ]
  },
  entry: {
    main: [
      'C:\\Dev\\play\\kotlin\\kotlin-multiplatform-quarkus\\build\\js\\packages\\kotlin-multiplatform-quarkus\\kotlin\\kotlin-multiplatform-quarkus.js'
    ]
  },
  output: {
    path: 'C:\\Dev\\play\\kotlin\\kotlin-multiplatform-quarkus\\build\\distributions',
    filename: [Function: filename],
    library: 'kotlin-multiplatform-quarkus',
    libraryTarget: 'umd'
  },
  devtool: 'eval-source-map',
  stats: {
    warningsFilter: [
      /Failed to parse source map/
    ],
    warnings: false,
    errors: false
  },
  devServer: {
    inline: true,
    lazy: false,
    noInfo: true,
    open: true,
    overlay: false,
    port: 8081,
    contentBase: [
      'C:\\Dev\\play\\kotlin\\kotlin-multiplatform-quarkus\\build\\processedResources\\js\\main'
    ]
  }
}
@Ilya Goncharov [JB] you can find the full project here: https://gitlab.com/zsinz-kotlin/kotlin-multiplatform-quarkus
:tnx: 1
i

Ilya Goncharov [JB]

07/29/2020, 4:31 PM
Ok, thank you I see problem in generated JavaScript file
26 var ChangeEvent = React.ChangeEvent;
But
React
was not declared, I am trying to find root cause cc @bashor @anton.bannykh
Seems that it is root cause, I believe it should be
@file:JsModule("react")
instead of
JsQualifier
https://gitlab.com/zsinz-kotlin/kotlin-react-mdwc/-/blob/master/src/main/kotlin/com/zsinz/kotlin/react/mdwc/types/react_types.kt Did you use
dukat
for getting these external declarations?
➕ 1
d

Darren Bell

07/29/2020, 9:34 PM
Hi. I have had these bindings around for a while. I think from memory, I maybe used dukat (in its infancy) to give me a start. But in the end I had issues, so had to hand crank. I havent looked at dukat again since. I'll try the change you are suggesting and report back. Thanks
i

Ilya Goncharov [JB]

07/30/2020, 7:50 AM
Additionally you possibly need to remove
CONFLICTING_OVERLOADS
in external declarations, and then remove the duplicated declarations, and everything should be ok
d

Darren Bell

07/30/2020, 10:38 AM
@Ilya Goncharov [JB] I have made the change you suggested with success. You help was very much needed and appreciated. I have committed the changes. I did have some other issues that I came across: • I have issues with using my own RState interface, I seemed to be give me a cast error. I worked around that by using the functionalComponent paradigm, which I was wanting to do anyway • jsStyle was also giving me cast error. I just removed them as I didnt really need them Again thanks for all of the help. Maybe others may want to use the react enabled material design components.
View count: 13