Jared Vu
09/22/2022, 4:51 PMval names are replaced. For the given class,
@JsExport
data class Foo (
val configs: Configs?,
)
I would expect the exported JS to have a key configs but instead it is replaced with
this.b1q_1 = configs;
Is there any way to preserve the human readable val names within our exported class?ephemient
09/22/2022, 4:58 PM@JsName("configs")
val configs: Configs?Jared Vu
09/22/2022, 5:25 PMJared Vu
09/22/2022, 10:27 PMjs config for KotlinMultiplatformExtension is
js(IR) {
browser {
testTask {
useMocha {
timeout = "10s"
}
}
}
binaries.library()
browser()
}
and I am using mpetuska’s npm-publish lib to assemble the js package.Big Chungus
10/04/2022, 9:49 PMJared Vu
11/09/2022, 9:59 PMdata class to a regular class but it seems like the variable names are still not surfaced.
Here are some screenshots of .kt -> .js -> .d.tsBig Chungus
11/09/2022, 10:58 PMJared Vu
11/10/2022, 12:20 AMBig Chungus
11/10/2022, 10:22 AMMichael Friend
11/14/2022, 9:37 PMconfigs property is hidden as b1q_1 in your case to prevent anyone from using the field directly. to give access the compiler generates a statement like this which should allow you to access the property as foo.configsMichael Friend
11/14/2022, 9:39 PMget configs(): Nullable<…Configs>Michael Friend
11/14/2022, 9:40 PMvar you’ll have a similar defineProperty call that also provides a set, as well as a corresponding set configs(): ... line in the d.tsephemient
11/14/2022, 9:54 PMObject.defineProperty(Foo.prototype, 'configs', { ... })Jared Vu
11/15/2022, 5:52 PMJohn Huang
11/15/2022, 5:57 PMJohn Huang
11/15/2022, 7:10 PMMichael Friend
11/15/2022, 7:30 PMval properties. you may be stuck just writing a wrapper class in js around your Kotlin classes so you can use them in reduxJohn Huang
11/15/2022, 7:38 PMJohn Huang
11/15/2022, 7:39 PMMichael Friend
11/15/2022, 7:41 PMfoo_1 but im not sure what causes it to be more readable. Probably changes in different kotlin versions, this is on 1.6.21John Huang
11/15/2022, 7:42 PMMichael Friend
11/15/2022, 7:49 PMMichael Friend
11/15/2022, 7:49 PMJohn Huang
11/15/2022, 7:55 PMMichael Friend
11/15/2022, 7:56 PMdevelopment and production flavors of the JS gradle tasks but they both produce configs_1 for me so im not sure why yours is differentMichael Friend
11/15/2022, 7:57 PMJohn Huang
11/15/2022, 7:58 PMJohn Huang
11/15/2022, 8:00 PMMichael Friend
11/15/2022, 8:07 PMcollection-import module. I can take some time to try to throw together a standalone repo with just js test stuff sometime tonight/tomorrow if you want something simpler https://github.com/mrf7/KMMtg/tree/test/js-testingJohn Huang
11/15/2022, 8:16 PMJohn Huang
11/15/2022, 8:22 PMbinaries.executable() vs binaries.library()John Huang
11/15/2022, 8:25 PM@JsExport, which we have to use for binaries.library()John Huang
11/15/2022, 8:31 PMbinaries.library(), even without @JsExport, the members are still obfuscatedMichael Friend
11/15/2022, 8:46 PM@JsExport by mistake. I readded it and switched from executable to library and im still getting configs_1 🤷 pushed to that branch if you want to try itJohn Huang
11/15/2022, 9:55 PMgradle build fails. I have tried gradle jsPackageJson and gradle jsMainClasses and I cannot find the generated js files.Michael Friend
11/15/2022, 10:28 PMkotlinBrowser I think. Pretty sure it was something like somethingProductionWebpackBig Chungus
11/15/2022, 10:52 PMMichael Friend
11/15/2022, 10:52 PMBig Chungus
11/15/2022, 10:52 PMBig Chungus
11/15/2022, 10:53 PMMichael Friend
11/15/2022, 11:19 PMJohn Huang
11/15/2022, 11:44 PMfunction Foo(configs) {
this.d26_1 = configs;
}Michael Friend
11/15/2022, 11:49 PMJohn Huang
11/16/2022, 12:21 AMJohn Huang
11/16/2022, 12:21 AMJohn Huang
11/16/2022, 1:08 AMMichael Friend
11/16/2022, 5:09 PMJohn Huang
11/16/2022, 5:39 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
buildscript {
val agp_version by extra("7.2.2")
repositories {
//gradlePluginPortal()
//google()
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0")
classpath("com.android.tools.build:gradle:$agp_version")
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
plugins {
kotlin("multiplatform") version "1.6.21"
kotlin("plugin.serialization") version "1.4.0"
id("maven-publish")
}
group = "exchange.dydx.abacus"
version = "1.0.27"
repositories {
google()
mavenCentral()
}
kotlin {
js(IR) {
browser {
testTask {
useMocha {
timeout = "10s"
}
}
}
browser()
binaries.library()
}
sourceSets {
val ktorVersion = "2.1.1"
val napierVersion = "2.6.1"
all {
languageSettings.apply {
optIn("kotlin.js.ExperimentalJsExport")
}
}
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0-RC")
implementation("io.github.aakira:napier:$napierVersion")
implementation("co.touchlab:stately-common:1.2.0")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("com.ionspin.kotlin:bignum:0.3.7")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlin:kotlin-test-common")
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
}
}
val jsMain by getting
val jsTest by getting
}
tasks.wrapper {
gradleVersion = "7.5.1"
distributionType = Wrapper.DistributionType.ALL
}
}John Huang
11/16/2022, 5:40 PMMichael Friend
11/21/2022, 9:20 PM1.6.21 IR gives str_1
1.6.21 LEGACY gives str (unobfuscated)
1.7.0 IR gives c_0
1.7.21 IR gives c_0
1.7.21 LEGACY gives str (unobfuscated)
1.8.0 IR gives str (unobfuscated)Michael Friend
11/21/2022, 9:22 PMMichael Friend
11/21/2022, 9:25 PMc_0 obfuscated names you were seeing on 1.6.21 with the IR compiler.Michael Friend
11/21/2022, 9:28 PMstr_1 i.e. obfuscated but still human readable property name. And that is the one difference between what you had and the other project i posted. But in that project it was multimodule so that declaration was in a different file (root build.gradle)
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0")Michael Friend
11/21/2022, 9:34 PMMichael Friend
11/21/2022, 9:39 PMJohn Huang
11/21/2022, 11:15 PMJohn Huang
11/21/2022, 11:16 PMMichael Friend
11/21/2022, 11:21 PMJohn Huang
11/21/2022, 11:21 PMExecution failed for task ':kotlinStoreYarnLock'.
> yarn.lock was changed. Run the `kotlinUpgradeYarnLock` task to actualize yarn.lock fileMichael Friend
11/21/2022, 11:22 PMJohn Huang
11/21/2022, 11:24 PMJohn Huang
11/21/2022, 11:25 PMMichael Friend
11/21/2022, 11:25 PMJohn Huang
11/21/2022, 11:26 PMMichael Friend
11/21/2022, 11:30 PMJohn Huang
11/22/2022, 9:35 PM