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

    Sean Keane

    02/18/2020, 3:07 PM
    is a way to remove the 2mb size from the Kotlin Requirement? I’m publishing a NPM lib and it seems to be dependant on
    require("kotlin")
    s
    a
    e
    • 4
    • 62
  • j

    Jaxon Du

    02/18/2020, 5:57 PM
    Has anyone gotten kotlin-js working with SvelteJS? Any sample codes?
    r
    • 2
    • 1
  • f

    Fleshgrinder

    02/18/2020, 6:58 PM
    I hope this is the right place to ask these questions: 1. Are there no conversion function from any kind of
    ArrayBuffer
    to a Kotlin array and/or vice-versa? 2. How do you await a
    Promise<S>
    while blocking execution? (
    let x = await f()
    )
    v
    g
    • 3
    • 13
  • c

    Chenn

    02/19/2020, 10:47 AM
    Is there any way to create generator functions in Kotlin JS ?
    p
    • 2
    • 12
  • m

    mirror-kt

    02/19/2020, 12:00 PM
    Is there any way to get URL hash values as Map or data class? I already could get hashes as string (props.location.hash), but I want to parse it.
    s
    d
    r
    • 4
    • 11
  • s

    spierce7

    02/19/2020, 7:06 PM
    kotlin-js has an output directory within the root project. Do I have any ability to move that?
    i
    • 2
    • 1
  • c

    corneil

    02/20/2020, 7:47 AM
    I learned a lot about calling Kotlin/JS from JavaScript while implementing this same for using KFSM. https://github.com/open-jumpco/kfsm-webjs I would prefer Kotlin/JS all the way but that isn't the reality because there are so many JS tools involved in building JavaScript for the browsers. Here is my Kotlin/JS version for comparison. https://github.com/open-jumpco/kfsm-web
    g
    • 2
    • 4
  • m

    MrPowerGamerBR

    02/20/2020, 6:05 PM
    Okay, thank you @Svyatoslav Kuzmich [JB] 🙂 , it would be nice if the tutorial was updated because it is kinda confusing when there is both
    kotlin2js
    and the new multiplatform way on the website, makes you wonder "okay, so what's the right one?"
    ➕ 2
    r
    j
    s
    • 4
    • 4
  • a

    audriusk

    02/21/2020, 9:20 AM
    Seems that currently output from gradle js modules is in
    rootProject/build/js
    Is there any easy way to change output to be in subModule dir? e.g.
    submodule/build/dest
    Usecase: firebase functions deployment. It requires all files of proper node project (packages.json, src, etc)
    c
    • 2
    • 1
  • a

    Adam Szadkowski

    02/23/2020, 9:29 AM
    Using the newest kotlin.js plugin for gradle (like it is described in https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/01_Introduction ) - has anyone tried to include there some css dependency? For example bootstrap or something else? When I try to load it as a regular module:
    @JsModule("typeface-roboto")
    @JsNonModule
    external val roboto: dynamic
    I am getting an error that webpack is unable to load css:
    Module parse failed: Unexpected character '@' (2:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
    But still - looking at DSL for
    kotlin.target.browser { }
    I was not able to find anything which would allow to add new loader. Is there any solution to this?
    r
    s
    • 3
    • 7
  • f

    Fleshgrinder

    02/24/2020, 1:33 PM
    Is there something special one needs to configure to get
    jsBrowserTest
    to work on a Mac? The headless chrome that is started by default does not seem to work at all: https://github.com/Fleshgrinder/kotlin-uuid/runs/464690932?check_suite_focus=true
    s
    i
    • 3
    • 5
  • r

    ribesg

    02/24/2020, 8:12 PM
    Uh wtf? Here's the content of a file,
    webpack.config.d/chunk.js
    config.optimization = {
        moduleIds: 'hashed',
        runtimeChunk: 'single',
        splitChunks: {
            cacheGroups: {
                vendor: {
                    test: /[\\/]node_modules[\\/]/,
                    name: function(module) {
                        const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
                        return `npm.${packageName.replace('@', '')}`;
                    }
                }
            }
        }
    };
    And here's the matching
    webpack.evaluated.config.js
    part:
    optimization: {
        moduleIds: 'hashed',
        runtimeChunk: 'single',
        splitChunks: {
          cacheGroups: {
            vendor: {
              test: /[\\\/]node_modules[\\\/]/,
              name: [Function: name]
            }
          }
        }
      }
    What should I do with that?
    :youtrack: 1
    t
    i
    • 3
    • 7
  • t

    Thanhhai08sk

    02/25/2020, 8:47 AM
    This is the compiled javascript from my "SharedCode" Kotlin module
    ...
    function createApplicationScreenMessage() {
      return 'Kotlin Rocks on ' + platformName();
    }
    var package$kotlinnativetest = package$org.kotlinnativetest || (package$org.kotlinnativetest = {});
    package$kotlinnativetest.main = main;
    package$kotlinnativetest.createApplicationScreenMessageJs = createApplicationScreenMessage;
    ...
    This is maybe a dumb question but I'm new to js. How could I call the "createApplicationScreenMessageJs" function in js?
    i
    e
    t
    • 4
    • 27
  • s

    spierce7

    02/26/2020, 3:34 AM
    I’m trying to use Kotlin for firebase functions. I’m getting problems because Kotlin is exporting other keys as well, which makes firebase throw an error. Here are the additional keys it has that it shouldn’t:
    $$importsForInline$$,com,firebase
    Firebase basically expects a node file with only firebase functions exported. How can I achieve this?
    t
    a
    i
    • 4
    • 14
  • g

    galex

    02/26/2020, 9:32 AM
    What’s the best stack added to Kotlin/JS to make nice material style apps? I’d love to use Material UI on React but I didn’t enjoy working with the existing libraries I found back then, and I’m open to any web framework
    r
    a
    • 3
    • 5
  • b

    Benoit Quenaudon

    02/26/2020, 4:36 PM
    Hi I am using composite builds in my project and it looks like the
    KotlinCompilationNpmResolver
    isn't able to resolve it. The
    --info
    would show me that the nested project's module has been found to then tell me that it cannot find the project
    Selected primary task ':wire-tests:jsPackageJson' from project :wire-tests
    Found project 'project :wire-library:wire-runtime' as substitute for module 'com.squareup.wire:wire-runtime'.
    Found project 'project :wire-library:wire-grpc-client' as substitute for module 'com.squareup.wire:wire-grpc-client'.
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':wire-tests:jsPackageJson'.
    > Cannot find project :wire-runtime
    The stracktrace brings me to https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt#L185 It looks like the
    project.projectRegistry
    only has access to the root modules, and none of the `includedBuild`'s modules are in there.
    s
    s
    • 3
    • 5
  • s

    sean

    02/26/2020, 7:33 PM
    I'm trying the new 1.3.70-eap for
    JSExport
    with the compiler opts. I'm getting out a
    .js
    and
    .d.ts
    file. But when trying to import into a
    ts
    project I'm getting
    output.d.ts is not a module
    The top level looks like
    declare namespace output {
        type Nullable<T> = T | null | undefined
        namespace my.test.project
            .....
        }
    }
    Is there an example of how to properly structure / bundle the output into a npm package?
    s
    e
    • 3
    • 5
  • u

    uliluckas

    02/26/2020, 8:45 PM
    Is there a known issue with gradle not finding node? I get
    Could not find org.nodejs:node:12.14.0
    with kotlin eap and `Could not find org.nodejs:node:10.15.3.`with the stable release
    i
    u
    • 3
    • 6
  • u

    uli

    02/27/2020, 10:16 AM
    btw. this ^^^ is on a raspberry pi. It seems to work on mac
    h
    u
    • 3
    • 2
  • s

    Sean Keane

    02/27/2020, 2:05 PM
    So I’m trying to use JS -> Kotlin. But every time I try and use a method the names are scrambled. I want to have
    commonLib.myTestMap.get("key")
    But the method available to me is
    commonLib.myTestMap.get_11rb$("key")
    Is there any way of having a standard getter for the keys in the map?
    a
    i
    e
    • 4
    • 49
  • h

    hallvard

    02/27/2020, 2:38 PM
    Do you control the map? Can you annotate the getter with @JsName ?
    s
    i
    • 3
    • 12
  • s

    spierce7

    02/27/2020, 10:54 PM
    has anyone been able to get js code coverage to work?
    d
    • 2
    • 4
  • s

    spierce7

    02/28/2020, 5:32 AM
    Does anyone know why this isn’t working?
    implementation(npm("@jetbrains/kotlin-react"))
    i
    • 2
    • 2
  • r

    ribesg

    02/29/2020, 10:09 AM
    I don't understand the implementation of React Context in the wrapper. How do you get the
    dispatch
    function?
    useContext
    only returns the state
    n
    • 2
    • 5
  • g

    Grantas33

    03/01/2020, 4:56 PM
    Hello. Has anyone had success in making progressive web apps with kotlin.js?
    a
    r
    • 3
    • 5
  • j

    jw

    03/03/2020, 4:23 AM
    i'm migrating from kotlin2js/frontend/dce to org.jetbrains.kotlin.js. How do I set webpack into production mode?
    t
    i
    • 3
    • 5
  • o

    Omar Ahmed

    03/03/2020, 9:42 AM
    I made a multiplatform library how can I ship it to js?
    r
    s
    e
    • 4
    • 24
  • s

    Sean Keane

    03/03/2020, 2:32 PM
    Is there any documentation on working with Webpack in Kotlin 1.3.70?
    s
    i
    +2
    • 5
    • 64
  • j

    jw

    03/04/2020, 2:58 AM
    with the new js plugin writing into build/distributions/, it's hard to use the distribution plugin to then zip that directory (because it wants to write it into build/distributions/. Are people just writing their own zip tasks to avoid this mess?
    i
    t
    • 3
    • 4
  • r

    rnentjes

    03/04/2020, 9:55 AM
    Using the new kotlin/js 1.3.70, how do I get my dependencies (i.e. kotlin.js) in the distribution folder with dce applied to it? Or even better, can I get the dependencies included in one js file?
    i
    s
    • 3
    • 6
