https://kotlinlang.org logo
Docs
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
  • h

    hellman

    08/27/2019, 7:10 AM
    You can apparently bump Dukat to a later version by setting
    rootProject.kotlinNodeJs.versions.dukat.version = "<VERSION>"
    t
    d
    4 replies · 3 participants
  • b

    Big Chungus

    08/27/2019, 9:49 AM
    Could someone here share their gradle setup for new kotlin.js plugin?
    h
    d
    +2
    17 replies · 5 participants
  • f

    fcosta

    08/27/2019, 12:12 PM
    I noticed that the
    config.output.filename
    property in
    webpack.config.js
    auto generated file changed in the kotlin JS 1.3.50. Is there any way to customize it?
    config.entry.push("/Users/felipecosta/github/chat-app/build/js/packages/chatapp-frontend/kotlin/chatapp-frontend.js");
    config.output = {
        path: "/Users/felipecosta/github/chat-app/frontend/build/distributions",
        filename: "frontend-1.0-SNAPSHOT.js"
    };
    s
    s
    3 replies · 3 participants
  • s

    spierce7

    08/27/2019, 5:44 PM
    I’m using the
    kotlin-multiplatform
    plugin, and I’ve noticed that my js tests aren’t running on 1.3.50. Is there anything special I need to do to make them run?
    s
    g
    17 replies · 3 participants
  • b

    bmjav

    08/28/2019, 7:41 PM
    Hi there. I believe this is a code generation problem in the JS backend: https://pl.kotl.in/luUpaughw `chainc()' method call is not being emitted.
    d
    7 replies · 2 participants
  • p

    Patrick Jackson

    08/29/2019, 3:35 PM
    are there any examples of kotlin compiled to JS and consumed by Javascript? IOW a Javascript app which has a dependency on a kotlin lib? getting hung up on importing the kotlin compiled js. Sorry, JS newb here
    f
    a
    +3
    9 replies · 6 participants
  • p

    Patrick Jackson

    08/30/2019, 3:28 PM
    Anyone interested in helping with a Kotlin MP Redux? Goal is a version of redux that supports all platforms. Specifically looking for someone with some JS expertise to help with consuming shared Kotlin code from actual JS code. Starting point would be the counter sample app. https://reduxkotlin.org
    r
    b
    +1
    16 replies · 4 participants
  • p

    Patrick Jackson

    08/30/2019, 6:12 PM
    Do tests still need to be ran with something like this: https://stackoverflow.com/questions/52618371/how-to-make-my-js-tests-appear-in-kotlin-multiplatform-project
    g
    2 replies · 2 participants
  • j

    Juanoterocas

    08/31/2019, 7:57 PM
    In kotlinx , do I need to write serialization strategy for each List<CustomClass> inside other class?
    d
    17 replies · 2 participants
  • j

    Juanoterocas

    09/01/2019, 7:05 PM
    hi guys , how I do include a custom css file using require? so far I have tried using
    require("css/normalize.css")
    and
    require("./css/normalize.css")
    but i'm getting : Module not found: Error: Can't resolve 'css/normalize.css' in '/home/devquilla/repository/ServerCPSVertx/WalletCPS/dashboard/build/kotlin-js-min/main' @ ./dashboard.js 2777:4-32
    b
    7 replies · 2 participants
  • t

    Tristan Caron

    09/02/2019, 3:38 PM
    Hello, I am trying to start a new project using experimental frontend plugin provided by Kotlin 1.3.50 I am able to write code without any errors, and having code completion. When I am running the code, I am getting this kind of error:
    ERROR in ./kotlin/sample1.js
    Module not found: Error: Can't resolve 'kotlin-react' in '/Users/user/IdeaProjects/project/build/js/packages/project/kotlin'
     @ ./kotlin/project.js 3:4-97
     @ multi ./kotlin/project.js source-map-support/browser-source-map-support.js
    I guess this not integrated in my bundle. How can I do so?
    build.gradle.kt
    b
    b
    16 replies · 3 participants
  • s

    Svyatoslav Kuzmich [JB]

    09/02/2019, 9:38 PM
    Hi! We are designing how Kotlin code will be visible from JavaScript in the new version of Kotlin/JS. I'd like to gather some data. To what extent do you use Kotlin code from JavaScript? 0️⃣ - Kotlin code calls JavaScript, but not vice versa. 1️⃣ - JavaScript calls a few Kotlin functions or uses a couple simple classes. 2️⃣ - JavaScript code uses a substantial portion of Kotlin library API. Thanks!
    1️⃣ 18
    2️⃣ 6
    0️⃣ 27
    j
    t
    4 replies · 3 participants
  • j

    jw

    09/03/2019, 5:55 PM
    Sure you just need to run a JS engine with something like graal or the now-deprecated nashorn or by calling out to V8, QuickJS, Duktape, etc.
    y
    1 reply · 2 participants
  • b

    basher

    09/03/2019, 11:33 PM
    @Michael Bryant
    t
    1 reply · 2 participants
  • s

    Sam Garfinkel

    09/04/2019, 1:46 PM
    Maybe the way webjars packages their stuff?
    z
    9 replies · 2 participants
  • t

    thana

    09/04/2019, 3:42 PM
    in tests wie love to use
    long sententces with blanks as test names
    . As this is not valid in javascript wie use
    @JsName("testN")
    annotations. but this still tedious. is there a way to autogenerate the js functionname for test functions?
    e
    2 replies · 2 participants
  • n

    Nicholas Bilyk

    09/04/2019, 8:14 PM
    I need some help learning webpack for kotlin multiplatform 1.3.50. I see that there can be a webpack.config.d directory that appends configuration to a generated webpack config file, but I can't find any documentation for the syntax of the js files it's expecting. I'd like to be able minify / combine all js dependencies for a production build, but not have the extra processing for dev builds.
    b
    m
    +1
    18 replies · 4 participants
  • s

    Sam Garfinkel

    09/05/2019, 2:39 PM
    Is it safe to call
    RComponent.setState
    (from the Kotlin react wrappers) from a coroutine? I haven't seen any examples of react/coroutine integration.
    :yes: 1
    b
    2 replies · 2 participants
  • m

    mp

    09/05/2019, 3:01 PM
    Anyone can say how I can describe in jsruntime property that is function in my external interface?
    j
    4 replies · 2 participants
  • s

    Sam Garfinkel

    09/05/2019, 5:38 PM
    Hmmm, does the MPP webpack task not install transitive NPM dependencies of Kotlin modules correctly? For example, even with
    implementation("org.jetbrains:kotlin-react:16.9.0-pre.83-kotlin-1.3.50")
    I'm getting
    Module not found: Error: Can't resolve 'react'
    t
    s
    5 replies · 3 participants
  • s

    Sam Garfinkel

    09/05/2019, 5:47 PM
    Nevermind, this is because for whatever reason the wrappers don't declare their dependencies: https://www.npmjs.com/package/@jetbrains/kotlin-react
    b
    1 reply · 2 participants
  • s

    Soren Valle

    09/06/2019, 12:21 AM
    Opinions, improvements?
    class JsonObject {
        val obj = js("({})")
    
        infix fun <T : Any> String.l(other: T) {
            obj[this] = other
        }
    }
    
    fun jo(builder: JsonObject.() -> Unit): Any {
        return JsonObject().apply(builder).obj as Any
    }
    
    fun main() {
        val test = jo {
            "this" l "that"
            "this other" l 1
            "user" l jo {
                "first_name" l "jane"
                "last_name" l "doe"
            }
        }
    }
    j
    s
    +3
    9 replies · 6 participants
  • s

    Soren Valle

    09/07/2019, 1:20 AM
    Is it possible to overload
    functionProperty
    ? If so how?
    external interface SomeInterface {
        var functionProperty: (param1: Type, param2: OtherType) -> ReturnValue
        var functionProperty: (param1: Type) -> ReturnValue
        var functionProperty: () -> ReturnValue
    }
    t
    4 replies · 2 participants
  • s

    Sam Garfinkel

    09/09/2019, 3:21 PM
    New to writing Kotlin wrappers, what is the correct way to wrap an object that consumes another object (i.e.
    Foo({...})
    )?
    s
    t
    13 replies · 3 participants
  • a

    altavir

    09/10/2019, 12:09 PM
    I am wrapping jQuery library and Dukat gives me following definition:
    external interface JQuery {
        fun fancytree(options: FancytreeOptions = definedExternally /* null */): Fancytree
        fun fancytree(option: String? = definedExternally /* null */, vararg rest: Any): Any
    }
    It is obvious that I can't use it with kotlin jquery since this JQuery and jQuery in the bindings are two different things. How can I make it right?
    e
    2 replies · 2 participants
  • m

    mp

    09/10/2019, 2:19 PM
    hi there any chance to get 2 output files from kotlinjs(new plugin 1.3.50) project (working on chrome extension and need 2 files with main() functions)
    g
    s
    5 replies · 3 participants
  • s

    Sam Garfinkel

    09/10/2019, 2:52 PM
    Is there any way to associate multiple
    requires
    with a single wrapper file? For example, the
    swagger-ui
    , which is bundled with
    swagger-ui/dist/swagger.css
    . The CSS should always be required whenever the
    swagger-ui
    export is required. AFAIK you can only have a single
    @file:JsModule(...)
    annotation.
    s
    d
    14 replies · 3 participants
  • s

    Sam Garfinkel

    09/10/2019, 4:50 PM
    Just confirming here, based on what I've seen in several threads, there is currently no type-safe way to support Union Types in KotlinJS? I'm fine with just returning
    dynamic
    , but just wanted to confirm.
    s
    u
    7 replies · 3 participants
  • j

    Jens C.

    09/12/2019, 8:12 AM
    Hey! The latest Idea EAP build still produces non working (out-of-the-box) gradle Kotlin/JS + Kotlin/JVM projects ... is there a simple fix?
    s
    3 replies · 2 participants
  • m

    mp

    09/12/2019, 12:03 PM
    hi there 1) anyone try to avoid dce processing of polyfill file? 2) what is analogue of
    require('webexteision-polyfill')
    in kotlinjs?
    b
    s
    +1
    15 replies · 4 participants
