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

    Sam Garfinkel

    09/12/2019, 1:53 PM
    Is Dukat supposed to generate
    @JsName
    and
    @JsModule
    annotations or is that currently not a supported feature?
    s
    u
    • 3
    • 3
  • r

    ribesg

    09/13/2019, 8:31 AM
    Hey, I plan to start a personal project and I would like to make the frontend in Kotlin. What are viable solutions right now? I remember looking at some React things in Kotlin but it was mostly PoC at the time.
    m
    b
    r
    • 4
    • 26
  • h

    hikamaeng

    09/13/2019, 10:19 AM
    The default dispatcher of kotlinJS is based on window.postMessage. I'm trying to create a new dispatcher based on requestAnimationFrame. But it's not working properly and needs help. https://gist.github.com/hikaMaeng/a8250773a2cafd5fe38dc2fefa1dae3f
    e
    • 2
    • 1
  • s

    Sam Garfinkel

    09/13/2019, 1:58 PM
    Anyone have an example project of using React Hooks? Having trouble getting them to work correctly.
    s
    z
    • 3
    • 28
  • t

    Trevor

    09/14/2019, 5:31 AM
    I've put up a pull-request for
    create-kotlin-react-app
    which updates
    kotlin-react
    to it's most recent version I believe. This makes it so you can use hooks out of the box! https://github.com/JetBrains/create-react-kotlin-app/pull/294
    • 1
    • 1
  • t

    trevortrevor

    09/16/2019, 1:45 PM
    Also, is there a place that lists JS libraries that have kotlin bindings? Dukat seems to do good for smaller libraries, but were still at a place where hand-rolled ones are more ergonomic.
    f
    s
    • 3
    • 5
  • g

    gaetan

    09/16/2019, 5:32 PM
    Any idea why this code works:
    val image = js("""document.querySelector("iframe").contentDocument.querySelector("canvas").toDataURL()""")
    			console.log(image)
    but this one fails with a ClassCastException:
    val image = ((document.querySelector("iframe") as HTMLIFrameElement)
    				.contentDocument?.querySelector("canvas") as HTMLCanvasElement).toDataURL()
    			console.log(image)
    ?
    t
    • 2
    • 2
  • p

    Philipp Smorygo [JB]

    09/17/2019, 11:33 AM
    Hello, I need some help. I have a small gradle.kts project with two subprojects: 1) multiplatform lib, 2) js module.
    plugins {
        id("org.jetbrains.kotlin.multiplatform")
        id("org.jetbrains.kotlin.plugin.serialization")
    }
    
    repositories {
        mavenCentral()
        maven("<https://kotlin.bintray.com/kotlinx>")
    }
    
    kotlin {
        jvm()
        js()
    
        @Suppress("UNUSED_VARIABLE")
        sourceSets {
            commonMain {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                    implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Versions.kotlin_serialization_version}")
                }
            }
            val jvmMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-jdk8"))
                    implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.kotlin_serialization_version}")
                }
            }
            val jsMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-js"))
                    implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Versions.kotlin_serialization_version}")
                }
            }
        }
    }
    import org.jetbrains.kotlin.gradle.dsl.Coroutines
    
    plugins {
        kotlin("js")
        id("org.jetbrains.kotlin.plugin.serialization")
    }
    
    repositories {
        mavenCentral()
    }
    
    kotlin {
        experimental {
            coroutines = Coroutines.ENABLE
        }
    
        target {
            browser {
                runTask {}
            }
        }
    
        sourceSets {
            main {
                dependencies {
                    implementation(kotlin("stdlib-js"))
                    implementation(project(":common"))
                }
            }
        }
    }
    However gradle reports that
    "...Caused by: java.lang.IllegalStateException: project ':common' is not configured for JS usage"
    What am I missing?
    ✅ 1
    i
    • 2
    • 2
  • s

    Soren Valle

    09/18/2019, 11:46 AM
    How does one prohibit the mangling of abstract class implementation overridden property names with
    @JsName("prop")
    ?
    abstract class SomeClass {
        @JsName("someProp")
        abstract var someProp: String
    }
    
    class SomeClassImpl : SomeClass() {
        override var someProp: String = "prop"
    }
    
    
    fun main() {
        console.log(SomeClassImpl())  // still mangled  - Object { "someProp_366n21$_0": "prop" }
    }
    e
    • 2
    • 3
  • e

    Evan R.

    09/18/2019, 12:27 PM
    How do you guys use Kotlin/JS libraries in other JS applications? Does anyone have any experience with that?
    :yes: 3
    t
    a
    i
    • 4
    • 14
  • h

    hallvard

    09/19/2019, 8:43 AM
    Kotlin/js gives us
    console.log
    ,
    console.dir
    ,
    console.warn
    , and
    <http://console.info|console.info>
    . Is there a reason there is no
    console.debug
    ?
    g
    n
    • 3
    • 6
  • g

    gildor

    09/22/2019, 4:47 AM
    @krotki I would recommend this example that uses new JS plugin and dukat for interop with js libraries https://github.com/Kotlin/kotlin-js-demo-1.3.50
    k
    • 2
    • 3
  • r

    Ricky

    09/22/2019, 5:20 PM
    Been getting this issue https://youtrack.jetbrains.com/issue/KT-33710 witch is fixed in dev versions for 1.3.60 but now i'm getting:
    * What went wrong:
    Could not determine the dependencies of task ':packageJson'.
    > Could not resolve all dependencies for configuration ':npm'.
       > Could not find org.jetbrains.kotlin:kotlin-test-js-runner:1.3.60-dev-2370.
    where exactly do I set the version for
    kotlin-test-js-runner
    ?
    i
    • 2
    • 2
  • v

    Vytautas Jakutis

    09/23/2019, 8:37 AM
    What is the reason d.ts.libs folder (a copy of typescript/lib) is bundled with dukat?
    u
    • 2
    • 9
  • h

    hallvard

    09/23/2019, 12:03 PM
    I am struggling with a JS library misbehaving on Safari/mac. In a listener triggered on page unload, I need to return nothing in order to avoid a dialog alert to users. But on Safari, the event object has
    returnValue: "kotlin.Unit"
    (where my Firefox/Ubuntu has
    returnValue: ""
    ). Is this something known? Is there a workaround?
    s
    z
    • 3
    • 14
  • b

    Big Chungus

    09/23/2019, 2:43 PM
    Has anyone managed to get new js plugin working with dce?
    s
    s
    • 3
    • 8
  • c

    caffeine

    09/24/2019, 12:45 AM
    Hello! I found a bug: https://youtrack.jetbrains.com/issue/KT-33974
    u
    • 2
    • 1
  • b

    Bahaa Kallas

    09/24/2019, 3:11 PM
    what is the recommended way to setup kotlin react project ? does using the example here https://github.com/JetBrains/create-react-kotlin-app/ still the right point to start ?
    t
    s
    • 3
    • 5
  • r

    ribesg

    09/25/2019, 10:38 AM
    I don’t understand what I’m missing
    b
    g
    • 3
    • 15
  • t

    tapchicoma

    09/27/2019, 11:13 AM
    anyone tried to create Github Action using Kotlin?
    l
    • 2
    • 3
  • j

    Justin

    09/27/2019, 3:28 PM
    How do you read a txt file to a string in the JS target of a Kotlin Multiplatform project?
    b
    g
    • 3
    • 15
  • a

    altavir

    09/28/2019, 2:56 PM
    I've wrote a short article about handling inner React state from outside with coroutines: https://medium.com/@altavir/taming-react-with-kotlin-js-and-coroutines-ef0d3f72b3ea. Several people asked me why not use redux. In my particular case it won't work but wanted to ask the backward question (just for understanding it better): does redux do something that is not possible with channel?
    👍 3
    v
    • 2
    • 5
  • j

    Justin

    09/30/2019, 6:44 PM
    According to the docs, this should be supported, right? https://kotlinlang.org/docs/reference/js-reflection.html?_ga=2.212620177.463553542.1569790656-1872831452.1547516719#javascript-reflection
    c
    • 2
    • 2
  • v

    Vytautas Jakutis

    10/01/2019, 8:37 AM
    @[JB] Shagen I saw dukat v0.0.19 release! Tried again to compile for example `lib.es5.d.ts`:
    npm i dukat && npx dukat -d kt node_modules/dukat/d.ts.libs/lib.es5.d.ts
    Which succeeded, but when trying to compile the kotlin file to javascript, I got:
    $ kotlinc-js -output out.js kt/lib.es5.module_dukat.kt 
    kt/lib.es5.module_dukat.kt:126:15: error: parameter name expected
        fun apply(this: Function<*>, thisArg: Any, argArray: Any? = definedExternally /* null */): Any
                  ^
    a
    • 2
    • 1
  • h

    hallvard

    10/01/2019, 8:49 AM
    Trying to use Goggle's closure compiler on a K/JS module using ADVANCED_OPTIMIZATIONS, I keep getting complaints about 'module' (and 'variable' and 'require'):
    wrapper.js:6: ERROR - [JSC_UNDEFINED_VARIABLE] variable module is undeclared
    . Is there an easy fix for this that I missed?
    a
    • 2
    • 4
  • r

    ribesg

    10/03/2019, 9:25 AM
    So I’ve been playing with some Kotlin/JS and I now have my tiny mostly empty app served as a 30Mo js file (5Mo gzipped). Anyone has examples / know how to split that huge thing into different files? For example, I was thinking maybe I could import the right version of kotlin.js and maybe some dependencies in my index html, so that I only have to redownload my actual app code on updates. https://github.com/Ribesg/Kita/blob/11643d13126867946bd7d2113d09e8376ca9fa22/modules/client/client-web/build.gradle.kts#L11-L20
    b
    i
    +2
    • 5
    • 45
  • j

    Juanoterocas

    10/03/2019, 7:50 PM
    Hi guys , how I set npm( new JS target ) output to submodule directory, I'm having MODULE NOT Found because is using parent build output( with kotlin-frontend didn't happen ), is there an example for this, also to use webpack in production mode?
    a
    i
    s
    • 4
    • 25
  • b

    Big Chungus

    10/03/2019, 8:00 PM
    What do you guys think about this idea: for kotlin-js gradle plugin (and MPP counterpart of it) move the yarn.lock files outside of build directory to either project root or some external structure so those would be pushed to git and serve their purpose?
    👍 1
    s
    r
    +2
    • 5
    • 7
  • r

    ribesg

    10/06/2019, 12:09 PM
    Anyone knows how to keep generated Ktor serializers when using Koltin JS DCE?
    b
    • 2
    • 8
  • b

    Big Chungus

    10/08/2019, 12:27 PM
    When adding Kotlin/js dependency as jar, it's expanded fine, but all non-js dependency files are excluded from node_modules_imported. How can i disable this behaviour?
    :youtrack: 1
    ❓ 2
    s
    • 2
    • 4
