https://kotlinlang.org logo
Docs
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

    SOFe

    02/24/2019, 8:12 AM
    especially the bintray repositories, gradle dependencies outdated all the time
    ➕ 3
    s
    t
    +2
    6 replies · 5 participants
  • j

    jw

    02/25/2019, 8:28 PM
    does anyone else see their bundles failing to include dependencies? all i get is the contents of the module and no deps. I upgraded to Gradle 5.2, Kotlin 1.3.21, and frontend 0.45.0 at the same time so still narrowing in on the cause...
    g
    d
    +1
    5 replies · 4 participants
  • g

    GarouDan

    02/26/2019, 1:24 AM
    Hi guys, I was trying to configure the tasks
    compileKotlin2Js
    and
    compileTestKotlin2Js
    . But since I’m not using the
    id("kotlin2js")
    plugin but
    kotlin("multiplatform")
    I’m receiving an error saying that the tasks don’t exist. Does someone knows how to properly configure these tasks when applying the
    kotlin("multiplatform")
    plugin?
    j
    1 reply · 2 participants
  • j

    josephivie

    02/26/2019, 3:53 AM
    When using the Kotlin Frontend plugin, I got this:
    A problem was found with the configuration of task ':koolui-test-js:webpack-bundle'.
    > File '/.../koolui-test-js/build/classes/kotlin/main/koolui-test-js.js' specified for property 'sourceFile' does not exist.
    The file most certainly exists, I've checked it and read it. It's complete. Any ideas?
    a
    2 replies · 2 participants
  • j

    jw

    02/27/2019, 1:39 PM
    I'm adapting https://developer.chrome.com/apps/runtime which has functions that take arguments (
    getUrl
    ), functions which take async callbacks (
    getBackgroundPage
    ), and functions which perform actions (
    reload()
    ). But then it has this
    getManifest()
    function which takes no arguments, isn't async with a callback, and isn't performing some kind of action. Were I encapsulating this in a class, I would do
    val manifest: Json get() = delegate.getManifest()
    to expose it as a property. This is an external interface though so I'm forced into
    fun getManifest()
    s
    s
    6 replies · 3 participants
  • g

    GarouDan

    02/27/2019, 2:00 PM
    Guys, I’m trying to run a mpp project with javascript and react. My build is going ok but when I open the browser (where the webpack dev server pointed to me) I’m receiving the following error in the console:
    Uncaught Error: Error loading module 'common'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'common'.
    I could see that in my
    main.bundle.js
    generated file, indeed the
    "./common.js"
    is being required earlier than the
    "./kotlin.js"
    module. I tried to change the dependencies order in my
    build.gradle.kts
    file but it didn’t solve the problem. Does someone knows how can we fix this?
    s
    9 replies · 2 participants
  • j

    jw

    02/27/2019, 2:02 PM
    what module type are you using? the javascript plugin has a(n arguably terrible) default of 'plain' instead of something more appropriate like 'umd'
    g
    u
    4 replies · 3 participants
  • j

    JoakimForslund

    02/27/2019, 2:28 PM
    Having some issues with trying to apply
    task assembleWeb(type: Sync) {
        println(configurations)
        configurations.commonMainCompileOnly.each { File file ->
            from(zipTree(file.absolutePath), {
                includeEmptyDirs = false
                include { fileTreeElement ->
                    def path = fileTreeElement.path
                    path.endsWith(".js") && (path.startsWith("META-INF/resources/") ||
                            !path.startsWith("META-INF/"))
                }
            })
        }
        from compileKotlin2Js.destinationDir
        into "${projectDir}/web"
    
        dependsOn classes
    }
    
    assemble.dependsOn assembleWeb
    on a multiplatform project. Since im not using
    kotlin2js
    but the multiplatform plugin i'm receiving:
    Could not get unknown property 'compileKotlin2Js' for task ':assembleWeb' of type org.gradle.api.tasks.Sync.
    Anyone has any idea how to solve it?
    r
    6 replies · 2 participants
  • r

    Robert Jaros

    03/01/2019, 12:08 PM
    Anyone knows what kind of checks the compiler performs with "js" function (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/js.html#js)? I'm experimenting and keep getting "JavaScript: syntax error" at compile time.
    a
    s
    +1
    28 replies · 4 participants
  • j

    JoakimForslund

    03/01/2019, 12:40 PM
    How come
    state
    in this code would show as
    state_v23xwe$_0
    in javascript?
    @Serializable
    data class StateAware(@JsName("id") val id: String = hashCode().toString(), @JsName("test")val test: String = "Tested") {
    
        @JsName("state")
        var state: Int = Initilized
            set(value) {
                println("Item with id:$id -> Old State: '${this.state}' | New State: '$value' has been set")
                field = value
                stateAwareContainer.sync(this)
            }
    }
    a
    r
    +1
    8 replies · 4 participants
  • g

    galex

    03/01/2019, 6:47 PM
    Do we have a common place to share kotlin wrappers for js modules from NPM?
    s
    j
    +2
    8 replies · 5 participants
  • t

    thana

    03/04/2019, 7:31 AM
    im struggeling with both parts "all" and "transitive" 😉 i cannot get all dependencies, because i have a multi-module-project and i cannot make gradle to move the js-artefact of a dependency like
    implementation project(":otherModule")
    into the destination folder. and i have noo clue how to get the dependencies transitivley...
    g
    7 replies · 2 participants
  • s

    Svyatoslav Kuzmich [JB]

    03/04/2019, 2:21 PM
    Lets talk about magic
    fun js(code: String): dynamic
    function. [https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/js.html#js] It allows you to embed JavaScript code to Kotlin. Its one of those features which is super simple to use in most cases but becomes quite complex when specifying what it does in general. It has some problems. It implicitly links Kotlin declarations with names used inside JavaScript snippet, and can become an effective tool to shoot yourself in a foot. For most interop needs safer constructs like external declarations and dynamic expressions can be used instead. It is also a tough feature to maintain: it requires a whole JavaScript parser to be included and parser result integrated with compiler data structures. Switching parsers can be hard. Supporting multiple ES versions only adds to complexity. We are considering various options to redesign it in future releases to make it “less powerful”. We would like to hear your input to make sure we got you covered with a smooth transition: Do you use
    js
    function a lot? What for? Are they big? What constructs do you put inside?
    t
    j
    +9
    27 replies · 12 participants
  • d

    d.bellingroth

    03/05/2019, 7:40 AM
    Hello. I'm planning to share some Code between Backend (Kotlin/JVM, Gradle) and Frontend (Existing Javascript Application, NPM + webpack). I thought using the kotlin multiplatform capabilities to build a library that works on both platforms was a good catch for this problem. I just created a multiplatform gradle-project from IntelliJ and it builds for alle three platforms. But the output for the javascript target is a jar file with the compiled javascript code embedded. I'd like to use the generated javascript code in my existing webapp. Is there any way to configure gradle to output just a commonjs or umd module that I can directly require via webpack? Thanks a lot!
    g
    a
    5 replies · 3 participants
  • j

    JoakimForslund

    03/06/2019, 1:20 PM
    Are there any guides how to create a npm library out of a generated xxx.bundle.js generated from the kotlin frontend plugin?
    a
    8 replies · 2 participants
  • a

    altavir

    03/06/2019, 2:52 PM
    seems to be https://github.com/Kotlin/kotlin-frontend-plugin/issues/46
    a
    g
    38 replies · 3 participants
  • a

    Alexander Weickmann

    03/07/2019, 5:02 PM
    How to configure kotlin-dce-js using the Kotlin Gradle DSL? I can only find examples for Groovy and cannot figure out the Kotlin variant: https://kotlinlang.org/docs/reference/javascript-dce.html#development-mode
    g
    5 replies · 2 participants
  • a

    altavir

    03/08/2019, 7:19 AM
    This is the best I came up with so far
    JS_property_update.kt
    s
    r
    7 replies · 3 participants
  • j

    JoakimForslund

    03/08/2019, 10:04 AM
    Question: Using the kotlin.js add a lot of extra size to a library built with kotlin. Is there any way to remove that dependency or at least make sure it takes as little as possible? Don't think uglifyjs is gonna cut it
    s
    a
    7 replies · 3 participants
  • a

    Alexander Weickmann

    03/08/2019, 3:18 PM
    Using react-dom-wrapper, is there a way to insert HTML from a String variable into the dom? like this: https://stackoverflow.com/questions/23616226/insert-html-with-react-variable-statements-jsx
    1 reply · 1 participant
  • p

    pardom

    03/08/2019, 7:44 PM
    This works.
    Untitled.swift
    d
    1 reply · 2 participants
  • g

    GarouDan

    03/09/2019, 12:45 AM
    Hello buddies, I’m using
    id("org.jetbrains.kotlin.frontend")
    plugin to configure my
    kotlin-react
    application with webpack. But I’ve seen if my module has also the name
    react
    the system incurs in problems. Does someone knows an workaround for this? Without changing the module name?
    a
    3 replies · 2 participants
  • r

    Robert Jaros

    03/09/2019, 1:41 AM
    Anyone seeing problems with
    kotlin-frontend-plugin
    0.0.45 and
    kotlin
    1.3.21 when stopping background karma task?
    > Task :karma-stop FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':karma-stop'.
    > kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)[B
    It works correct when
    ./gradlew stop
    command is run for the second time but fails almost always for the first time.
    a
    2 replies · 2 participants
  • a

    altavir

    03/09/2019, 8:26 AM
    Another question about integrating Three.js. I found a very useful JS object in the library, but the problem is that it is not present in the final
    min.js
    module. For JS people recommend to do it like that: https://stackoverflow.com/questions/46362627/use-convexgeometry-in-npm-version-of-three. Is it possible to do it in kotlin-js?
    s
    t
    9 replies · 3 participants
  • j

    Jared

    03/11/2019, 6:35 PM
    Is it possible to use JS/TS files alongside Kotlin files in a Kotlin react app? I am interested in using Kotlin for my frontend react app but I am hesitant to jump into it since I might be giving up the ability to use community written libraries?
    r
    1 reply · 2 participants
  • r

    Robert Jaros

    03/11/2019, 7:06 PM
    Hello all, I am trying to collect your opinions. Do you think there is a sense in using the web workers in Kotlin/JS, with Kotlin coroutines at your disposal?
    s
    g
    +1
    6 replies · 4 participants
  • y

    ylemoigne

    03/12/2019, 2:57 PM
    Hello, I'm trying to translate
    window.customElements.define('app-drawer', class extends HTMLElement {})
    in kolin. I've tried
    window.customElements.define("app-drawer", { js("class extends HTMLElement {}")})
    , but it seems that the compiler try to analyse the
    js("...")
    content and don't understand the declaration.
    r
    6 replies · 2 participants
  • g

    gumil

    03/13/2019, 9:36 AM
    Is there a gradle plugin to run and generate html/xml test reports for multiplatform javascript?
    g
    9 replies · 2 participants
  • t

    thana

    03/13/2019, 9:47 AM
    yes, there is. thank tou 😄
    2 replies · 1 participant
  • r

    Robert Jaros

    03/13/2019, 11:36 AM
    Let's assume I would like to use a predictable state container in Kotlin/JS. There is a bunch of Kotlin projects, which port JS code (mainly Redux) to Kotlin, but all of them are targeting JVM. So what should I do - port one of these projects back to Kotlin/JS or create Kotlin bindings for original Redux? Any other ideas?
    t
    4 replies · 2 participants
Powered by Linen
Title
r

Robert Jaros

03/13/2019, 11:36 AM
Let's assume I would like to use a predictable state container in Kotlin/JS. There is a bunch of Kotlin projects, which port JS code (mainly Redux) to Kotlin, but all of them are targeting JVM. So what should I do - port one of these projects back to Kotlin/JS or create Kotlin bindings for original Redux? Any other ideas?
t

tapchicoma

03/13/2019, 12:11 PM
mm, https://github.com/freeletics/coredux - I want to migrate to multiplatform and add a JS support as next step. If approach in library suites you.
r

Robert Jaros

03/13/2019, 12:26 PM
A simple example would be useful. The pagination example in the sample directory seems quite complicated to me (I know very little about android development 😉)
t

tapchicoma

03/13/2019, 12:27 PM
Sure, one of the goals would be made multiplatform sample that does the same and has CoRedux in common module
r

Robert Jaros

03/13/2019, 12:29 PM
Looking forward for JS support 🙂
👍 1
View count: 2