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

    xxfast

    06/11/2021, 3:20 AM
    Hi all - is there a way to get the browser name and version from
    jsMain
    ?
    r
    • 2
    • 2
  • x

    xxfast

    06/12/2021, 2:48 AM
    Hi all. this question might not be 100% kotlin, but a question of interop between kotlin and typescript in my kotlin-js module, i have a package say
    com.organisation.product.core
    which has this kotlin class
    @JSExport
    class Service()
    once exported with
    npm-publish
    - when importing this from a typescript project it looks like
    import {com} from "@organisation/core";
    const Service = com.organisation.product.core.Service;
    This kinda woks, but when you have another module (for example,
    com.organisation.product.feature
    ) they both end up sharing the
    com
    import {com} from "@organisation/core";
    import {com} from "@organisation/feature"; // not allowed
    I know you can get around this with alias like
    import {au as core} from "@organisation/core";
    import {au as feature} from "@organisation/feature";
    
    const Service = core.organisation.product.core.Service;
    const FeatureService = login.organisation.product.feature.Service;
    Is there a way to make these imports much nicer without losing my package structure from kotlin side?
    e
    r
    t
    • 4
    • 6
  • g

    Grantas33

    06/13/2021, 8:19 AM
    Hi. Is there a way to generate a separate JS file from a single Kotlin file with the Kotlin js gradle plugin (without making a separate gradle module)?
    b
    • 2
    • 1
  • a

    Ayfri

    06/13/2021, 9:51 PM
    Kotlin support Node.js and npm libraries ok ? But when Deno ? :cheers:
    b
    n
    n
    • 4
    • 13
  • f

    Franco

    06/15/2021, 1:02 AM
    Hey everyone, we are trying to create a wrapper for the
    Prompt
    component in React Router and we can't get it to work. This is the code we have:
    @file:JsModule("react-router-dom")
    @file:JsNonModule
    package react.router.dom
    
    import react.Component
    import react.RProps
    import react.RState
    import react.ReactElement
    
    @JsName("Prompt")
    internal external class Prompt : Component<PromptProps, RState> {
        override fun render(): ReactElement?
    }
    
    internal external interface PromptProps : RProps {
    
        var `when`: Boolean
    
        var message: String
    
    }
    This is the wrapper function we created:
    public fun RBuilder.prompt(show: Boolean, message: String): ReactElement {
        return child(Prompt::class) {
            attrs.`when` = show
            attrs.message = message
        }
    }
    And this is how we are calling it inside the
    render()
    of another component:
    prompt(show = true, message = "ERROR")
    Anyone knows what we are doing wrong?
    🤔 1
    t
    • 2
    • 8
  • a

    andylamax

    06/16/2021, 3:43 AM
    for some reasons.
    kotlin {
      browser {}
      nodejs {}
    }
    seems more intuitive and inline with KMM than
    kotlin {
      js {
        browser()
        nodejs()
      }
    }
    The former unlocks • hierarchical source sets between javascript targets • Easier gradle resolutions for browser or node specific • Intrinsically adding
    kotlinx-browser
    and
    kotlinx-node
    depedencies
    ➕ 4
    c
    h
    • 3
    • 5
  • n

    Nikky

    06/16/2021, 10:03 AM
    this error showed up when i upgraded our webapp to kotlin 1.5.10
    Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (9:0)
    File was processed with these loaders:
     * ../../node_modules/source-map-loader/dist/cjs.js
    You may need an additional loader to handle the result of these loaders.
    |  *
    |  */
    > export { FluentBundle } from "./bundle.js";
    | export { FluentResource } from "./resource.js";
    | export { FluentType, FluentNone, FluentNumber, FluentDateTime } from "./types.js";
      SyntaxError: Unexpected token ')'
      at C:/Users/nikky/AppData/Local/Temp/_karma_webpack_600784/runtime.js:1:0
    i guess this is because webpack was updated, but i am completely clueless how to go about fixing this
    i
    b
    • 3
    • 8
  • s

    Slackbot

    06/17/2021, 7:35 AM
    This message was deleted.
    s
    j
    s
    • 4
    • 4
  • s

    Scott Wilson-Billing

    06/17/2021, 7:43 AM
    My company is looking to see if react kotlin/js is a viable alternative to react/js. we built a demonstrator using react and tailwind and now the challenge is to convert to react kotlin/js. I seem to have run into a bit of a problem quite early on and I'm looking for some help please.
    b
    • 2
    • 86
  • n

    Nikky

    06/17/2021, 12:38 PM
    how do other people do tests that involve suspending functions? in my karma test which i run in a
    GlobalScope.launch
    i see no log output at all if i use
    promise
    see all logs in a single line.. but the assertion seem to work.. somewhat
    c
    r
    • 3
    • 5
  • r

    Robert Munro

    06/18/2021, 9:47 AM
    I am trying to figure out what the correct way to use innerHTML - have tried using
    dangerouslySetInnerHTML
    setState{
        itemDescription = props.video.description
            ?.let { webLink.replaceLinks(it) }
            ?.replace("\n", "<br/>")
            ?: ""
    }
    styledDiv {
        attrs["dangerouslySetInnerHTML"] = state.itemDescription
    }
    but i dont seem to be able to do:
    attrs{
        dangerouslySetInnerHTML = state.itemDescription
    }
    b
    • 2
    • 3
  • h

    hfhbd

    06/18/2021, 7:36 PM
    How can you use the multiplatform plugin with a js target on alpine linux (docker dind)? I always get:
    Cannot run program "/root/.gradle/nodejs/node-v14.15.4-linux-x64/bin/node"
    b
    c
    • 3
    • 4
  • p

    peekandpoke

    06/21/2021, 11:00 AM
    Hello! Is there a way to disable minification for production builds. It seems that the source-maps are broken when the code is minified. Or is there a good guide on how to setup a kotlinjs production build with sourcemaps and all. By the way we are using Kotlin 1.5.10.
    b
    r
    • 3
    • 6
  • h

    hfhbd

    06/23/2021, 2:47 PM
    Hey, I want to publish a JS IR library to a npm registry. This works with
    npm-publish
    from Martynas Petušk! But if I consume the library, Typescript complaints about
    kotlin.js not found
    .
    b
    • 2
    • 7
  • a

    ankushg

    06/24/2021, 4:31 PM
    Hey all! Cool to see the JS IR Migration guide that was published as part of 1.5.20 A big issue for us in doing this migration is that our JS project is part of a Kotlin Multiplatform codebase. The guide recommends using `external interface`s, but many places we would need to do this to are located @indahc
    commonMain
    because they're also used by iOS and JVM targets. Any planned solutions or workarounds for this? Maybe moving
    external
    into Common, but making it a no-op for non-JS targets?
    a
    b
    • 3
    • 5
  • p

    Pitel

    06/25/2021, 1:30 PM
    Can ytou recommend some localization library? Preferablyu something framework-independent (but I'm using fritz)
    t
    h
    n
    • 4
    • 4
  • t

    Tyrel Haveman

    06/28/2021, 8:44 PM
    There's an example in the docs here about creating a Base64 encoder in Kotlin/JS. I was using this in my product, but after upgrading to Kotlin 1.5.0+ it no longer works. The code
    js("Buffer")
    outputs into the JavaScript console:
    Uncaught ReferenceError: Buffer is not defined
    https://kotlinlang.org/docs/multiplatform-library.html#js First of all, perhaps that example needs updated? Second, how can I resolve this in my product?
    e
    t
    • 3
    • 10
  • b

    Big Chungus

    06/28/2021, 10:16 PM
    Does anyone know where this HTML5 xsd was extracted from? (or where I could get a proper xsd for HTML5, google wasn't fruitful at all)
    ➕ 2
    t
    v
    e
    • 4
    • 8
  • d

    darkmoon_uk

    06/29/2021, 2:45 PM
    I need to build a Weak-Valued cache for my KMP project; including Kotlin/JS, so I need weak references on each platform. WeakReference is explicitly implemented for Kotlin/Native, to complement the existing JVM one. But I don't see any equivalent support for Kotlin/JS, even though JavaScript does provide a WeakRef. Is there a way to make this usable from Kotlin? Thanks. I'm experienced in KMP/KMM (`expect`/`actual`), but new to JavaScript interop.
    e
    • 2
    • 2
  • a

    Akram Bensalem

    06/29/2021, 5:11 PM
    I'm new in web development for that reason I want to ask experts here For you what is more preferable use Kotlin with React as FrontEnd or use Kvision ?
    a
    n
    +2
    • 5
    • 4
  • g

    gmazzo

    06/30/2021, 8:56 AM
    Hi there! Quick questions. We have a multiplatform project with
    JS
    target that we just migrated from Kotlin
    1.4
    to
    1.5.20
    . As now
    IR
    is the default backend, we need to annotate those key classes with
    JSExport
    to be able to see them on
    JavaScript
    exports. The problem is that we need access to some
    enum
    and
    interfaces
    too that seems it’s not exported anymore. Any advice on how to proceed here? I don’t know if there is any workaround for this or if
    enum
    and
    interfaces
    will be supported in the future 🤔
    r
    b
    • 3
    • 4
  • c

    CLOVIS

    06/30/2021, 1:03 PM
    I'd like to execute an
    npx
    command. I see that Kotlin/JS already bundles Yarn & co, is there a way to access it? SO recommends to use the Node-Gradle plugin, but that will install Node a second time, right?
    a
    • 2
    • 1
  • a

    Alexander Weickmann

    07/01/2021, 11:40 AM
    I have a KotlinJS project with a main function that starts my React.JS app. This main function loads when the .js file is loaded via script tag Is it possible to make it so that the app does not immediately initialize once the js file is loaded? I'd like to include the script tag to load the JS file and then at some time later initialize my react app on a button click But to do this I need to be able to call the KotlinJS main function (or any other function to start the app) from JavaScript manually ...
    t
    • 2
    • 7
  • n

    nschulzke

    07/01/2021, 7:18 PM
    I'm getting
    NoSuchElementException
    when I try to create an HttpClient with Kotlin/JS 1.5.2 with Ktor Client 1.6.1 (legacy compiler). According to this issue, this is a DCE problem: https://github.com/ktorio/ktor/issues/1731 When I get an error like this, how do I know which declarations need to be added to the DCE keep setting? I tried adding the one suggested in the above issue, but it didn't work:
    dceTask {
        keep("ktor-ktor-io.\$\$importsForInline\$\$.<http://ktor-ktor-io.io.ktor.utils.io|ktor-ktor-io.io.ktor.utils.io>")
    }
    t
    • 2
    • 1
  • c

    CLOVIS

    07/02/2021, 3:41 PM
    Is it normal that IntelliJ + live reload eats almost 10GB of RAM?
    a
    c
    • 3
    • 9
  • r

    Roman Vasilyev

    07/04/2021, 7:01 AM
    my current kotlin js always generates
    reactJs.js
    is it possible to change config to get
    reactJs.somerandomhash.js
    ?
    t
    • 2
    • 4
  • b

    Big Chungus

    07/06/2021, 1:04 AM
    Are there any BeforeAll and AfterAll test annotations in js? Kotlin-test-annotations-common doesn't seem to have anything to offer for those.
    👀 1
    r
    h
    c
    • 4
    • 10
  • s

    simon.vergauwen

    07/06/2021, 5:59 PM
    Hey everyone 👋 , Can anyone give me any advice with following error? I configured a
    useConfigDirectory
    pointing here: https://github.com/arrow-kt/arrow/blob/main/arrow-libs/karma/chrome_bin.js https://github.com/arrow-kt/arrow/blob/sv-js-fx-coroutines/arrow-libs/fx/arrow-fx-stm/build.gradle#L20
    Disconnected (0 times) , because no message in 30000 ms.
    java.lang.IllegalStateException: command '/Users/runner/.gradle/nodejs/node-v14.15.4-darwin-x64/bin/node' exited with errors (exit code: 1
    t
    i
    • 3
    • 8
  • r

    Robert Munro

    07/07/2021, 5:08 PM
    I have a project using muirwik that has started failing builds with the error:
    Error: Can't resolve '@material-ui/core/styles/createMuiTheme'
    The project has worked fine and no changes to the module on the weekend and i started another module for a website - but i rolled back to before i started deleted all build folders and still get the error? Just wondering if anyone has seen the error before?
    m
    • 2
    • 2
  • h

    Hampus Londögård

    07/08/2021, 11:23 AM
    Is it not possible to get the source map when using
    IR
    compiler? 🙂
    b
    t
    • 3
    • 13
Powered by Linen
Title
h

Hampus Londögård

07/08/2021, 11:23 AM
Is it not possible to get the source map when using
IR
compiler? 🙂
b

Big Chungus

07/08/2021, 11:24 AM
Nope, It's comming soon-ish, but not here just yet.
h

Hampus Londögård

07/08/2021, 11:25 AM
That's a shame. Any ETA?
b

Big Chungus

07/08/2021, 11:25 AM
What I normally do is develop in legacy mode and switch it back to IR on release. Works 90% of the time.
h

Hampus Londögård

07/08/2021, 11:25 AM
Ok, makes sense. Gonna validate that it works with fritz2 🙂
When I did a quick switch a while back I got some error that it didn't find "kotlinx-seralization-jsLegacy". Have you seen that?
b

Big Chungus

07/08/2021, 11:28 AM
It can happen depending on what libraries/versions you're using. Some of them do not publish in BOTH mode
t

turansky

07/08/2021, 11:36 AM
I call:
./gradlew clean
./gradlew --stop
before every switch Legacy <-> IR
h

Hampus Londögård

07/08/2021, 11:43 AM
@turansky you seem to have fixed my bug somehow, but Im not sure how I apply your fix correctly as it doesn't seem to work for me. See here https://github.com/turansky/kfc-plugins/blob/7e475092ea4617deaa46e558b56a5a1492cc2[…]n/kotlin/com/github/turansky/kfc/gradle/plugin/WebpackPlugin.kt How can I get this to work for me?
I'm using Kotlin 1.5.20, kotlinx-serialization=1.2.1
The problem at hand:
Module not found: Error: Can't resolve 'kotlinx-serialization-kotlinx-serialization-core-jsLegacy' in /path/to/file/dce
t

turansky

07/08/2021, 11:46 AM
Simplest solution - update other dependencies
Some of your dependencies use outdated
serialization
(not recommended for
1.5+
)
h

Hampus Londögård

07/08/2021, 11:48 AM
Oh, thanks. Must be fritz2, gonna try their snapshot
View count: 8