Closed Komdosh closed 5 months ago
Hi~ Based on your description, I created a project that I used to try to reproduce it, but unfortunately I don't seem to be reproducing it successfully. Here's its configuration:
plugins {
kotlin("multiplatform") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
id("love.forte.plugin.suspend-transform") version "0.9.0"
}
group = "plugin.demo"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
kotlin {
jvm {}
js {
browser { testTask { useMocha { this.timeout = "5s" } } }
}
sourceSets.commonMain.dependencies {
implementation("io.ktor:ktor-client-core:2.3.12")
}
}
suspendTransform {
useJsDefault()
}
This is the structure of the project:
The AuthClient
in the commonMain:
class AuthClient(private val client: HttpClient) {
@JsPromise
suspend fun config(): AuthConfig {
return client.get("/config").body()
}
}
class AuthConfig
fun main() {
println(AuthClient(HttpClient()))
}
I executed compileKotlinJs
and got a successful result and got the compiled content in build/classes/js/main/default/linkdata/root_package/0_.knm
as follows:
public fun main(): kotlin.Unit { /* compiled code */ }
public final class AuthClient public constructor(client: io.ktor.client.HttpClient) {
private final val client: io.ktor.client.HttpClient /* compiled code */
@love.forte.plugin.suspendtrans.annotation.JsPromise public final suspend fun config(): AuthConfig { /* compiled code */ }
@love.forte.plugin.suspendtrans.annotation.Api4Js public final fun configAsync(): kotlin.js.Promise<out AuthConfig> { /* compiled code */ }
}
public final class AuthConfig public constructor() {
}
🤔This seems like everything is in order, additional information about this project:
However, NoClassDefFoundError
exceptions are usually caused by a Kotlin version mismatch. If you want to use the 0.9.0
version, Kotlin should be 2.0.0
, so maybe that's a reason?
Oh, I forgot that i've changed the kotlin version to 2.0.20-Beta1. With 2.0.0
it works properly, thank you.
Hello! Thank you for your library, it looks very helpful!
I have a problem with setup.
I have a multiplatform project (JVM + JS (Not wasm)). Kotlin version is 2.0.0. Am I missing something?
I'm trying to compile :common:api:compileKotlinJs, but I'm getting an error:
There is also a gradle hint for configuration: