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

    Animesh Sahu

    02/04/2021, 10:11 AM
    Hmm,
    A boolean was expected
    🤔 I guess its a boolean otherwise code wouldn't have been compiled.
    t
    • 2
    • 17
  • r

    Robert Jaros

    02/04/2021, 2:44 PM
    Do I understand correctly that to publish my project to Maven Central all dependencies need to be in Central as well? If so, can we expect
    kotlin-wrappers
    and
    kotlinx-nodejs
    artifacts to be published to Central anytime soon?
    m
    v
    a
    • 4
    • 6
  • d

    Dmitry Romanov [JB]

    02/05/2021, 8:08 AM
    I would also like to remind you that another experimental feature was added in 1.4.20 - Ignoring compilation errors with IR compiler. How many of you guys have tried it and ready to share some feedback?
    r
    h
    +2
    • 5
    • 6
  • j

    John O'Reilly

    02/05/2021, 4:13 PM
    Is there any recommended way to show a map in a Kotlin/JS based web app?
    j
    • 2
    • 3
  • h

    Harald Pehl

    02/05/2021, 5:30 PM
    Anybody knows how to create and use custom events in Kotlin/JS? I'd like to do something like this:
    class TreeItemSelectEvent<T>(val treeItem: TreeItem<T>) : Event("treeitemselect")
    
    fun select(treeItem: TreeItem<T>) {
        element.dispatchEvent(TreeItemSelectEvent(treeItem))
    }
    When I try to create and dispatch the event, I get the following error:
    TypeError: Failed to construct 'Event': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
    Using
    CustomEvent
    instead of
    Event
    doesn't help. What am I missing?
    r
    • 2
    • 6
  • s

    Shannon Rhodes

    02/05/2021, 6:55 PM
    is it possible to build kotlin multiplatform to js without using jvm?
    s
    a
    • 3
    • 6
  • g

    galex

    02/06/2021, 1:36 PM
    Did someone manage to use the d.ts of its Kotlin/JS MPP? I do not manage to implement an interface named
    LifecycleOwner
    declared like that:
    export namespace com.company.core.livedata {
        class Lifecycle {
            constructor();
            readonly tags: kotlin.collections.MutableMap<string, any>;
            isStarted: boolean;
            start(): void;
            stop(): void;
            addStopObserver(block: () => void): void;
            notifyObserversStop(): void;
        }
    }
    export namespace com.company.core.livedata {
        interface LifecycleOwner {
            readonly lifecycle: com.company.core.livedata.Lifecycle;
        }
    }
    I just don’t manage to import it in pure React app (with typescript). I import the module like that:
    import * as companycore from 'companycore';
    I can find
    Lifecycle
    class if I log the whole module:
    console.log("companycore", companycore)
    But not the
    LifecycleOwner
    interface. Any idea?
    b
    t
    • 3
    • 15
  • s

    Slackbot

    02/06/2021, 6:42 PM
    This message was deleted.
    t
    • 2
    • 1
  • j

    Julius Hannink

    02/08/2021, 1:51 PM
    Hi, just trying to change to the js IR compiler backend, but keep getting the error:
    You already registered Kotlin/JS target 'js' with another compiler: legacy
    Any idea on how to do that properly? I tried clearing gradle / idea / etc. caches but without success so far... :(
    m
    r
    • 3
    • 5
  • d

    dave08

    02/08/2021, 4:51 PM
    It seems a bit complicated with webpack already... adding to that that I don't know what the kotlin js gradle tasks do for me when I enable css... I'm pretty confused.
    t
    • 2
    • 4
  • t

    Tarun Chawla

    02/09/2021, 11:33 AM
    Am new to frontend development. Am looking for a way to validate HTML form before submitting them. E.g Form fields should not be empty, if field type is number and its length is restricted to 10 then before submitting it should check for these things. Any framework which I can embed in Kotlin/JS? PS: Am creating a HTML page inside override fun RBuilder.render() {
    r
    • 2
    • 2
  • m

    Marc Knaup

    02/09/2021, 12:02 PM
    Does anyone have a good setup/architecture for enabling different environments? Let’s say I have three environments
    live
    ,
    test
    and
    dev
    . In each environment I’d like to use different configuration values, for example a different API URL. So basically I’d have three
    .kt
    files with different values each and depending on what I’d like to build/deploy I need a different one of these to be used 🤔 Ideally the values are provided when starting the server (e.g. webpack dev server) so that they can depend on environment variables (e.g. on Heroku).
    t
    b
    • 3
    • 36
  • d

    dave08

    02/09/2021, 3:05 PM
    Anyone has an idea what could cause this error:
    kotlin-react-tutorial.js?92c2:40758 Uncaught TypeError: Cannot read property 'toString' of undefined
        at _no_name_provided__132.invoke_223 (kotlin-react-tutorial.js?92c2:40758)
        at _no_name_provided__83.eval [as _$render] (kotlin-react-tutorial.js?92c2:40780)
        at _no_name_provided__83.invoke_132 (kotlin-react-tutorial.js?92c2:24110)
        at eval (kotlin-react-tutorial.js?92c2:24149)
        at buildElements (kotlin-react-tutorial.js?92c2:23965)
        at _no_name_provided__84.invoke_134 (kotlin-react-tutorial.js?92c2:24124)
        at VideoList (kotlin-react-tutorial.js?92c2:24136)
        at renderWithHooks (react-dom.development.js?b313:14985)
        at updateFunctionComponent (react-dom.development.js?b313:17356)
        at beginWork (react-dom.development.js?b313:19063)
    In here:
    _no_name_provided__132.prototype.invoke_223 = function ($this$rFunction, props) {
        var tmp0_iterator = props.videos.iterator_68();
        while (tmp0_iterator.hasNext_49()) {
          var video = tmp0_iterator.next_56();
          var tmp0_p_0 = null;
          var tmp1_tag_0_1 = _no_name_provided_$factory_98(tmp0_p_0);
          var tmp0_apply_0_3 = new RDOMBuilder(tmp1_tag_0_1);
    >>>      tmp0_apply_0_3._set_key_(video._id.toString()); <<<<<<
          var tmp0__anonymous__1_5 = tmp0_apply_0_3._attrs_0;
          _set_onClickFunction_(tmp0__anonymous__1_5, _no_name_provided_$factory_99(props, video));
          if (video.equals(props.selectedVideo)) {
            tmp0_apply_0_3.unaryPlus_8('\u25B6 ');
          }tmp0_apply_0_3.unaryPlus_8('' + video._speaker + ': ' + video._title);
          $this$rFunction.child_4(tmp0_apply_0_3.create_11());
          Unit_getInstance();
        }
      };
    I'm using the IR compiler in dev mode
    m
    a
    +2
    • 5
    • 38
  • t

    Tarun Chawla

    02/09/2021, 5:01 PM
    Any good intro on coroutine scope in Kotlin JS? I want to use scope limited to JS/HTML page lifecycle instead of GlobalScope.
    a
    • 2
    • 12
  • a

    Andrey Nikanorov

    02/09/2021, 5:28 PM
    Do we have any tool similar to "Analyze APK" but for JS? It's not really clear what are included in the webpacked JS.
    t
    • 2
    • 7
  • s

    Shannon Rhodes

    02/09/2021, 6:11 PM
    which command should I run to generate the root build folder? I someone was able to get that working yesterday but now I am not able to regenerate it after running
    ./gradlew clean
    . I've tried build, run, and jsBrowserTask. What is the normal sequence of CLI commands?
    t
    • 2
    • 4
  • j

    Joost Klitsie

    02/10/2021, 8:44 AM
    Hi all! After a long wait I could finally enable the IR compiler on my project! After running the production webpack, the size of the resulting js file went down from 4.9MB to a whopping 4.3MB, which in fairness was a bit disappointing. I use the React-wrapper, Coroutines, Ktor, Kodein, is there any way to optimize the size?
    r
    t
    m
    • 4
    • 11
  • t

    Tarun Chawla

    02/10/2021, 10:27 AM
    In my current full stack project, one big js file is getting generated. Is there any way to have multiple js files instead of one big output.js?
    :yes: 1
    ✅ 1
    🇳🇴 1
    r
    t
    • 3
    • 8
  • d

    dave08

    02/10/2021, 10:53 AM
    I'm trying to use an npm react module that needs css for it to work... the html renders with my wrapper... but no css.
    :thread-please: 1
    r
    • 2
    • 12
  • d

    dave08

    02/10/2021, 2:10 PM
    How can I define:
    rowExpansionTemplate?(data: any): JSX.Element | undefined;
        rowGroupHeaderTemplate?(data: any, index: number): React.ReactNode | undefined;
    In a Kotlin js react component wrapper?
    b
    • 2
    • 6
  • t

    Tarun Chawla

    02/10/2021, 3:30 PM
    Is it possible to use npmjs packages in Kotlin/JS? If yes can you please share good documentation on how to call js apis from Kotlin code?
    h
    • 2
    • 2
  • d

    dave08

    02/10/2021, 4:15 PM
    Using the kotlin js tutorial's setup, and I keep on loosing my source set, I constantly have to do redo a gradle sync to get them back... is this a bug?
    t
    • 2
    • 5
  • r

    Robert Jaros

    02/10/2021, 5:58 PM
    I've noticed that with IR there is no concept of "unused Kotlin dependencies". With legacy backend I could add a Kotlin/JS dependency to a project, and if I didn't use it at all, it was fully removed from the final bundle (it was put into separate js module, which could be filtered by webpack tree-shaking). With IR just adding a dependency puts its code in the
    projectName.js
    file processed by webpack, which makes all
    require()
    directives resolved and added to the final bundle. It probably does not impact typical use cases, but for modular framework like KVision it makes a difference. I can't just work with an empty template project with all modules in
    build.gradle.kts
    , because the bundle is very large even though the application is just a "hello world". It's a bit surprising for me considering IR should make final bundles lighter 😉
    :trollface: 2
    m
    • 2
    • 1
  • m

    Marc Knaup

    02/10/2021, 7:11 PM
    Is
    -Xir-property-lazy-initialization
    only relevant in projects with binaries? Means I don’t have to set it in Kotlin/JS libraries at all, right?
    i
    • 2
    • 1
  • c

    Chris

    02/11/2021, 3:30 PM
    I am working on a library for technical indicators and am wondering if it is possible to compile the same library code for JS and JVM. This would allow me to have a single code base that could run in the browser as well as server side. Some googling has led me to believe that this is not possible but I wanted to confirm.
    b
    • 2
    • 3
  • a

    Alexander Weickmann

    02/12/2021, 12:19 PM
    JCenter and Bintray will shut down on May 1st. Seems like there are multiple Kotlin projects on these repos, e.g. https://github.com/JetBrains/kotlin-wrappers Did Jetbrains already anounce a plan that these repos will be published somewhere else in time?
    r
    t
    s
    • 4
    • 7
  • s

    spierce7

    02/13/2021, 2:57 AM
    Is there a planned release of when we get source maps in the IR compiler? My team can’t use the IR compiler because it still lacks source maps, and that also means I can’t use typescript definitions. I was really hoping it was going to come in 1.4.30.
    r
    o
    • 3
    • 3
  • r

    rnett

    02/13/2021, 7:33 AM
    distribution
    also seems not to work for Node, probably for related reasons
    t
    v
    • 3
    • 4
  • a

    altavir

    02/13/2021, 2:39 PM
    @turansky I saw your reply in the ktor-client size ticket. Could you tell me what tool did you use to get the bundle size picture?
    t
    o
    • 3
    • 15
  • d

    dave08

    02/14/2021, 2:46 PM
    How would I wrap this in Kotlin js (coming from npm's wsse module):
    declare const usernameToken: ({ username, password, }: {
        username: string;
        password: string;
    }) => UsernameToken;
    export default usernameToken;
    export { UsernameToken };
    a
    • 2
    • 7
Powered by Linen
Title
d

dave08

02/14/2021, 2:46 PM
How would I wrap this in Kotlin js (coming from npm's wsse module):
declare const usernameToken: ({ username, password, }: {
    username: string;
    password: string;
}) => UsernameToken;
export default usernameToken;
export { UsernameToken };
I tried this:
external interface Credentials {
	var username: String
	var password: String
}

@JsModule("wsse")
@JsNonModule
external val usernameToken: (credentials: Credentials) -> UsernameToken
But it doesn't seem to work...
It gives me tmp1 is not a function...
tmp_0._xWsse0 = tmp_1(new _no_name_provided__146()).getWSSEHeader();
When I try calling it like this:
val xWsse = usernameToken(object : Credentials {
		override var username: String = "..."
		override var password: String = "..."
	}).getWSSEHeader()
a

araqnid

02/14/2021, 3:24 PM
@JsModule("wsse")
external object WSSE {
    @JsName("default")
    fun usernameToken(credentials: Credentials): UsernameToken
}
d

dave08

02/14/2021, 3:27 PM
Thanks 😒imple_smile:, that worked! Hopefully I'll get used to this conversion eventually, or dukat will work better...
a

araqnid

02/14/2021, 3:31 PM
urgh, yes, the auto-generated Dukat bindings go into the root package 😢 and produces
T$2
for the Credentials interface … and then fails to work on IR with:
var default = $module$wsse.default;
      ^^^^^^^
SyntaxError: Unexpected token 'default'
🙈 2
View count: 7