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
  • f

    frank

    06/10/2020, 8:29 PM
    I have added
    kotlin-react
    libs manually in my html but it can't find
    module
    variable in the React libs.
    <script type="text/javascript" src="lib/kotlin/kotlin.js"> </script>
    <script type="text/javascript" src="lib/kotlin/kotlinx-html-js.js"></script>
    <script type="text/javascript" src="lib/kotlin/kotlin-wrappers-kotlin-react-jsLegacy.js"></script>
    <script type="text/javascript" src="lib/kotlin/kotlin-wrappers-kotlin-react-dom-jsLegacy.js"></script>
    <script type="text/javascript" src="js/webapp.js"></script>
    ReferenceError: module is not defined  kotlin-wrappers-kotlin-react-jsLegacy.js:845:1
    
    ReferenceError: module is not defined kotlin-wrappers-kotlin-react-dom-jsLegacy.js:2472:1
    My steps: 1. Copy js libs of Gradle local repo into my Project 2. Import js libs in my html Suggestions how to import Kotlin/JS libs?
    t
    j
    • 3
    • 21
  • d

    dazza5000

    06/10/2020, 10:42 PM
    how do you all typically use
    data
    classes when integrating with existing javascript projects?
    t
    r
    • 3
    • 13
  • a

    aerb

    06/14/2020, 12:45 AM
    Is it possible to configure KotlinJS to compile to multiple js files instead of one big one?
    :yes: 1
    🇳🇴 1
    t
    j
    +7
    • 10
    • 38
  • b

    Big Chungus

    06/14/2020, 4:08 PM
    message has been deleted
    t
    h
    • 3
    • 38
  • s

    Subroh Nishikori

    06/14/2020, 5:05 PM
    Hi! I would like to view the React Component created by Kotlin/JS in Storybook. But it seems impossible to get a specific Component from the JS generated by
    browserDevelopmentWebpack
    and load it into the Storybook. Also, a file simply transpiled to JS will cause great difficulty in resolving library dependencies for `kotlin-wrappers`(Because the npm module distribution has stopped since pre.91😭) Do you have any good ideas about this?
    t
    • 2
    • 4
  • b

    Big Chungus

    06/14/2020, 6:49 PM
    Not sure if this is the best place to ask, but does anyone know what this TS snippet does?
    const elm = vnode.elm = oldVnode.elm!
    t
    d
    n
    • 4
    • 16
  • j

    janvladimirmostert

    06/14/2020, 8:56 PM
    what is the best route to go when you need to build a kotlinJS project that's consumed by a TypeScript project? I've enabled IR mode which generates TypeScript headers, i've `npm link`ed it so that my TypeScript project can consume it but it's not in a module format that a node + typescript project can easily consume
    js(IR) {
            browser {
                dceTask {
                    keep(
                         ...
                    )
                }
                binaries.executable()
            }
        }
    Locally this project seems to be using ES6 modules
    import ChatMessageList from './chat-message-list';
    When i auto import Kotlin classes, it does this
    import ApplicationState = module_name.com.domain.ApplicationState;
    this compiles, but does not work when i run the html file with the generated JS i can see the generated KotlinJS in the Parceble js output, but it seems the KotlinJS is using a different module system or something, i'm not very familiar with TypeScript and NPM yet
    d
    • 2
    • 2
  • j

    janvladimirmostert

    06/14/2020, 9:14 PM
    if i comment out
    binaries.executable()
    , what happens with the generated JS files? All i'm seeing is a
    package.json
    and
    package.json.hash
    where there used to be a js file
    t
    • 2
    • 2
  • s

    Sean Najera

    06/15/2020, 1:36 AM
    Are Kotlin/JS react apps supported in Android Studio? When I follow the JB tutorial https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/01_Introduction and run Gradle task 
    browserDevelopmentRun
     I get the following error
    org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager$ResolutionState$Installed cannot be cast to org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager$ResolutionState$Configuring
    But when using IntelliJ, the task runs fine.
    t
    • 2
    • 2
  • h

    Hannes Tenter

    06/15/2020, 9:23 AM
    Hey guys, javascript module n00b here. I tried to use react-tracked (https://github.com/dai-shi/react-tracked) but I'm getting "Uncaught TypeError: $module$react_tracked is not a function" so I'm guessing there's sth wrong but I don't know what 😞 Anyone able to just include this npm dependency in his project? Without me giving what I tried already, what should the external declarations look like for example to use the createContainer function https://github.com/dai-shi/react-tracked/blob/master/src/index.js ?
    i
    h
    • 3
    • 3
  • j

    janvladimirmostert

    06/15/2020, 11:23 AM
    currently the generated TypeScript look something like this
    declare namespace blah {
        type Nullable<T> = T | null | undefined
        namespace com.blah {
    is there a way to make it export the namespace like this?
    export declare namespace blah {
        type Nullable<T> = T | null | undefined
        namespace com.blah {
    i
    • 2
    • 2
  • g

    GarouDan

    06/16/2020, 4:59 PM
    Hi, Do you know how can we
    publish
    a kotlin mpp library (the js part) to
    npm
    ? I’d like js npm users consume and use my library as well. Please let me know if you have an example or a project configuration that I could use.
    c
    • 2
    • 2
  • d

    Danilo Herrera

    06/16/2020, 10:36 PM
    Hello beautiful people! Not sure if this is the best place to ask, but I've figured out how to run an application continuously so that the code changes automatically reflect on the browser, and on the JVM side I've managed to get a Ktor project to autoreload so that the code changes propagate without needing to rebuild. However, I am exploring a multi-platform project with a JS client and JVM server, but cannot seem to figure out how to get continuous/autoreload functionality. Has anyone figured this out or know if it's possible?
    t
    a
    +3
    • 6
    • 14
  • p

    Patrick

    06/17/2020, 1:51 PM
    How can I access str.prototype.normalize using Kotlin/JS?
    a
    t
    • 3
    • 17
  • f

    fkrauthan

    06/17/2020, 8:59 PM
    Quick question when I build a kotlinjs project and include a external dependency (for example from NPM) does kotlinjs compiler support tree shaking or will it always include the full external dependency in the final generated code?
    r
    t
    +3
    • 6
    • 11
  • t

    Tristan MARIE

    06/18/2020, 5:19 PM
    hi, i'm trying to use kotlin-react, but the hot-reload keeps crashing when I save while having a syntax error, it builds but nothing gets refreshed on the browser and I must terminate the gradle task and launch it again to see the changes, anyone has a fix ?
    r
    • 2
    • 2
  • d

    Dima Avdeev

    06/19/2020, 6:54 AM
    Hello There are runBlocking and runBlockingTest builders in the "jvmTest" sourceSet. Is it possible to write Unit tests using suspend functions in "jsTest"? If yes - please give a link to examples? If not - is planned in future? Thanks!
    s
    a
    • 3
    • 7
  • a

    Alexander Minyaev

    06/19/2020, 7:07 PM
    Hi! Does kotlin-js support for example IE 11 ? I have error with Promise ('Promise' is undefined) in it. + I'am using coroutines.
    r
    • 2
    • 3
  • p

    Pavel Petkevich

    06/20/2020, 9:56 AM
    Hello guys, Hopefully, I’m using the right channel 😄 A few weeks ago, I decided to create my own portfolio website using “kotlin-js” and “ktor”, nevertheless I faced with a problem: ----------------------------------- Project structure: :buildSrc - for dependencies :client - for the views of the websites(pages, extensions and so on) :server - server based on ktor for redirecting on the web. ----------------------------------- Problem description: Without the :server module we can run our website using this shell command:
    ./gradlew :client:run --continuous
    and it will run continuously our website on the localhost. (works fine). But my target is to run it from the server module, usign this shell command:
    ./gradlew :server:run --continuous
    and it runs perfectly but not presenting the page…. ----------------------------------- Possible solution: I would say that I know the root cause: It happens because the server module has no access to the pregenerated file -
    "build/distributions/client.js"
    . Also I’m trying to copy it with this code in `build.gradle.kts(:server)`:
    val processResources by tasks.existing(ProcessResources::class)
    processResources {
      from(project(":client").tasks.getByName("browserProductionWebpack").path)
    //  dependsOn(project(":client").tasks.getByName("browserProductionWebpack")) - also doesn't work...
    }
    In case someone already faced with this kind of problem, maybe you can help me to figure out the best solution. 😄 Thank you in advance 😄
    t
    j
    i
    • 4
    • 15
  • c

    CLOVIS

    06/20/2020, 1:48 PM
    Hi, I currently have the following code:
    import org.w3c.files.Blob
    import org.w3c.files.File
    
    val data: Blob = ...
    File(
        Array<Blob>(1) {data},
        "image.png"
    )
    This is in jsTest of a Multiplatform project. The IDE doesn't have a problem with it, nor does Gradle. When I run it, I get:
    ReferenceError: File is not defined
    The generated JS code in
    build/
    looks like:
    new File(array, 'image.png')
    where
    array
    is generated with a normal
    for
    loop. The IDE does link it with what appears to me as the correct definition, in a TypeScript file. I'm running Chromium 83, and according to https://caniuse.com/#feat=fileapi it is supported. Sorry if that's something dumb or obvious, I'm new to the JS world and I'm completely lost as to what could cause this, especially since the error message doesn't hint toward anything. The File constructor is even defined in the Kotlin standard library for JS: https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-file/-init-.html
    t
    • 2
    • 2
  • a

    Alexander Minyaev

    06/22/2020, 8:52 AM
    Hello! How to insert text with HTML tags into
    RComponent
    (
    RBuilder
    )? Details in thread.
    s
    t
    • 3
    • 7
  • z

    zeugederunity

    06/22/2020, 12:35 PM
    Hello everyone, i'm developing a react application with KotlinJS and after adding the react-dom-route dependency i got the following error in the browser console:
    Uncaught TypeError: Cannot read property 'slash' of undefined
        at eval (kotlin-react-router-dom.js:10)
        at eval (kotlin-react-router-dom.js:276)
        at Object.../../packages_imported/kotlin-react-router-dom/0.0.0/kotlin-react-router-dom.js (firmensuche.js:987)
        at __webpack_require__ (firmensuche.js:30)
        at eval (firmensuche.js:3)
        at eval (firmensuche.js:8)
        at Object../kotlin/firmensuche.js (firmensuche.js:1399)
        at __webpack_require__ (firmensuche.js:30)
        at Object.0 (firmensuche.js:1411)
        at __webpack_require__ (firmensuche.js:30)
    I'm quite new to JS & React in general, so i don't really know why this property isn't defined. (My best guess is that it has something to do with incompartible versions,) My Dependencies in the gradle.kts are:
    val react_version = "16.13.1"
    val react_router_version = "5.1.2"
    val kotlin_react_version = "16.13.1-pre.105-kotlin-1.3.72"
    val kotlin_react_router_dom = "5.1.2-pre.109-kotlin-1.3.72"
    
    implementation(npm("react",react_version))
    implementation(npm("react-dom",react_version))
    implementation(npm("react-is",react_version))
    implementation(npm("react-router-dom",react_router_version))
    
    implementation("org.jetbrains:kotlin-react:$kotlin_react_version")
    implementation("org.jetbrains:kotlin-react-dom:$kotlin_react_version")
    implementation("org.jetbrains:kotlin-react-router-dom:$kotlin_react_router_dom")
    Does anyone of you know how to fix that error? Thank you in advance!
    ✔️ 1
    t
    • 2
    • 3
  • r

    Robert Jaros

    06/22/2020, 4:07 PM
    Is there any possibility to configure
    karma-kotlin-reporter
    ? I've replaced
    mocha
    with
    qunit
    and everything works fine, but reports are written in files with
    >
    character in filenames. It works on Linux but doesn't work on Windows.
    t
    • 2
    • 2
  • z

    zeugederunity

    06/23/2020, 7:51 AM
    Hello everyone, how can i style a navlink from kotlin-react-router-dom with kotlin-styled? (I found a JS-example, but i don't know how to apply it with kotlin) Here the example: https://codesandbox.io/s/34z5152z1q?file=/index.js:232-239
    • 1
    • 1
  • a

    Antonios Barotsis

    06/23/2020, 7:27 PM
    I also seem to have another issue, this code
    val discord = require("discord.js");
    val client = discord.Client()
    compiles to this
    var discord = require('discord.js');
    var client = discord.Client();
    which gives me an error because it should instead be
    var discord = require('discord.js');
    var client = new discord.Client();
    How do I invoke ``new`` seeing as how its not a kotlin keyword? Edit: Im not sure if this has something to do with the way I imported the package, this is the require function, I did not make any external classes
    external fun require(module: String): dynamic
    a
    • 2
    • 10
  • a

    Antonios Barotsis

    06/24/2020, 8:53 PM
    Hello again! I am working on the same stuff I was working on yesterday and Im now trying to bind an event to an external class. The javascript code I would use to react to the event is this:
    client.on(('ready'), msg => { // do stuff here })
    How can I define this event in my external class and how do I then use it?
    a
    a
    • 3
    • 4
  • p

    PHondogo

    06/24/2020, 9:16 PM
    Hello! How to skip obfuscation in production JS generated code?
    t
    i
    • 3
    • 6
  • j

    Jeff

    06/26/2020, 8:01 AM
    Hey guys. I get this error running my web app. What could be the issue? Android and server work fine. 
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':kotlinNpmInstall'.
    > org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager$ResolutionState$Installed cannot be cast to org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager$ResolutionState$Configuring
    m
    f
    • 3
    • 6
  • z

    zeugederunity

    06/26/2020, 12:19 PM
    Greetings everyone, i have a question regarding Kotlin-React and websockets. In plain React it is (according to my research) common to instantiate a single WebSocket instance at the root of your application and then pass it down via props. But is there an alternative (Edit: idiomatic) way to share this single instance in Kotlin React? Like using a top level declaration or an object handling that connection? Thank you for your answers in advance!
    ✔️ 1
    a
    • 2
    • 2
  • n

    Nikky

    06/27/2020, 10:39 AM
    when i updated my multiplatform project to
    1.4-M2
    to make use of better dce in js, the
    jsBrowserProductionWebpack
    task disappeared i use it to copy from
    build/distributions
    into the shadowJar resources which task would replace that ? PS: i also do nto see the webpack run tasks and dce tasks that should be there, but gradle does nto log any obvious errors
    t
    • 2
    • 3
Powered by Linen
Title
n

Nikky

06/27/2020, 10:39 AM
when i updated my multiplatform project to
1.4-M2
to make use of better dce in js, the
jsBrowserProductionWebpack
task disappeared i use it to copy from
build/distributions
into the shadowJar resources which task would replace that ? PS: i also do nto see the webpack run tasks and dce tasks that should be there, but gradle does nto log any obvious errors
t

turansky

06/27/2020, 11:10 AM
binaries.executable()
added?
n

Nikky

06/27/2020, 11:15 AM
where would i add that?
thaks that gets me further now i notice i cannot update past 104 for the kotlin-wrappers because https://github.com/cfnz/muirwik/issues/29 for now i guess i will add it as a submodule and see if i can port it
View count: 2