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

    andylamax

    08/03/2022, 8:48 AM
    Since you are drawing on Canvas You can bypass css all together and calculate the video coordinates and bounds altogether
  • a

    Ashley Arthur

    08/03/2022, 11:04 AM
    Hi all, another KMP -> JS question if anyone knows: When compiling a Kotlin method with default values, it seems the current behaviour ( 1.7.10 ) is to make ALL parameters in the function signature ‘optional’ in terms of the Typescript definition, even the ones where we haven’t specified a default value. Is this by design? It seems unsafe, because the params without defaults will possibly be undefined when the function is called from JS. example code: Kotlin
    fun hello(param1:String, param2:String, param3:Boolean = false ) {}
    JS.dt.ts
    hello(param1?: string, param2?: string, param3?: boolean): void;
    b
    a
    s
    • 4
    • 4
  • b

    Björn Lilleike

    08/03/2022, 3:33 PM
    For our team, the slow continuous build process of kotlin/js is still one of the biggest pain points. Is there a solution to reduce this hot reload times? As far as I understand, it is always one big js created that also includes all the library code when hot reloading. Can this be split to the unchanged library code with only the specific project code been rebundeld? Any other idea is welcome, sourceMaps = false is already active.
    r
    b
    d
    • 4
    • 3
  • a

    andylamax

    08/04/2022, 10:00 AM
    Hello, has any one been getting
    info There appears to be trouble with your network connection. Retrying...
    for kotlin js builds too frequently in github actions lately? or is it just me? Whats even more ironik is simply reruning the job, passes.
  • s

    shama

    08/04/2022, 10:24 PM
    Can you use KSP with the JS IR compiler? If so, are there any examples I could check out? Thanks!
    b
    • 2
    • 3
  • a

    alec

    08/05/2022, 3:24 PM
    I'm upgrading gradle to 5.7 and getting
    > Task :sqldelight:kotlinNpmInstall
    error <https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz>: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat '/Users/runner/Library/Caches/Yarn/v6/npm-typescript-3.9.5-586f0dba300cde8be52dd1ac4f7e1009c1b13f36-integrity/node_modules/typescript/lib/typingsInstaller.js'"
    
    > Task :sqldelight:kotlinNpmInstall FAILED
    ...
    > Task :web:kotlinSourcesJar
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':sqldelight:kotlinNpmInstall'.
    >                 Process 'Resolving NPM dependencies using yarn' returns 1
                      
                      yarn install v1.22.17
    and running out of ideas for what could be going on. It might be a corrupt cache of some sort but this is happening on CI and I'm not sure how to force a clear of the cache
    h
    t
    • 3
    • 10
  • a

    Ayfri

    08/06/2022, 2:30 PM
    Hi, how could I set up tests that only call once the constructor or just an initialization function, for now with a class it calls the constructor once per test and I depend on a library that have methods that should be only called once per project I'm using Karma as tests
    • 1
    • 1
  • m

    martmists

    08/07/2022, 2:27 AM
    I have a few questions about splitting code, in particular this warning:
    asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
    This can impact web performance.
    Assets: 
      index.js (516 KiB)
    entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
    Entrypoints:
      main (516 KiB)
          index.js
    webpack performance recommendations: 
    You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
    For more info visit <https://webpack.js.org/guides/code-splitting/>
    After going to that website it remains a bit unclear how I should approach this, for two reasons: • How do I effectively set this up for Kotlin/JS? • The generated filenames by this action seem somewhat random; How would I handle this in my pebble templates? (currently hardcoded to index.js)
    b
    • 2
    • 1
  • n

    Norbi

    08/07/2022, 1:37 PM
    I've just run into this error when I execute `jsBrowser*Run`:
    [webpack-cli] TypeError: cli.isMultipleCompiler is not a function
    I found some discussion about this problem (eg. https://kotlinlang.slack.com/archives/C0B8L3U69/p1655183383117179?thread_ts=1655180593.195219&amp;cid=C0B8L3U69) and a reported issue (KT-52776 KJS / Gradle: Webpack version update despite yarn.lock breaks Kotlin/JS build). Unfortunatelly the workaround does not work for me. Do you have any idea how this could be solved? Thanks.
    c
    • 2
    • 4
  • t

    Tóth István Zoltán

    08/09/2022, 12:10 PM
    I've been poking around Webpack and DCE in Kotlin/JS because I would like to have dynamic module loading. I understand that this is not supported as of now, but I'm willing to put in some work to find a solution. The concept is that we have a basic application (web client + server) and the user can add modules that contain both JVM parts and UI parts. A kind of a plugin concept, many systems provide this function. The JVM part is quite trivial, we've got that working already. As for the JS part. Checking the code the Kotlin compiler produces, it seems perfectly viable to forget Webpack. This of course means no DCE, but to be honest, I don't really care about DCE. The reason is that DCE helps up until a point, but then, as the application grows, the single-bundle concept starts to hurt more than the DCE helps. So, my plan is to get rid of Webpack altogether and just go with plain modules. The real question is, how to get these modules and how to ensure that all the "requires" use the proper name. The Kotlin compiler actually produces these modules, they are there... somewhere. :) I hacked around a bit and got it almost working already. However, it would be nice to have a "clean" solution for this. I'm not really worried about dependencies, we have like 6 from Kotlin (kotlin, atomicfu, serialization, coroutines, datetime -> js-joda) and a few from our own modules. Any pointers/ideas would be welcome, thanks.
  • s

    simon ballantyne

    08/10/2022, 10:12 PM
    So feeling particularly dumb, I have an example Kotlin/react js project and I am trying to add some .jar dependencies via gradle. I'm trying to use the file tree implementation statement but the dependencies don't appear to be imported. Any ideas?
    b
    • 2
    • 4
  • b

    Big Chungus

    08/11/2022, 6:43 PM
    Sounds like you're missing sourceMaps
    c
    • 2
    • 7
  • c

    CLOVIS

    08/13/2022, 10:18 PM
    I added a file to the
    jsMain/resources
    directory of my library module, but it doesn't end up in
    build/js/packages
    for the final module. Is there anything needed to tell Gradle to put resources from dependencies there?
    t
    • 2
    • 3
  • s

    Sachinda Liyanaarachchi

    08/18/2022, 9:01 AM
    Hello, I’m trying to setup fritz2 with a project that includes native applications. So, I got the application running but it cannot find the
    .js
    file in
    index.html
    My current problem is that there are two build folders being created. 1 in project folder and one in shared folder.
    o
    b
    • 3
    • 8
  • d

    David Whittaker

    08/20/2022, 5:28 AM
    Complete n00b question: I was hoping to use Kotlin in addition to my existing backend JavaScript code using Node. So I setup a new project and selected NodeJS Application and it created the Hello World app, which I can run with
    /gradlew run
    . But I want to be able to take the JavaScript output and use it in my existing app. Where is the JS? I see there's a /build/js folder but no .js files, even after doing a
    ./gradlew build
    . :: confused ::
    g
    b
    t
    • 4
    • 10
  • t

    Tom Yuval

    08/20/2022, 1:24 PM
    Related but slightly different, and possibly just as n00by: I’m building a multi-platform library, and my tests fail on JS IR, though they pass on all other platforms – including JS Legacy. Where can I find the two generated JS versions of the code so that I can compare them and gain any insight into what’s going on there?
    t
    • 2
    • 2
  • j

    juh juh

    08/21/2022, 7:30 PM
    Hello, is there some multiplatform library to consistently represent floating-point numbers across all platforms? I'm working on "replay" system for my game, and I really need numbers to be consistent across platforms, but with default Float it fails on JS, where I can't even do
    Float.fromBits((-1e11f).toRawBits())
    without getting distorted results
    e
    t
    • 3
    • 5
  • a

    Ayfri

    08/22/2022, 4:54 AM
    Hey I'm asking myself if it would be possible to generate using for example KSP a Partial version of any type using an annotation so we can more easily mimic the TypeScript definition that uses
    Partial<something>
    ? It would set all the external fields to nullable and override ones from the parents.
    g
    l
    • 3
    • 8
  • s

    Shan

    08/22/2022, 5:39 AM
    Hello. Getting this error when using a npm dependency:
    The engine "node" is incompatible with this module. Expected version ">=16.0.0". Got "14.17.0"
    Is there a way to configure the
    kotlinNpmInstall
    task to use a different version of node?
    e
    • 2
    • 2
  • a

    Alexander Weickmann

    08/22/2022, 10:48 AM
    Hi all, any way to create a custom html tag element with the new kotlin-react-dom instead of the legacy? This used to work:
    inline fun ChildrenBuilder.auiDropdownMenu(block: RDOMBuilder<AUI_DROPDOWN_MENU>.() -> Unit): Unit = tag(block) {
        AUI_DROPDOWN_MENU(mapOf(), it)
    }
    class AUI_DROPDOWN_MENU(
        initialAttributes: Map<String, String>,
        override val consumer: TagConsumer<*>
    ) : HTMLTag("aui-dropdown-menu", consumer, initialAttributes, null, false, false),
        CommonAttributeGroupFacadeFlowInteractivePhrasingContent
    but now I want to migrate this code and cannot find out how to do it
    a
    t
    • 3
    • 4
  • a

    Alexey Polyusov

    08/23/2022, 8:57 PM
    Hi guys! 🙂 I want to write an app that can be viewed in a web browser. I want to draw a lot of lines, squares etc on some canvas and make animations. I want to make some file processing (10-15 mb per file). I wish to load the entire file into RAM to speed things up. Not sure if I need multithreading. I have NO knowledge of JS\CSS\HTML at all, but I know Kotlin. What framework\library should I use for this task? Thanks!
    b
    v
    +2
    • 5
    • 5
  • a

    Ayfri

    08/24/2022, 2:49 AM
    Hi ! Is there an equivalent to electron but for Kotlin/JS ?
    r
    g
    d
    • 4
    • 7
  • j

    John O'Reilly

    08/24/2022, 9:09 AM
    Are any other folks running in to following (and using any particular workaround for now?) https://youtrack.jetbrains.com/issue/KTIJ-22303
    j
    • 2
    • 4
  • s

    Shan

    08/27/2022, 7:47 PM
    Want to make sure my assumptions are correct, first time working with Kotiln JS target &
    dynamic
    types: I have a js function from an imported library which returns
    dynamic
    . I'm trying to cast the return type's properties to kotlin types to create a typesafe wrapper of sorts. I can cast js primitives to kotlin primitives fine, but anything more complex like a js
    Uint8Array
    as
    UByteArray
    give me a
    ClassCastException
    . Wondering what the strategy is for this? Do I need to create my own
    Uint8Array
    type & implementations?
    b
    t
    • 3
    • 4
  • e

    eygraber

    08/30/2022, 9:38 PM
    I just updated one of my projects to use both
    LEGACY
    and
    IR
    compilers to support some users (I was only using
    IR
    before). After doing so I got strange test failures that were all related to conditions in a
    when
    not matching properly. Works on JS IR and all other backends except JS LEGACY:
    when(uriString[end]) {
      '/',
      '\\',
      '?',
      '#'
      -> break // break isn't executed when uriString[end] == '/'
    }
    Works on all backends:
    val c = uriString[end]
    if(c == '/' || c == '\\' || c == '?' || c == '#') break
    Is behavior like this expected?
    t
    t
    • 3
    • 3
  • a

    Ayfri

    08/31/2022, 9:16 AM
    Hi, why isn't there any operation on Number ? If I have an external interface having
    x: Number, y: Number
    , how would I create an operator function
    plus
    , should I convert or
    unsafeCast<Double>
    the numbers for every operation I need ? Or add operator functions to Number with
    unsafeCast<Double>
    every time ?
    b
    t
    • 3
    • 10
  • t

    turansky

    08/31/2022, 10:05 AM
    reader.result as ArrayBuffer
    ?
    u
    • 2
    • 7
  • u

    包子such fun

    08/31/2022, 3:43 PM
    Thanks everyone, finally I read file as dataUrl to get the base64 code and trans it to ByteArray (ktor only support this). And successed upload my file to OSS😪
    v
    • 2
    • 2
  • s

    Shan

    09/02/2022, 11:57 PM
    Heyo. Trying to convert a
    Uint8Array
    into a utf-8 string. Anyone know the best practice way to do this, since a
    Uint8Array
    isn't back by a
    UByteArray
    internally (from what I can tell) ?
    t
    e
    • 3
    • 16
  • l

    Laurent Laborde

    09/05/2022, 10:03 AM
    Friendly greetings ! would you suggest “Use new JS IR compiler” for a new hobby project, with no planned external dependencies, that will create a fullscreen canvas for a browser openGLES application ? (like a game, except that it won’t be a game)
    b
    a
    • 3
    • 8
Powered by Linen
Title
l

Laurent Laborde

09/05/2022, 10:03 AM
Friendly greetings ! would you suggest “Use new JS IR compiler” for a new hobby project, with no planned external dependencies, that will create a fullscreen canvas for a browser openGLES application ? (like a game, except that it won’t be a game)
b

Big Chungus

09/05/2022, 11:28 AM
I would, but it makes little difference for your particular use-case. That said, you might want to stick with legacy if only for quicker build times.
Note that quicker != quick anyways
You should be able to switch between the backends at will given that you only need canvas
l

Laurent Laborde

09/05/2022, 11:31 AM
thank you 😒miling_face_with_3_hearts:
a

andylamax

09/05/2022, 6:31 PM
quicker?? I think the IR compiler is now faster than the Legacy one
b

Big Chungus

09/05/2022, 6:34 PM
Is it? Maybe for a "standing start", but not for recompilation
But it's been a while since I've last compared them TBH. Best try and see for yourself.
a

andylamax

09/05/2022, 6:36 PM
I have been using IR for the past few months. I can say it got a better, better than Legacy
View count: 9