Powered by Linen
Title
m

mp

09/12/2019, 12:03 PM
hi there 1) anyone try to avoid dce processing of polyfill file? 2) what is analogue of
require('webexteision-polyfill')
in kotlinjs?
b

Big Chungus

09/12/2019, 12:04 PM
2. exactly the same. Kotlin stdlib-js has a require function
1. Snippet from https://kotlinlang.org/docs/reference/javascript-dce.html
m

mp

09/12/2019, 12:13 PM
2) with
implementation(kotlin("stdlib-js"))
it import for me
require(val: boolean)
function that assert val and throw exception if false 🤔 not same as
require
some js module
b

Big Chungus

09/12/2019, 12:13 PM
no, there's another one. IDE just throws you a wrong suggestion
m

mp

09/12/2019, 12:13 PM
ok ll check
b

Big Chungus

09/12/2019, 12:21 PM
import kotlinext.js.require
m

mp

09/12/2019, 12:27 PM
I understand what do you mean - but this one is not in stdlib-js but in https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-extensions (an it broke build in my case)
s

Sam Garfinkel

09/12/2019, 1:46 PM
You can just write your own (it's a very simple function):
external fun require(module: String): dynamic = definedExternally
The
= definedExternally
might even be unecessary tbh
b

Big Chungus

09/12/2019, 1:48 PM
= definedExternally
is not needed here as it's a function. It's meant to be used for variables
s

Sam Garfinkel

09/12/2019, 1:49 PM
@Big Chungus TIL
b

Big Chungus

09/12/2019, 1:49 PM
TIL?
s

Sam Garfinkel

09/12/2019, 1:50 PM
"Today I learned"
b

Big Chungus

09/12/2019, 1:50 PM
😄
t

turansky

09/12/2019, 6:29 PM
To avoid dce processing we declare npm dependencies in separate subproject.
ES6
npm dependencies also marked as
external
in webpack
View count: 4