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

    altavir

    10/08/2019, 2:26 PM
    It seems that core-js npm bundle structure does not correspond to the one promised in the documentation. Any ideas?
    r
    s
    • 3
    • 12
  • s

    sean

    10/10/2019, 1:20 PM
    With dukat is there an example without kts gradle?
    :thread-please: 3
    r
    • 2
    • 1
  • n

    Nikky

    10/10/2019, 1:39 PM
    my kotlinjs
    .js.map
    files do not seems to work, as in .. when i open the debugger in chrome the files are empty i use
    moduleKind = "umd"
    and require.js to load all things (because everything else seemed to be unproportional more effort) anybody else having this issue.. or have working source mappings ?
    i
    • 2
    • 10
  • g

    gbaldeck

    10/11/2019, 3:46 AM
    Hi everyone, I have been away for a while and have a question about ducat and the React wrapper. Has it made the React wrapper obsolete since it can generate the type definitions from the d.ts files?
    b
    v
    +2
    • 5
    • 7
  • r

    ribesg

    10/11/2019, 2:11 PM
    My `data class`es don’t seem to have a
    copy
    function when I run my app, any idea why? Would DCE remove it or something? What can I do?
    g
    r
    +3
    • 6
    • 37
  • g

    gbaldeck

    10/11/2019, 2:55 PM
    One other question I have. We are building out a document management solution at my company and I have a few options to consider in terms of tools. On the frontend it is between Typescript/KotlinJs with React and on the backend Java/Kotlin with Spring. I know all the benefits of Kotlin cross-platform so that is a great selling point. But what I'm not sure about is the future of KotlinJs. If we start this project using React and KotlinJs, then the new backend compiler for KotlinJs is completed in a year or so (just guessing on the timeline), will the interop between KotlinJs and Javascript be so improved that the React wrapper is no longer needed and we would need to refactor the whole app when doing an upgrade? More specifically, what I'm unsure about is what effect the new backend compiler will have on KotlinJs, and if huge refactoring is going to be required if we use any current wrappers.
    r
    s
    • 3
    • 4
  • p

    pdvrieze

    10/11/2019, 3:07 PM
    Hi guys, I'm quite struggling how to get the files that make up npm dependencies. It's easy enough to get kotlin javascript dependencies and the related js files, but I don't seem to be able to get all (including transitive) files needed to actually use my Kotlin javascript module. I've managed to get the actual node dependency specifications, but not the files that they resolve to. I don't want minification (at this point).
    i
    • 2
    • 1
  • t

    Tristan Caron

    10/14/2019, 12:55 PM
    I tried every configuration that you can find on Slack and none of them is working for me. Do you have a starter kit for a simple project using React Wrappers and DCE?
    a
    b
    +2
    • 5
    • 15
  • n

    Nikky

    10/15/2019, 7:11 PM
    does anyone know how to make this happen in ktor client ?
    fetch('<http://another.com>', {
      credentials: "include"
    });
    or what things to do, headers to set ?
    j
    b
    +2
    • 5
    • 10
  • t

    Trevor

    10/15/2019, 8:50 PM
    Out of curiosity, is it possible to output a json AST of a
    .d.ts
    file with
    dukat
    ? https://github.com/Kotlin/dukat
    b
    • 2
    • 3
  • d

    diesieben07

    10/15/2019, 11:59 PM
    The JS DCE seems to not process the stdlib at all. Even with just one kotlin file that has one function in it (no parameters) that returns a string, I get what seems like the entirety of kotlin.js. Am I doing something wrong or is this simply not implemented yet?
    b
    i
    • 3
    • 22
  • r

    ribesg

    10/17/2019, 8:46 AM
    So how do you guys bind a coroutine scope to a React component?
    z
    • 2
    • 5
  • f

    fcosta

    10/17/2019, 12:00 PM
    Hey guys! How can i pass environment variables from
    Gradle
    to
    WebPack
    with
    org.jetbrains.kotlin.js
    ?
    b
    b
    • 3
    • 7
  • l

    louiscad

    10/17/2019, 9:42 PM
    Is that something that could change for the better? https://twitter.com/ankushg/status/1184536209336537090?s=09
    a
    n
    • 3
    • 2
  • a

    audax

    10/18/2019, 5:07 AM
    I am using 1.3.50 and I have a multiplatform library that I now wish to package as an NPM module which I want to use in an angular project with typescript. How do I package my library as an NPM module? All the information I could find was for older versions of kotlinjs which do not apply anymore.
    d
    s
    • 3
    • 3
  • h

    hellman

    10/20/2019, 6:40 PM
    Ok, so it seems like importing
    @types/something
    doesn’t work well. you got duplicate declarations
    :youtrack: 1
    b
    • 2
    • 5
  • d

    Daan

    10/21/2019, 2:24 PM
    I guess this is related since it gets at the root of the problem: https://youtrack.jetbrains.com/issue/KT-24784
    b
    • 2
    • 2
  • s

    spierce7

    10/21/2019, 2:59 PM
    Is there any news concerning this? https://youtrack.jetbrains.com/issue/KT-16604
    👍 4
    👀 2
    t
    v
    s
    • 4
    • 3
  • t

    tarek

    10/23/2019, 12:09 AM
    Your generated js file is named after your module. You can have a look in
    build/distributions
    after running
    ./gradlew jsBrowserWebpack
    to see the result Additionally, you can add a
    index.html
    with a
    <script src="<my-module>.js"></script>
    to your
    jsMain/resources
    folder and it will be copied to your build folder and used when you run
    ./gradlew jsBrowserRun
    👍 1
    s
    • 2
    • 10
  • s

    sdeleuze

    10/23/2019, 1:35 AM
    Next step in my Kotlin/JS journey, I would like to be able to use https://www.npmjs.com/package/rsocket-websocket-client, so I have added
    implementation(npm("rsocket-websocket-client", "0.0.16"))
    dependency to my project and I would like to consume
    RSocketWebSocketClient
    class defined like that in JS:
    class RSocketWebSocketClient {
      constructor(options, encoders) {
        // ...
      }
      close() {
        // ...
      }
      connect() {
        // ...
      }
    }
    exports.default = RSocketWebSocketClient;
    On Kotlin side, I have defined:
    @JsModule("rsocket-websocket-client")
    external class RSocketWebSocketClient(options: dynamic, encoders: dynamic)
    
    fun main() {
    	println("Hello JavaScript!")
    	RSocketWebSocketClient(js("{}"), js("{}"))
    }
    And I get this error
    TypeError: RSocketWebSocketClient is not a constructor
    . What did I miss?
    t
    • 2
    • 6
  • d

    Dominik Csiba

    10/23/2019, 8:47 AM
    Is it possible to do something like this? Specifically asking for the options part, as I am currently using
    dynamic
    , and I don't like the un-safety.
    external interface GraphvizProps : RProps {
      var dot : String
      var options: {width: number, height: number}
     }
    d
    • 2
    • 8
  • m

    mzgreen

    10/23/2019, 12:28 PM
    Hey I just tried to create a js module in an existing kotlin multiplatform project and I can’t get it working. I don’t have any experience with js so it makes things harder. I created a new module in the project and performed the steps described in gradle setup section in the documentation. I would like to make it work without any unnecessary libraries, just the simplest setup where I have a html file and some kotlin code that I can run in the browser. I looked for sample apps on github but I found only some old ones or some more complex solutions that use react or other libs. Is there some sort of a doc/blog post/sample that I could take look at?
    i
    • 2
    • 7
  • g

    gaetan

    10/23/2019, 2:29 PM
    I would expect to do something like:
    task app1(type: KtolinJsDce) {
    		dceOptions {
    		    outputFileName = "app1"
    		    keep = "mod.app1.start"
    	}
    }
    i
    f
    • 3
    • 15
  • p

    paul murphy

    10/23/2019, 8:22 PM
    Hi Guys, Would I be able to get help with the following question https://stackoverflow.com/questions/58489279/how-to-depend-on-a-maven-local-jar-when-using-create-react-kotlin-app-https-gi
    r
    • 2
    • 1
  • s

    Sam

    10/24/2019, 11:39 AM
    I'm looking for a sample / tutorial on how to configure a js app with kotlin code along with npm packages using the new
    org.jetbrains.kotlin.js
    gradle plugin available since Kotlin 1.3.40 release. Could you recommend any?
    s
    a
    • 3
    • 4
  • s

    sdeleuze

    10/24/2019, 1:19 PM
    The more I use Kotlin/JS, the more I think you could do for frontend what you did on Android with carefully crafted Kotlin extensions (including Coroutines and Flow based ones) on top of Web APIs. See https://github.com/Kotlin/kotlinx.coroutines/issues/1633#issuecomment-545913942.
    f
    • 2
    • 1
  • g

    gaetan

    10/24/2019, 2:15 PM
    The biggest problem today for Kotlin/JS is tooling. Using ktor-js client, with really basic usage (GET, POST, …) and AFTER Kotlin DCE, I end with: kotlinx-coroutines-core.js : 362 Ko kotlinx-coroutines-io.js: 157 Ko kotlinx-io.js: 223 Ko kotlinx-serialization-kotlinx-serialization-runtime.js: 271 Ko ktor-ktor-client-core.js: 292 Ko ktor-ktor-http-cio.js 43 Ko ktor-ktor-http.js: 168 Ko ktor-ktor-utils.js: 80 Ko Waaaay too much to be able to do this call:
    val response = <http://client.post|client.post><HttpResponse>("/account/profile") {
    						val jsonData = Json(JsonConfiguration.Stable).stringify(
    							ProfileFormState.serializer(),
    							store.state
    						)
    						body = jsonData
    					}
    ☝️ 1
    💯 1
    r
    a
    f
    • 4
    • 8
  • n

    Nicholas Bilyk

    10/24/2019, 6:58 PM
    In KotlinJS under the hood the multiplatform FloatArray corresponds to Float32Array -- is there a reason we can't use FloatArray (without casting) as a parameter when Float32Array is expected? (Same goes for IntArray -> Int32Array)
    • 1
    • 1
  • t

    tarek

    10/26/2019, 5:06 PM
    Is there a better way to convert from a javascript
    UInt8Array
    back to a Kotlin
    ByteArray
    than trivially
    ByteArray(uintArray.length) { uintArray[it] }
    ?
    d
    • 2
    • 2
  • p

    patrickdelconte

    10/29/2019, 2:02 PM
    I’m having trouble with translating this instantiation of a class to kotlinjs
    var ui = new firbeaseui.auth.AuthUI(firebaseI.auth());
    . Doing the naive thing in kotlin does not result in a “new” call in the generated code e.g.
    val ui = firebaseui.auth.AuthUI(firebase.auth())
    does not work. rightnow I am doing the following, which works but is a bit ugly
    external val uiHack: AuthUI
    val firebaseHack = firebase // firebase is imported as `@JsModule("firebase") external val firebase: Firebase`
    val firbeaseUIHACK = firebaseui // same as above
    js("var uiHack = new firbeaseUIHACK.auth.AuthUI(firebaseHack.auth());")
    val ui = uiHack
    the same question has also been asked on stackoverflow some time ago: https://stackoverflow.com/questions/49097351/cant-create-object-from-required-module-in-kotlinjs
    • 1
    • 1
