Jim
03/02/2022, 8:13 PM@JsName
and @JsModule
to dukat generated externals?Jim
03/02/2022, 11:01 PMopen class Foo(config: `T$0`) {
open fun bar(id: String): String
}
Then when I look at the js it's a little funky:
var Foo = (function(() {
function Foo(config) {
...
}
Foo.prototype.bar = function(id) {
return "..."
}
}
..continued in thread
Edit: I figured it out - the @JsModule
needs to be for the whole file since it didn't know where T$0
was coming from, I suspectshaktiman_droid
03/03/2022, 1:18 AMjsBrowserDistribution
where we get a fat .js
file.
Here is the output for this for my sample project
shared.js => 122KB
shared.js.map => 49KB
• Another option is to ship library as an NPM module. For example @Big Chungus’s plugin task `packJsNpmPublication`provides output like this for same sample project
npm notice === Tarball Contents ===
npm notice 316.8kB Kmp_Library-shared.js
npm notice 117B package.json
npm notice 71.7kB Kmp_Library-shared.js.map
npm notice 715B Kmp_Library-shared.d.ts
npm notice === Tarball Details ===
npm notice name: shared
npm notice version: 0.1.0
npm notice filename: shared-0.1.0.tgz
npm notice package size: 74.5 kB
npm notice unpacked size: 389.3 kB
# Which number to believe from both options?
Now for example if I want to add kotlinx.datetime
dependency in my project
I want to measure how much size impact it would do to my library user.Partho Paul
03/03/2022, 6:38 AMorg.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileProductionExecutableKotlinJs'
error while compiling my project. I tried deleting build and gradle folder and rebuilding but it didn't fix the issue. Attached in the thread is a snippet of the complete stack trace. Has anyone experienced something similar?
Thanks in advanceAyfri
03/04/2022, 12:32 AMAlex Edwards
03/05/2022, 5:24 AMjava;class;kt;jar;xml;json;ini;config;properties;ts;js;yml;yaml;mf;md
Partho Paul
03/07/2022, 2:50 PMval themeStyles = object : StyleSheet("ComponentStyles", isStatic = true) {
val toolbar by css {
toolbarJsCssToPartialCss(theme.mixins.toolbar)
}
}
But I'm not able to figure out the alternative approach for kotlin-mui. Is there anything trivial which I'm missing?
TIAMoritz Hofmeister
03/09/2022, 8:34 AMMoritz Hofmeister
03/09/2022, 8:45 AMMoritz Hofmeister
03/11/2022, 2:56 PMOutlinedTextFieldProps
in kotlin-mui
in a TextField component?
Are they only accessible through unsafeCast
?
I basically just want to access onChange
Ayfri
03/14/2022, 12:00 PMCannot find module 'C:\Users\pierr\.gradle\yarn\yarn-v1.22.10\bin\yarn.js'
What might be wrong ?shaktiman_droid
03/14/2022, 4:29 PM@JsExport guide for exposing Kotlin to JS
https://dev.to/touchlab/jsexport-guide-for-exposing-kotlin-to-js-20l9GoldenCow
03/15/2022, 4:22 AMMoritz Hofmeister
03/15/2022, 11:26 AMtheme.asDynamic().spacing(2)
julien lengrand-lambert
03/15/2022, 8:45 PMjulien lengrand-lambert
03/16/2022, 9:40 AMindex.js
file like this :
function defaultComparator (a, b) {
return a - b
}
export function isSorted (array, comparator) {
if (!Array.isArray(array)) throw new TypeError('Expected Array, got ' + (typeof array))
comparator = comparator || defaultComparator
for (var i = 1, length = array.length; i < length; ++i) {
if (comparator(array[i - 1], array[i]) > 0) return false
}
return true
}
export function returnValue(value) {
return value;
}
I would like to be able to import both functions from Kotlin, so I do as such
@JsModule("@jlengrand/test-js")
@JsNonModule
external fun <T> isSorted(a: Array<T>): Boolean
@JsModule("@jlengrand/test-js")
@JsNonModule
external fun returnValue(s: String): String
I can use the returnValue
function in my Kotlin code, however, it seems to always try to import the isSorted
function, given the error I get in my console :
Uncaught TypeError: Expected Array, got string....
As you can see, I have tried to extend from that documentation page (https://kotlinlang.org/docs/using-packages-from-npm.html), however I clearly seem to be missing a crucial piece of info.
Would you have any pointers by any chance?Moritz Hofmeister
03/16/2022, 2:30 PMmin
attribute and cannot figure out how to do it correctly:
var InputBaseComponentProps.min: String
get() = throw IllegalStateException()
set(value) {
return when (this) {
is HTMLInputElement -> min = value
else -> throw IllegalArgumentException("There is no min in this InputBaseComponentProps")
}
}
This results in an exception because it apparently does not match with HTMLInputElement.
As a reference, this works:
val HTMLElement.value: String
get() = when (this) {
is HTMLInputElement -> value
is HTMLTextAreaElement -> value
else -> throw IllegalArgumentException("There is no value in this HTMLElement")
}
Michal Klimczak
03/17/2022, 7:12 PMMoritz Hofmeister
03/18/2022, 1:08 PMOutlinedTextFieldProps
for TextField
leads to not having the ChildrenBuilder
in the current scope - This also means that it’s not possible to nest other (kotlin-mui) components without casting to the ChildrenBuilder first.
Is there a nice way to solve this issue?zilin jin
03/19/2022, 7:16 PMCLOVIS
03/20/2022, 12:08 PMCouldn't find package pkg-dir
since yesterday... Has anyone seen it already?
full error message: https://gitlab.com/opensavvy/formulaide/-/jobs/2224663228#L65Jim
03/22/2022, 6:16 PMSam Stone
03/23/2022, 1:54 PMJulius
03/23/2022, 10:35 PMGrégory Lureau
03/24/2022, 6:01 PM@JsExport
doesn't provide but @KustomExport
does:
• support exporting enum
, interface
, sealed class
• ability to remove the namespace
• support exporting List
(mapped into Array
)
• remove useless methods from data class
• support suspend
methods (with cooperative cancellation via AbortController)
Do you need something else? Please open an issue to help this project!
Have a nice day Kotlin developers! :kotlin-intensifies:Grégory Lureau
03/26/2022, 9:41 PMinternal
+ lateinit
field inside a @JsExport
annotated class.
TypeError: Cannot read properties of undefinedDid you already experienced something similar? Or am I missing something new in the compiler?
Slackbot
03/28/2022, 3:56 AMAkram Bensalem
03/29/2022, 6:47 PMbrowser()
inside the js(IR){}
+ when I remove browser()
and try to run the app
I got this error
Task 'jsBrowserDevelopmentRun' not found in project ':webApp'
ankushg
03/29/2022, 8:55 PMRan
03/30/2022, 8:43 AMval jsMain by getting {
dependencies {
implementation(npm("big-number", "2.0.0", true))
}
}
In jsMain, I use external to tell compiler that the BigNumber class is implemented by js:
external class BigNumber(raw: dynamic) {
fun plus(number: BigNumber): BigNumber
}
The I use BigNumber in kotlin code, but i get this error:
ReferenceError: BigNumber is not defined
Is there anyone can give me a help, thanks so much.Ran
03/30/2022, 8:43 AMval jsMain by getting {
dependencies {
implementation(npm("big-number", "2.0.0", true))
}
}
In jsMain, I use external to tell compiler that the BigNumber class is implemented by js:
external class BigNumber(raw: dynamic) {
fun plus(number: BigNumber): BigNumber
}
The I use BigNumber in kotlin code, but i get this error:
ReferenceError: BigNumber is not defined
Is there anyone can give me a help, thanks so much.Grégory Lureau
03/30/2022, 9:12 AMRan
03/30/2022, 9:16 AMBig Chungus
03/30/2022, 9:24 AMRan
03/30/2022, 9:24 AMBig Chungus
03/30/2022, 2:30 PM