Powered by Linen
Title
r

rnentjes

03/04/2020, 9:55 AM
Using the new kotlin/js 1.3.70, how do I get my dependencies (i.e. kotlin.js) in the distribution folder with dce applied to it? Or even better, can I get the dependencies included in one js file?
i

Ilya Goncharov [JB]

03/04/2020, 10:01 AM
After
build
task you get
build/distributions
folder with one js bundle with all included dependencies
r

rnentjes

03/04/2020, 10:17 AM
Ok, this works for me on a newly created project, so that's good. But when trying to migrate an existing mpp project I get an error where a dependency depending on kotlin.js is loaded before kotlin.js. I am guessing the dependency (https://github.com/rnentjes/komponent) needs to be updated. Anyone has an example of how to create a library for kotlin-js/mpp 1.3.70?
Otherwise I'll take a look at an mpp lib like serialization.
s

Sean Keane

03/04/2020, 10:42 AM
@Ilya Goncharov [JB] does this use all the DCE’d libraries from the gradle import? I have a very simple network request but the whole *.js output is sitting at 2mb
r

rnentjes

03/04/2020, 12:45 PM
I made a minimal example (https://gitbucket.astraeus.nl/rnentjes/test-pure-kotlin-js) and updated the included project (https://gitbucket.astraeus.nl/rnentjes/komp) and it gives the following error when running browserDevelopmentRun:
komp.js:2 Uncaught Error: Error loading module 'komp'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'komp'.
at eval (komp.js:2)
at Object.../../packages_imported/komp/0.1.16-SNAPSHOT/komp.js (test-pure-kotlin-js.js:477)
at __webpack_require__ (test-pure-kotlin-js.js:30)
at eval (test-pure-kotlin-js.js:3)
at eval (test-pure-kotlin-js.js:8)
at Object../kotlin/test-pure-kotlin-js.js (test-pure-kotlin-js.js:510)
at __webpack_require__ (test-pure-kotlin-js.js:30)
at Object.0 (test-pure-kotlin-js.js:522)
at __webpack_require__ (test-pure-kotlin-js.js:30)
at test-pure-kotlin-js.js:94
eval @ komp.js:2
../../packages_imported/komp/0.1.16-SNAPSHOT/komp.js @ test-pure-kotlin-js.js:477
__webpack_require__ @ test-pure-kotlin-js.js:30
eval @ test-pure-kotlin-js.js:3
eval @ test-pure-kotlin-js.js:8
./kotlin/test-pure-kotlin-js.js @ test-pure-kotlin-js.js:510
__webpack_require__ @ test-pure-kotlin-js.js:30
0 @ test-pure-kotlin-js.js:522
__webpack_require__ @ test-pure-kotlin-js.js:30
(anonymous) @ test-pure-kotlin-js.js:94
(anonymous) @ test-pure-kotlin-js.js:97
webpackUniversalModuleDefinition @ test-pure-kotlin-js.js:9
(anonymous) @ test-pure-kotlin-js.js:10
client?fdcd:52 [WDS] Live Reloading enabled.
Turns out there where some subtle changes with previous versions. For one the artifact name now gets the -js addition automatically. Any dependencies of dependencies are not automatically included anymore, this probably required some extra configuration now (?)
👍 1
View count: 5