Powered by Linen
Title
p

patrickdelconte

10/29/2019, 2:02 PM
I’m having trouble with translating this instantiation of a class to kotlinjs
var ui = new firbeaseui.auth.AuthUI(firebaseI.auth());
. Doing the naive thing in kotlin does not result in a “new” call in the generated code e.g.
val ui = firebaseui.auth.AuthUI(firebase.auth())
does not work. rightnow I am doing the following, which works but is a bit ugly
external val uiHack: AuthUI
val firebaseHack = firebase // firebase is imported as `@JsModule("firebase") external val firebase: Firebase`
val firbeaseUIHACK = firebaseui // same as above
js("var uiHack = new firbeaseUIHACK.auth.AuthUI(firebaseHack.auth());")
val ui = uiHack
the same question has also been asked on stackoverflow some time ago: https://stackoverflow.com/questions/49097351/cant-create-object-from-required-module-in-kotlinjs
for future reference the cleanest thing I was able to do is the following (from stackoverflow answer):
val firebaseHack = firebase
val firbeaseUIHACK = firebaseui 
val ui: AuthUI = js("new firbeaseUIHACK.auth.AuthUI(firebaseHack.auth());")
We still need the
firebaseHack
variable to make sure firebase is available in the local scope in the generated js
View count: 10