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

    Norbi

    09/28/2022, 7:29 PM
    Is this a valid
    filename
    in the generated
    webpack.config.evaluated.js
    ?
    output: {
        ...
        filename: [Function: filename],
        ...
      },
    I haven't configured file filename in my build, so it must be the default value. Thanks.
    d
    • 2
    • 2
  • n

    Norbi

    09/29/2022, 7:30 AM
    This is an excerpt from a Dukat-generated code:
    external interface KeycloakConfig {
        var url: String?
            get() = definedExternally
            set(value) = definedExternally
        var realm: String
        var clientId: String
    }
    Could you explain why the explicit get()/set() is needed in case of nullable properties? Thanks.
    t
    b
    • 3
    • 4
  • g

    georgi

    09/30/2022, 4:36 PM
    👋 Hey everyone! I have a multi-module KotlinJS setup and I've noticed that my root
    package.json
    file does not have a
    main
    entry point, while all my module `package.json`s do have corresponding entries for the main
    .js
    file. I'm aware we can customise these by doing something like the below, but that only changes the relevant module's
    package.json
    .
    js(IR) {
        compilations["main"].packageJson {
            customField(
                "dependencies", mapOf(
                    "a" to "b"
                )
            )
        }
    }
    Is there a way to modify the root
    package.json
    , i.e. the one that lives in
    build/js/package.json
    ? I basically want to add a
    main
    property pointing to my module entry point.
    b
    • 2
    • 52
  • e

    Eugene Maksymenko

    10/02/2022, 8:43 PM
    👋 Hello, team! Let me introduce WorldWind Kotlin - the first multi-platform planetary 3D globe library for JS, Android and JVM
    h
    • 2
    • 1
  • r

    Robert Munro

    10/03/2022, 12:49 PM
    heya, just wondering if there are any open source examples of websites using mui-kotlin? Something more complex then the examples/showcase - which are great but I am trying to get started but am having issue figuring out a full component example with props and state.
    t
    m
    • 3
    • 3
  • k

    Keith Miller

    10/04/2022, 5:52 PM
    Hello, I was wondering if there is a more fleshed out axios wrapper then the example given in the readme. Wanted to check before I start using it. Thanks!
    t
    • 2
    • 10
  • k

    Keith Miller

    10/05/2022, 4:15 AM
    Hey, another question about the MUI wrapper: any way to call
    responsivefontsizes
    for the theme?
    t
    • 2
    • 5
  • s

    Seth Madison

    10/05/2022, 5:33 AM
    Not sure if this will help anybody else, but I had a heck of a time getting babel to support
    import foo = x.y.z
    to deal with the long namespaces produced by JS IR (https://www.typescriptlang.org/docs/handbook/namespaces.html#aliases). It seems that babel added support for namespaces back in 7.15.0, but
    @babel/presets-typescript
    has not yet upgraded, so you need to pull in your own
    @babel/plugin-transform-typescript
    . I ended up with a config like this:
    return {
          presets,
          plugins,
          overrides: [
            // Note, preset-typescript does not have the latest version of plugin-transform-typescript
            // which includes support for import a = x.y.z (<https://github.com/babel/babel/pull/13528>)
            // so we just use plugin-transform-typescript directly, based on:
            // <https://github.com/babel/babel/blob/main/packages/babel-preset-typescript/src/index.ts>
            {
              test: /\.ts$/,
              plugins: [['@babel/plugin-transform-typescript', {}]],
            },
            {
              test: /\.tsx$/,
              plugins: [['@babel/plugin-transform-typescript', { isTSX: true }]],
            },
          ],
       }
  • r

    Robert Jaros

    10/05/2022, 2:12 PM
    KVision 5.16.0 is out https://github.com/rjaros/kvision/releases/tag/5.16.0
  • k

    Katarzyna

    10/06/2022, 8:38 AM
    Dear Kotlin/JS lovers, I am the manager of the self-publishing house. We are connected mainly with Kotlin. Our expert on this topic is Marcin Moskała. You could probably know him from conferences, workshops, and books: Kotlin Coroutines, Effective Kotlin, and Android Development with Kotlin. https://leanpub.com/u/mmoskala He is currently working on the book series Kotlin for Developers. It will contain 3 books: 1. Kotlin Essentials (in reviewing process) 2. Functional Kotlin (finished) 3. Advanced Kotlin (in draft) In the previous book - Functional Kotlin, Marcin decided to add a special chapter concerning the Arrow topic. The cooperation was really awesome. You are the experts on Kotlin/JS during many conferences and publications that is why we would like to encourage you to write a special chapter that will be published in Advanced Kotlin book about January 2023. What do you think? If you are interested let me know, please here in DM or contact via kasia@kt.academy. Regards:)
    g
    • 2
    • 2
  • h

    Hakon Grotte

    10/06/2022, 9:30 AM
    Hello! Using the React MUI wrapper, how can I override style of nested components with the
    sx
    prop?
    t
    • 2
    • 5
  • l

    Leon

    10/06/2022, 12:49 PM
    👋 Hello, team! I am a software engineer who have been dealing with mostly ReactJS for web frontend development. Nowadays I am implementing for integration of recharts library on KotlinJS. We could see recharts from npm or I pretty sure that you have seen so many usage examples of recharts on ReactJS applications so far. But I am struggling for doing it on KotlinJS. So I tried to find recharts wrapper for Kotlin, but one thing I have found is not working properly. Dear anyone can kindly help me regarding this one? I really would appreciate any advise or help. Below is just what I am working and stuck with… https://github.com/gm666q/kotlin-recharts
    • 1
    • 1
  • m

    Maggie Weber

    10/06/2022, 5:37 PM
    Hello everyone! We're interested in using Kotlin/Multiplatform to build an SDK that can be used by external applications in JVM and JS environments. However, it looks like the generated Javascript isn't really usable from non-Kotlin JS environments and doesn't seem like it was designed to. Using the IR compiler, the limits placed on what can be exported (no suspend functions being the big one but the others are pretty close behind) make it impossible to write well-designed code, and the format of the exports make it difficult to write good code on the consumer side. The Legacy compiler is equally problematic due to the lack of TS definitions and the ever-spooky "Legacy" word. Is using Kotlin/Multiplatform with a JS target with the express purpose of building a library that can be consumed from TS a use case that will be better supported in the future? Thanks for your time!
    s
    a
    • 3
    • 6
  • k

    Kristian Nedrevold

    10/09/2022, 8:21 PM
    when using react-router-dom useNavigate hook how do you pass data through the navigate invokation to the next component?
    t
    • 2
    • 1
  • a

    Adam Cooper

    10/09/2022, 9:11 PM
    I can't seem to figure out how to have compiled JS code execute on load in the browser. Essentially, what is the equivalent to
    application {
        mainClass.set("...")
    }
    for JavaScript?
    h
    • 2
    • 13
  • p

    PhongBM

    10/10/2022, 10:44 AM
    Hi everyone. I'm newbie in KotlinJs. I want to build a NodeJs Express using Kotlin. But I don't know how to do it. I created project using IntelliJ (New Project -> Kotlin Multiplatform -> Node.JS Application). What do I need to configure next to use npm express and create APIs.
    b
    • 2
    • 4
  • g

    georgi

    10/11/2022, 8:54 AM
    ❓ Does anyone have an example of a MondoDB integration with KotlinJs? I'm building a NodeJS app with KotlinJs and I'd like to talk to a MongoDB database. So far it looks like I have the following options: • monko - seems like what I want but I couldn't find any setup instructions/examples • KMongo - it's using the native Java driver for MongoDB so wouldn't work for KotlinJs, unless I'm missing something • MongoDB Node Driver - I'd have to create my own bindings for it from Javascript which I'm hoping to avoid • MongoDB / Realm - doesn't support the
    js
    target yet unfortunately • ...anything else?
    b
    m
    • 3
    • 7
  • p

    PhongBM

    10/12/2022, 2:16 PM
    I am new to KotlinJs. I use IntelliJ for created project and coding. It's my code
    external fun require(module: String): dynamic
    
    fun main() {
        val express = require("express")
        val app = express()
    
        app.get("/") { _, res ->
            res.json("Success")
        }
    
        app.listen(3000) {
            console.log("Server is running...")
        }
    }
    'express' has data type dynamic, IDE does not support code completion.
    r
    z
    • 3
    • 5
  • s

    Seth Madison

    10/13/2022, 6:33 PM
    Does anybody know of a way to remove the polyfills from the kotlin std lib ir generated files?
  • c

    christophsturm

    10/13/2022, 9:08 PM
    is there any kotlin web framework that does server side rendering? (compile the same code for js and jvm and render it first on the server side and then hydrate it on the client)
    b
    • 2
    • 2
  • d

    David Herman

    10/13/2022, 10:42 PM
    Hello, I'm working on a framework in Kotlin/JS land, and I recently updated to 1.7.10. I am now running into the change where JS files are compiled
    per-module
    instead of
    whole-program
    . I know I can just change the granularity back, but before I do that, I'm trying to, in code, generate an
    index.html
    file will all the separate JS files imported via
    <script>
    tags. The problem is, I don't know the order to import them. Is there a way to find out?
    h
    • 2
    • 12
  • v

    Vampire

    10/16/2022, 3:08 AM
    Give me a little reminder please. If I have a
    Dict
    subinterface that I need to give as argument, how do I properly construct it? In this case it is the
    external interface OutgoingHttpHeaders : Dict<dynamic /* Number | String | Array<String> */>
    from
    kotlinx-nodejs
    t
    • 2
    • 213
  • b

    Blake Anderson

    10/18/2022, 5:45 AM
    I'm having an issue with overload resolution for nested sealed classes with the same simpleName, in this case
    Expression.Access.Variable
    and
    Pattern.Variable
    . Here's some debug output from my testing:
    visit Variable(name=x)
      > is Expression.Access.Variable: false
      > is Pattern.Variable: true
    Matched is Pattern.Variable
      > func = function (p0) { return $boundThis.visit_ta6mxa_k$(p0); }
    visit pattern variable: Variable(name=x)
    visit Variable(qualifier=null, name=x)
      > is Expression.Access.Variable: true
      > is Pattern.Variable: false
    Matched is Expression.Access.Variable
      > func = function (p0) { return $boundThis.visit_ta6mxa_k$(p0); }
    visit pattern variable: Variable(qualifier=null, name=x)
    So, the
    is
    check of my
    when
    statement seems to be working fine - it's the actual function
    visit(ast: Expression.Access.Variable)
    versus
    visit(ast: Pattern.Variable)
    that's off (via
    val func: Type -> T = ::visit
    ). I'm guessing it's the function resolution, but could be an implementation layer. Continuing to dig around here to see what I can find out. EDIT: Self-contained example in thread.
    a
    • 2
    • 6
  • m

    Matt Nelson

    10/18/2022, 7:57 AM
    Got a multiplatform library where resources need to be extracted to the local file system at runtime (executable that will be run in its own process). Trying to add support for JS (node only), but have no clue how to retrieve them from
    jsMain
    in order to uncompress and persist to FS. Resources in question are in
    src/jsMain/resources
    directory. With java you'd just call
    javaClass.getResourcesAsStream("/path/myresource.txt.gz")
    1. Is there a similar way to java's for accessing them at runtime? 2. The files should not be served as content, would there be a better way to distribute them then as resources?
    b
    • 2
    • 32
  • b

    bashor

    10/18/2022, 1:34 PM
    https://twitter.com/bashorov/status/1580528407607410689
    a
    • 2
    • 1
  • a

    Ademir Queiroga

    10/21/2022, 5:12 PM
    Hi! I’m playing with #multiplatform and I have a this data class:
    @JsExport
    @Serializable
    data class Account(
        val id: String,
        val appName: String?,
        val availableCredits: Float,
    )
    When exported to javascript and logging an instance of this class the property names get all messed up.
    Account { n4n_1: 'test_id', o4n_1: 'test_name', p4n_1: 10 }
    Does anyone know why and how to fix this? In the
    .ts
    file the constructor has the all parameters correctly named and the IDE parameter hints are also all correct (and typed). I’m only facing this issue when logging the instances…
    m
    j
    • 3
    • 14
  • a

    andylamax

    10/23/2022, 1:11 AM
    is it just me? or is the
    jsBrowserTest
    configuration broken?? funny thing is
    jsNodeTests
    passes with no problem. I am getting a bunch of
    Module parse failed: Unexpected token (1:0)
    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>
    Any known solutions to this?
    • 1
    • 1
  • a

    andylamax

    10/24/2022, 1:31 PM
    @Big Chungus
    npm-publish
    doesn't fully support Configuration Cache. I say "doesn't support fully" because, if I comment out dependency configurations on the packageJson block, everything works fine. But if I include those configs, it fails with the error
    Execution failed for task ':picortex-sdk-react:assembleJsPackage'.
    > Error while evaluating property 'package$npm_publish_gradle_plugin.packageJson.dependencies' of task ':picortex-sdk-react:assembleJsPackage'
       > Failed to query the value of property 'dependencies'.
          > Could not create an instance of type dev.petuska.npm.publish.extension.domain.json.JsonObject.
             > Could not generate a decorated class for type JsonObject.
                > class sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to class java.lang.reflect.ParameterizedType (sun.reflect.generics.reflectiveObjects.TypeVariableImpl and java.lang.reflect.ParameterizedType are in module java.base of loader 'bootstrap')
    Is there a known current workaround you?? Also, should I create a ticket for this in github?? Tested Versions.
    npm-publish: 3.0.3
    kotlin     : 1.7.10 & 1.7.20
    gradle     : 7.5.1
    jdk        : openjdk_18
    b
    • 2
    • 17
  • c

    CLOVIS

    10/24/2022, 9:40 PM
    If I add a file in
    src/main/resources
    ,
    maven-publish
    correctly adds it to the generated
    .klib
    , but it doesn't seem like a downstream project can access it, it is extracted in
    /build/tmp/expandedArchives
    but doesn't seem to be copied anywhere. Do you know how the downstream library can use it? I expected it to appear in
    build/js/packages/<module>
    since that's where Webpack executes.
    d
    r
    • 3
    • 5
  • k

    kang wang

    10/26/2022, 10:33 AM
    Is there any performance comparison between kotlin generated js and handwritten js? We want some performance benchmark before compiling our business logic written in kotlin into javascript.
    a
    • 2
    • 1
Powered by Linen
Title
k

kang wang

10/26/2022, 10:33 AM
Is there any performance comparison between kotlin generated js and handwritten js? We want some performance benchmark before compiling our business logic written in kotlin into javascript.
a

Andrey Tabakov

10/26/2022, 7:34 PM
I don’t have any statistics, but I use kotlinJS in production. I’ve seen a generated code. It’s always a compromise. Is it slower? - I think yes, but you will get a lot of kotlin features such as really type-safe code
View count: 6