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

    Ivan Đorđević

    03/14/2023, 1:32 PM
    Is there a way to make Kotlin/JS useful (and not have to create wrappers for all suspend functions for example) with the IR compiler? Is there an experimental toggle/feature somehow that would make them work with
    @JsExport
    or generate promises out of them automatically?
    t
    r
    • 3
    • 4
  • w

    Wardell

    03/14/2023, 8:30 PM
    Is it yet possible to easily include Kotlin code inside of a JS/TS project and have everything just work? Specifically one that doesn't use Gradle but just uses Webpack (or a different bundler) directory? I'd love to have a way to just have a directory full of Kotlin code, point Webpack at it, and get back a bundled JS file with a Typescript declaration file next to it.
    b
    • 2
    • 2
  • d

    Dmitriy Malayev

    03/16/2023, 8:47 PM
    Hello I'm trying to use import mui.material.RadioGroup and would like to hide and show a section like a Box based on if it's yes or no. How do I do that?
  • r

    rocketraman

    03/16/2023, 9:06 PM
    [SOLVED] I have a test in
    commonTest
    that does
    TimeZone.of("US/Eastern")
    . This test fails in karma/browser with
    Uncaught IllegalTimeZoneException: DateTimeException: unsupported ZoneId
    . This appears to be a limitation of the headless execution environment, but I'm not sure. Any way to avoid this?
    • 1
    • 2
  • m

    Michal Janos

    03/17/2023, 10:07 AM
    Hi, I trying move project to IR, but I have issue with 'reflection'
    internal actual fun Any.getFieldValue(fieldName: String): Any? {
        val thisDynamic: dynamic = this
        return thisDynamic[fieldName]
    }
    this works well on LEGACY, but on IR it return undefined. I try to play with that and
    thisDynamic[fieldName+"_1"]
    return right value, but I don't think this is safe solution. This is any class, where I want to find value by string. Is there any idea how to do it in IR?
    r
    • 2
    • 3
  • l

    louiscad

    03/17/2023, 4:11 PM
    Hello,
    print(0.0.toString())
    prints
    0.0
    on the JVM, but
    0
    on JS. Is there an alternative to
    toString()
    to get
    0.0
    on JS as well?
    e
    • 2
    • 3
  • s

    spierce7

    03/17/2023, 5:13 PM
    Is anyone else seeing this issue? of not being able to download nodejs?
    #13 100.6 FAILURE: Build failed with an exception.
    #13 100.6 
    #13 100.6 * What went wrong:
    #13 100.6 Could not determine the dependencies of task ':kotlinNodeJsSetup'.
    #13 100.6 > Could not resolve all files for configuration ':detachedConfiguration1'.
    #13 100.6    > Could not resolve org.nodejs:node:16.13.0.
    #13 100.6      Required by:
    #13 100.6          project :
    #13 100.6       > Could not resolve org.nodejs:node:16.13.0.
    #13 100.6          > Could not get resource '<https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.gz>'.
    #13 100.6             > Could not HEAD '<https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.gz>'. Received status code 403 from server: Forbidden
    #13 100.6 
    #13 100.6 * Try:
    #13 100.6 > Run with --info or --debug option to get more log output.
    #13 100.6 > Run with --scan to get full insights.
    #13 100.6 
    #13 100.6 * Exception is:
    #13 100.6 org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task ':kotlinNodeJsSetup'.
    #13 100.6 	at
    t
    e
    a
    • 4
    • 9
  • s

    spierce7

    03/17/2023, 5:15 PM
    our CI pipeline is stuck because of this now
  • k

    kubele

    03/18/2023, 8:29 AM
    Hi, I'm struggling with deploy my Kotlin/JS app to Heroku. I follow this official tutorial, but the
    heroku-buildpack-static
    is deprecated now and the guide they provide works for already running applications. Have you encountered this issue?
    • 1
    • 1
  • s

    Sam Garfinkel

    03/18/2023, 4:11 PM
    Is there anyway to manually refine the type that the typescript declaration generator emits? For instance, I am working on a multi platform template engine and would like to emit type declarations for the input in typescript as
    T extends string | Record<string, T>
    which provides a little more information than just, what in Kotlin, has to be a
    Map<String, Any>
    t
    • 2
    • 2
  • s

    Seth Madison

    03/19/2023, 2:25 AM
    I wish there was a way to define an external interface that conforms to a normal interface. It feels like it could be done with an annotation or something that you put on a normal interface that tells the compiler not to expect getters.
    t
    • 2
    • 9
  • c

    Claude Brisson

    03/19/2023, 8:00 PM
    Hi. I still don't get how to generate a .js file to include in a web page using basic <script> tags. Some web pages talk about a browserProductionWebpack gradle task, but I don't see it in my kotlin js project. I am not using node.js on the server side, and not willing to. I'm just stuck on the very simple task of getting my kotlin code compiled into a .js file, and I don't seem to find any relevant resource online, which I find quite frightening...
    r
    t
    • 3
    • 3
  • i

    Ilia Tochilin

    03/20/2023, 1:01 PM
    Hi, as far as I know there’s no description of which compilers are deprecated or what versions of Kotlin are supported. For example, I want to use command-line compiler, as I understand it is kotlinc or kotlin compiler embeddable, kotlinc seems to support IR, but there’s an open youtrack issue where it’s clear that it doesn’t work, does anyone have an overview of every possible way of using Kotlin/Js and probably plans on getting rid of something ?
    c
    • 2
    • 7
  • r

    rocketraman

    03/20/2023, 7:47 PM
    I'm trying to use https://github.com/midzer/tobii in my kotlin/js project. However, I'm having problems initializing the library. Right now I'm getting
    Uncaught TypeError: components_lightbox_TobiiModule_h0nwsu.Tobii is not a function
    -- I'm trying to call the default function defined here: https://github.com/midzer/tobii/blob/production/src/js/index.js#L16. I've tried a couple of different approaches to import the module, code in 🧵.
    t
    b
    • 3
    • 56
  • m

    Mihai Voicescu

    03/21/2023, 6:52 PM
    Did anybody manage to make exporting an interface with enums as either Typescript Union or Enum (so that a Kotlin API project can be shared with a Typescript project)? Note that it has to survive serialization and deserialization... For example, given the following JSON:
    { 
      "gender": "male"
      "age": 24
    }
    To be in Typescript:
    enum Gender {
    Male = "male",
    Female = "female"
    }
    
    interface Person {
    gender: Gender
    age: number
    }
    And in Kotlin:
    enum class Gender {
    @SerialName("male")
    Male,
    @SerialName("female")
    Female
    }
    
    interface Person {
    gender: Gender
    age: number
    }
    Note that I am using Kotlin Multiplatform
    c
    • 2
    • 1
  • c

    Christian H.

    03/22/2023, 7:30 AM
    Hello 👋 I have a project based on https://kotlinlang.org/docs/multiplatform-full-stack-app.html changed kotlin version to 1.8.0 with IR compiler Currently I am working on the JS part but can't debug, because errors are shown in the minimized JS file. Using InteliJ JS Debugger doesn't help. Do you have any tips on how to identify the source of the problem? Like where source maps should be located so I can validate they are generated? Or any settings that need to be done? Thank you very much in advance!
    • 1
    • 1
  • c

    CLOVIS

    03/22/2023, 1:48 PM
    I'm getting a regression when migrating from 1.7.20 to 1.8.10, it this already known?
    e: java.lang.IllegalStateException: IdSignature clash: opensavvy.decouple.core/UIMetadata.initializeFor$composable|-575774612970147389[0]; Existed declaration FUN IR_EXTERNAL_DECLARATION_STUB name:initializeFor$composable visibility:public modality:ABSTRACT <> ($this:opensavvy.decouple.core.UIMetadata, content:kotlin.Function2<androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit>, $composer:androidx.compose.runtime.Composer?, $changed:<http://kotlin.Int|kotlin.Int>) returnType:kotlin.Unit clashed with new FUN IR_EXTERNAL_DECLARATION_STUB name:initializeFor$composable visibility:public modality:ABSTRACT <> ($this:opensavvy.decouple.core.UIMetadata, content:kotlin.Function2<androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit>, $composer:androidx.compose.runtime.Composer?, $changed:<http://kotlin.Int|kotlin.Int>) returnType:kotlin.Unit
    l
    • 2
    • 13
  • x

    xxfast

    03/22/2023, 10:19 PM
    Hi all. Fairly new to kotlin js. So don't mind me if this question doesn't make sense 😅 I want to provide different implmentations for
    browser
    and
    nodejs
    . Are we able to have a seperate source set for js browser and js node, so that any consumer of my library be able chose one or the other depending on their setup?
    js("browser", IR) {
      browser()
    }
    
    js("node", IR) {
      nodejs()
    }
    
    // browser project
    js(IR){
      browser()
    }
    
    jsMain by getting {
      dependencies {
        implementation(project(":myLibrary")) // gets sources from :myLibrary:browserMain
      }
    }
    
    // node project
    js(IR){
      nodejs()
    }
    
    jsMain by getting {
      dependencies {
        implementation(project(":myLibrary"))  // gets sources from :myLibrary:nodeMain
      }
    }
    e
    a
    • 3
    • 9
  • r

    rocketraman

    03/23/2023, 3:27 AM
    Has anyone got a Gradle solution for uploading source maps to sentry.io? Looks like in production mode the source maps are inlined using base64, but Sentry just shows references to the minified javascript. So not even the manual upload of source maps using the Sentry CLI appears to be working.
    • 1
    • 1
  • x

    xxfast

    03/23/2023, 7:46 PM
    Got this vulnerability picked up by sonatype-lift, currently set against webpack 5.74.0. I'm guessing there's nothing I can do on my side as this is coming from kotlin-js tooling?
    t
    • 2
    • 2
  • k

    Kalalau Cantrell

    03/24/2023, 1:22 PM
    Hey all, new to KMP and exploring the feasibility of creating a shared lib that can be used across iOS, Android, and web (TS + React). My specific question is how are people working around the limitation where
    kotlin.collections.List
    can’t be exported with
    @JsExport
    ? With my limited experience in KMP, see below for something I’ve cobbled together that’s been working but it does not seem ideal. For instance, converting to and from
    List
    and having to create wrappers for every collection type takes away from the dream of writing business logic once at a high level and reusing it across platforms. Does anyone have advice for doing this in perhaps a more generic way? Has anyone found a way to use
    expect / actual
    as a better solution?
    @ExperimentalJsExport
    @JsExport
    class PeopleList : MutableList<StarWarsPerson> by mutableListOf() {
        fun toArray(): Array<StarWarsPerson> {
            val array = emptyArray<StarWarsPerson>()
            this.forEachIndexed { index, person ->
                array[index] = person
            }
            return array
        }
    
        companion object {
            fun fromArray(people: Array<StarWarsPerson>): PeopleList {
                val peopleList = PeopleList()
                peopleList.addAll(people)
                return peopleList
            }
        }
    }
    
    @ExperimentalJsExport
    @JsExport
    data class StarWarsPerson(val name: String
    b
    g
    • 3
    • 5
  • p

    Paul Dhaliwal

    03/25/2023, 2:49 PM
    Is it possible for a kotlin/js multi-project to output both “whole-program” and “per-module”? I would like to achieve the following:
    module-core
    -> whole program: single JS file that includes things like stdlib, kotlinx-serialization, etc…
    module-a
    , which depends on
    module-core
    -> “per-module”: single JS file for
    module-a
    , and an additional JS file for
    module-core
    , with the
    module-a.js
    file correctly depending on
    module-core.js
    (which itself includes stdlib, kotlinx-serialization etc…)
  • c

    Cru

    03/26/2023, 2:51 PM
    Hi everyone. I want to learn VueJS. But, I want to learn it while using kotlin (instead of javascript). How can I set up my hello world application?
    b
    m
    • 3
    • 2
  • j

    Jilles van Gurp

    03/27/2023, 11:41 AM
    Getting this uninformative / unactionable error since 1.8. Also tried 1.8.20-RC2. I disabled all our webpack configuration overrides and it doesn't seem to matter. It seems to not like one of our files but since it is not telling me which one, I have nothing to go on. jsBrowserDevelopmentRun seems to work fine, jsBrowserProductionRun, jsBrowserWebpack, jsBrowserProductionWebpack all fail with this.
    16 actionable tasks: 5 executed, 11 up-to-date
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':jsBrowserProductionWebpack'.
    > Module parse failed: Unterminated regular expression (144:33)
      You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
      |       Companion_getInstance_3();
      |       var tmp1_div = 1000000.0;
      >       tmp$ret$0 = tmp0_div.if() / tmp1_div;
      |       tmp$ret$1 = new Pair(Unit_getInstance(), tmp$ret$0);
      |       tmp$ret$2 = tmp$ret$1.m4_1;
      
      Module parse failed: Unterminated regular expression (341:33)
      You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
      |       // Inline function 'kotlin.Long.div' call
      |       var tmp0_div = roundToLong(latitude * 1000000);
      >       tmp$ret$0 = tmp0_div.if() / 1000000.0;
      |       roundedLat = tmp$ret$0;
      |       var tmp$ret$1;
    p
    • 2
    • 3
  • m

    Mike Dawson

    03/27/2023, 4:24 PM
    As I understand from this bug - https://youtrack.jetbrains.com/issue/KT-43500 - it seems like IR Javascript compilation fails when dealing with any compileOnly dependency. Now that the Legacy compiler is deprecated, this would mean that compileOnly dependencies cannot be used for Javascript at all. That seems very unfortunate.
    b
    • 2
    • 36
  • l

    louiscad

    03/27/2023, 4:51 PM
    Hello, am I the first one to realize that in Kotlin/JS,
    addAll
    in
    MutableList
    is extremely slow compared to just using a
    forEach
    +
    add
    ? https://youtrack.jetbrains.com/issue/KT-57607/MutableList.addAll-has-UNACCEPTABLE-performance-on-Kotlin-JS-legacy-IR
  • j

    Jilles van Gurp

    03/28/2023, 3:06 AM
    Related to the error I posted earlier, I've been digging around and narrowed down the problem a bit. It appears webpack is failing on the js code generated by the kotlin compiler with a bit misleading error. It actually displays the bit of code it crashes on. I traced that back to one of my own libraries. I fixed the bit of code and then I got a similar error back that I traced back to a bit of code from the koin library that does some things with nano timestamps that involve dividing by some large double number. ``````
    e
    • 2
    • 13
  • f

    franztesca

    03/28/2023, 8:42 AM
    I'm trying to compile a Kotlin/JS library that should be used by both browser and node target. This is my gradle js configuration:
    js {
            binaries.library()
            browser {
                distribution {
                    directory = File("$projectDir/js_output/browser/")
                }
            }
            nodejs {
                distribution {
                    directory = File("$projectDir/js_output/node/")
                }
            }
        }
    My goal is to compile the browser version to the output folder
    js_output/browser
    and the node one to
    js_output/node
    . However this doesn't work, because apparently the Kotlin target is shared between node and browser, therefore setting the distribution in the
    nodejs
    block overrides the one of
    browser
    , and thus both are always compiled to the same distribution directory (
    js_output/node
    ). I use the
    jsNodeProductionLibraryDistribution
    and
    jsBrowserProductionLibraryDistribution
    tasks to create the production library distributions. This is actually a KMP project. Any hints on how to do this properly?
  • a

    alec

    03/28/2023, 1:23 PM
    I have a build reporting that the yarn lock file needs to be updated, but if I run it locally there are no changes. Conversely in a separate PR it goes green on CI, but if I run the same build locally it asks me to update the yarn lock. This makes me think the actual output of the yarn lock file is different locally vs CI in my setup - wondering if anyone has run into this or if anyone has any ideas as to why this is happening?
    d
    a
    a
    • 4
    • 6
  • m

    Mike Dawson

    03/29/2023, 8:06 AM
    Has anyone tried using the new react router wrapper with the legacy compiler? It compiles, but if I used "Component" in createRouter, I got an error saying no Component or element specified. Now that I have switched to IR, the problem goes away. I think whilst the legacy compiler is deprecated, but not removed, if its not supported it should provide some kind of compiler error or something in the README.
    t
    • 2
    • 4
Powered by Linen
Title
m

Mike Dawson

03/29/2023, 8:06 AM
Has anyone tried using the new react router wrapper with the legacy compiler? It compiles, but if I used "Component" in createRouter, I got an error saying no Component or element specified. Now that I have switched to IR, the problem goes away. I think whilst the legacy compiler is deprecated, but not removed, if its not supported it should provide some kind of compiler error or something in the README.
t

turansky

03/29/2023, 8:09 AM
Breaking change already described Now we support IR only
m

Mike Dawson

03/29/2023, 8:10 AM
Great - I had tried using 522 and 511 (the version that I saw at the time that was used in the MUI showcase)
Hi @turansky - there is a contradictory description on the front page README: https://github.com/JetBrains/kotlin-wrappers#experimental-ir-backend "Experimental IR Backend" - not experimental anymore... mandatory now...
Maybe this should be changed to note that only the IR compiler is supported?
View count: 2