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

    Gurupad Mamadapur [FH]

    12/24/2019, 12:34 PM
    Running into these issues while using a shared module(mpp) which has ktor-js dependency for javascript target-
    Module not found: Error: Can't resolve 'text-encoding' 
    Module not found: Error: Can't resolve 'abort-controller' 
    Module not found: Error: Can't resolve 'utf-8-validate' 
    Module not found: Error: Can't resolve 'bufferutil'
    g
    • 2
    • 4
  • r

    Robert Jaros

    12/26/2019, 1:30 PM
    If anyone is interested, all KVision example apps from https://github.com/rjaros/kvision-examples have been refactored to use new Kotlin/JS plugin instead of the deprecated frontend plugin. The changes include: - New Kotlin/JS plugin for all non-MPP and MPP projects - Support for development with webpack dev server and HMR - Support for production builds with both DCE and webpack optimizations - Support for testing with Karma and headless Chrome - Workarounds for some issues, including KT-34287 and KT-32531 - Update Gradle to the latest version (6.0.1) with all deprecation warnings fixed
    👍 16
    s
    • 2
    • 1
  • s

    Samuel Michael

    12/27/2019, 12:10 PM
    hi working on a kotlin JS hello world but don’t get anything print out in js console
    i
    • 2
    • 9
  • s

    Samuel Michael

    12/27/2019, 4:42 PM
    is there anyway to get a starter template that works out of the box?
    i
    • 2
    • 7
  • c

    camdenorrb

    12/28/2019, 6:33 AM
    How do I bundle my kotlin code to a js file? Right now it's making a jar even though I'm using the kotlin js gradle plugin...
    i
    b
    • 3
    • 33
  • p

    Paul N

    12/30/2019, 2:34 PM
    Hopefully this is a common issue that someone can help me with ? I've got a data class that has a kotlin,js.Date on it. If I print out the value of it via console.log I get: 2019-12-29T13:30:00.000+0000 I'm trying to get the hours portion so I do
    date.getHours()
    and I'm getting "TypeError: date.getHours is not a function" as an error in the browser. I don't quite understand this; does my date object not contain a date or something ?
    i
    • 2
    • 3
  • t

    tylerwilson

    12/30/2019, 5:52 PM
    Trying to add js target to an existing Android/iOS MP library. When I try to add npm dependency, I get:
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':salonbizlibrary:jsPackageJson'.
    > NPM Dependencies already resolved and installed
    This is the js sestion:
    jsMain {
                dependencies {
                    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version"
    
                    implementation "io.ktor:ktor-client-js:$ktor_version"
                    implementation "io.ktor:ktor-client-core-js:$ktor_version"
                    implementation "io.ktor:ktor-client-json-js:$ktor_version"
                    implementation "io.ktor:ktor-client-serialization-js:$ktor_version"
    
                    //implementation(npm("moment", "2.24.0"))
                    implementation(npm("crypto-js", "3.1.9-1"))
                }
            }
    If I do not include the npm dependency, it builds fine.
    p
    • 2
    • 3
  • p

    pavel.v

    01/01/2020, 2:10 PM
    I am using kotlin-redux from kotlin-wrappers, when i try to run app, compiler says me “When accessing module declarations from UMD, they must be marked by both @JsModule and @JsNonModule”. How can i fix this problem? At the same time i use kotlin-react, and calling render function doesn’t give this error but it is not marked with JsNonModule annotation
    👍 1
    b
    e
    • 3
    • 2
  • p

    Paul N

    01/01/2020, 10:26 PM
    What should I be using to manage the builds of a Kotlin React project ? Should it be: 1. Create Kotlin React App 2. Gradle - Kotlin Frontend plugin 3. Gradle - Kotlin.JS plugin I see that Jetbrains seem to be pushing option 3, as per this link https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/01_Introduction but I'm struggling to find an example of a gradle build file that uses the Kotlin.js plugin. What do people use ?
    3️⃣ 1
    👍 1
    a
    • 2
    • 1
  • t

    Tobi

    01/03/2020, 2:56 PM
    Hey folks, I am trying to configure npm dependencies through gradle, but apparently I am doing it wrong 😕 My build.gradle looks like this and I am getting the following error:
    Could not find method npm() for arguments [org.jetbrains:kotlin-react, 16.9.0-pre.83] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    Thanks in advance.
    plugins {
        id 'org.jetbrains.kotlin.js' version '1.3.61'
        id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.61'
    }
    
    group 'org.example'
    version '1.0-SNAPSHOT'
    
    repositories {
        maven {
            url "<https://dl.bintray.com/kotlin/kotlin-eap>"
        }
        mavenCentral()
        jcenter()
    }
    
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
        implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.14.0"
        implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.2'
        implementation "io.ktor:ktor-client-js:1.2.6"
        implementation "io.ktor:ktor-client-json-js:1.2.6"
        implementation("io.ktor:ktor-client-serialization-js:1.2.6")
        testImplementation "org.jetbrains.kotlin:kotlin-test-js"
        implementation(npm("org.jetbrains:kotlin-react", "16.9.0-pre.83"))
        implementation(npm("org.jetbrains:kotlin-react-dom", "16.9.0-pre.83"))
    
    }
    
    kotlin {
        target {
            browser {}
            nodejs {}
        }
    }
    r
    i
    p
    • 4
    • 20
  • a

    Alexander

    01/04/2020, 7:01 PM
    Has anyone implemented GeoQuery with Cloud firestore?
    m
    • 2
    • 3
  • p

    Paul N

    01/05/2020, 6:22 PM
    Hi - another gradle doesn't seem to be picking up npm dependencies thread I'm afraid ! Any help greatly appreciated. Basically classes like the react ones aren't being picked up and my Kotlin doesnt compile. Example bit of code that doesn't compile:
    import react.*
    and my gradle build file (this time in Kotlin):
    plugins {
        id("org.jetbrains.kotlin.js") version "1.3.61"
    }
    
    repositories {
        mavenCentral()
        jcenter()
    }
    
    kotlin {
        sourceSets.forEach { sourceSet ->
    
            // double check source sets are OK
    
            sourceSet.kotlin.sourceDirectories.files.forEach {
                println(it.absoluteFile)
            }
        }
        sourceSets["main"].dependencies {
            implementation(npm("react", "16.8.3"))
            implementation(npm("@jetbrains/kotlin-css", "1.0.0-pre.89"))
            implementation(npm("@jetbrains/kotlin-css-js", "1.0.0-pre.89"))
            implementation(npm("@jetbrains/kotlin-styled", "1.0.0-pre.89"))
            implementation(npm("react-google-charts"))
    
        }
        target {
    
            browser {
    
            }
        }
    }
    
    dependencies {
        implementation(kotlin("stdlib-js"))
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.2")
    }
    
    contents of generated file .......build/js/packages/myprojectname/package.json
    
    {
      "main": "kotlin/myprojectfile.js",
      "devDependencies": {
        "webpack": "4.41.2",
        "webpack-cli": "3.3.9",
        "webpack-dev-server": "3.8.2"
      },
      "dependencies": {
        "kotlin": "1.3.61",
        "kotlinx-coroutines-core": "1.3.2",
        "kotlin-source-map-loader": "1.3.61",
        "react": "16.8.3",
        "@jetbrains/kotlin-css": "1.0.0-pre.89",
        "@jetbrains/kotlin-css-js": "1.0.0-pre.89",
        "@jetbrains/kotlin-styled": "1.0.0-pre.89",
        "react-google-charts": "*"
      },
      "peerDependencies": {},
      "optionalDependencies": {},
      "bundledDependencies": [],
      "name": "myprojectfile",
      "version": "0.0.0-unspecified"
    }
    p
    • 2
    • 2
  • n

    Nikky

    01/07/2020, 10:18 PM
    so i also tried using kotlin2js, frontend and dce together in a subproject.. but that broke in other ways when i tried to depend on the
    :shared
    multiplatform project i am not sure what the "correct" way to do this is anymore
    j
    • 2
    • 1
  • s

    spierce7

    01/09/2020, 4:51 AM
    So even when using the dce plugin, the output is over 100kb. Can anything be done about this aside from minifying the files, or is this as good as it gets?
    j
    a
    +2
    • 5
    • 6
  • i

    iseki

    01/09/2020, 12:54 PM
    Hello everyone, Is there anyway setup yarn/npm registry or proxy in build.gradle.kts ? I found no docs for it Thank you. Kotlin version 1.3.61
    t
    • 2
    • 1
  • i

    iseki

    01/09/2020, 1:54 PM
    Are there anyone can help me solve this problem? I don't know how to modify --Xmx parameter... Logs: https://paste.ubuntu.com/p/3JQfqFc9Sb/ Thanks
    p
    • 2
    • 1
  • i

    Ivan Osipov

    01/10/2020, 11:17 AM
    Hi, guys. Thanks a lot for your answers for many different questions above. Search in Slack is much more helpful than google 🙂 I'm struggling with running a small react app which is a gradle module of a bigger project. I see that intellij generates multiple source sets for multiplatform what looks weird for me because it can be multiple frontends, so now I use just gradle mudules and kotlin("js") plugin inside one of modules It's ok if I work with the module as with an independent project but when it is a module then the plugin creates build folder on root project level. Should that case work properly now? Are there some examples (using the latest kotlin js plugin within a module of a project)? Gradle 6.0.1 kotlin.js (kotlin("js") plugin ) 1.3.61
    t
    f
    +2
    • 5
    • 12
  • m

    mzgreen

    01/12/2020, 4:08 PM
    Is there a sample showing how to use web workers in KotlinJS? I have no prior js experience so JS code is not very helpful for me.
    j
    d
    +2
    • 5
    • 12
  • n

    Nikky

    01/12/2020, 6:14 PM
    how do i get access to console.debug() ? i would also use kotlin-logging if i could then jump to callsite in debugtools but it just guides me to where the library calls console.log()
    p
    b
    • 3
    • 3
  • n

    Nikky

    01/13/2020, 10:32 AM
    is there a channel for dukat support / help in fixing the generated files ?
    i
    • 2
    • 2
  • n

    Nikky

    01/13/2020, 12:03 PM
    it would be nice if dukat could use existing external declarations along with their original
    .d.ts
    source to reference the manually fixed up typedefinition of eg. https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-react i believe there is a huge demand for generating externals for all kinds of react components that are compatible with the jetbrains maintained wrappers
    e
    • 2
    • 1
  • i

    Ilya Goncharov [JB]

    01/13/2020, 2:38 PM
    Hi there! We announce 1.3.70 EAP (https://discuss.kotlinlang.org/t/kotlin-1-3-70-early-access-preview/15876) It brings some Kotlin/JS related stuff, including long awaited support of DCE in js plugin
    🎉 26
    a
    n
    +3
    • 6
    • 23
  • r

    Robert Jaros

    01/13/2020, 4:51 PM
    No work at all on KT-34287 ? It should be relatively easy to fix and it's really important for developing any Kotlin/JS libraries.
    s
    • 2
    • 1
  • t

    thana

    01/14/2020, 9:35 AM
    where can i find the altest state of the new kotlin/js-build(tool) docs? i forgot the linke 🙈
    e
    • 2
    • 2
  • v

    Vladyslav Sitalo

    01/15/2020, 4:20 AM
    is there a way to add custom content to the
    package.json
    generated by KotlinJS plugin? (looking to update the
    scripts
    section like here: https://github.com/sindresorhus/alfy#publish-to-npm)
    i
    • 2
    • 2
  • t

    thana

    01/15/2020, 8:51 AM
    how to use
    browserWebpack
    corretly? i realised the bundled js file e.g. does not contain the kotlin.js dependency... is adding
    implementation(npm("kotlin", "${extra["kotlin_version"]}"))
    the correct way to reach this? I cannot try that because then it says "Cannot find kotlin@1.3.61 in yarn.lock". What am i missing?
    r
    • 2
    • 3
  • n

    Nikky

    01/16/2020, 9:49 AM
    how do i publish my js to mavenLocal using the new plugin and kotlin
    1.3.70-eap-42
    ? i tried to apply https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#publishing-a-multiplatform-library but it seems to not work
    d
    i
    • 3
    • 11
  • p

    pjagielski

    01/16/2020, 10:15 AM
    Hi all! I'm looking for a reference multiplatform template project using kotlin.js plugin with react, hot-reload and shared frontend/backend model, anyone? Found this https://github.com/snrostov/kotlin-full-stack-application-demo but could not get it to work...
    ➕ 1
    s
    • 2
    • 5
  • i

    iseki

    01/17/2020, 5:12 AM
    When we can add production mode to gradle build? Looks we need add custom config file when build......
    s
    • 2
    • 2
  • p

    pjagielski

    01/17/2020, 1:05 PM
    Is it possible to configure webpack (eg. dev server port) in kotlin-js plugin as in kotlin-frontend-plugin?
    b
    i
    r
    • 4
    • 12
Powered by Linen
Title
p

pjagielski

01/17/2020, 1:05 PM
Is it possible to configure webpack (eg. dev server port) in kotlin-js plugin as in kotlin-frontend-plugin?
b

bashor

01/17/2020, 2:07 PM
cc @Ilya Goncharov [JB]
i

Ilya Goncharov [JB]

01/17/2020, 2:26 PM
It is possible to declare it with
webpack.config.d
You can create js file in it with content smth like
config.devServer = config.devServer || {}
config.devServer.port = ...
r

Robert Jaros

01/17/2020, 2:40 PM
You can configure port and some other options with gradle DSL:
runTask {
                outputFileName = "main.bundle.js"
                devServer = KotlinWebpackConfig.DevServer(
                    open = false,
                    port = 3000,
                    contentBase = listOf("$buildDir/processedResources/frontend/main")
                )
            }
and other parameters with
webpack.config.d
p

pjagielski

01/17/2020, 2:46 PM
so in build.gradle it should be
kotlin {
  js {
    browser {
       runTask ...
}
?
webpack.config.d
approach is a bit too low, maybe for webdevs, not kotlin programmers, that were promised that webpack is managed by plugin 😉
and
8080
as default is a bit too agressive I think 😉
for backend dev
i

Ilya Goncharov [JB]

01/17/2020, 2:51 PM
Like @Robert Jaros told, you can configure it via
kotlin {
  js {
    browser {
       runTask {
           devServer = KotlinWebpackConfig.DevServer(
               port = 3000,
               contentBase = listOf("$buildDir/processedResources/frontend/main"
           )
       }
}
But in case with
webpack.config.d
you do stuff via low level js config, but don’t need to overwrite
contentBase
property We think about how to do good DX with gradle plugin for this purposes.
👍 1
p

pjagielski

01/17/2020, 2:54 PM
not a gradle expert, how can I find the config path in plugins' source code?
org.jetbrains.kotlin.gradle.targets.js.dsl
?
i

Ilya Goncharov [JB]

01/17/2020, 2:57 PM
org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
if it is what you want
👍 1
View count: 8