Powered by Linen
Title
b

Big Chungus

10/08/2019, 12:27 PM
When adding Kotlin/js dependency as jar, it's expanded fine, but all non-js dependency files are excluded from node_modules_imported. How can i disable this behaviour?
:youtrack: 1
❓ 2
s

snrostov

10/08/2019, 8:00 PM
What do you mean by "all non-js dependency files"? Maybe you can provide some example of this files?
b

Big Chungus

10/08/2019, 8:01 PM
Well i was using kvision kotlin js jar and it has some css in it. I can see them in tmpExpandedArchives, but not node modules imported
s

snrostov

10/08/2019, 8:08 PM
Currently there is no way to disable it: https://github.com/JetBrains/kotlin/blob/24f08a614e860f5add491fe9ce04247dc837ceb7/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt#L31 https://github.com/JetBrains/kotlin/blob/24f08a614e860f5add491fe9ce04247dc837ceb7/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt#L71-L76 Only
.js
,
.meta.js
and
.js.map
will be copied. But I think it makes sense to copy all files. Can you please create an issue in :youtrack: ? cc @Ilya Goncharov [JB]
👍 1
b

Big Chungus

10/10/2019, 11:25 AM
https://youtrack.jetbrains.com/issue/KT-34287
:tnx: 2
View count: 4