Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.4k stars 402 forks source link

[K2] KMP: JS legacy-compiled libraries do not work for Kotlin <1.9.0 #3751

Open vmishenev opened 3 weeks ago

vmishenev commented 3 weeks ago

The JS integration test has unresolved types for Kotlin less 1.9.0. For Kotlin 1.9.0 and later, the test is passed.

Blocked by: https://youtrack.jetbrains.com/issue/KT-64159

whyoleg commented 3 weeks ago

Action point:

vmishenev commented 2 weeks ago

In our integration test:

HTMLAnchorElement is unresolved. It is from stdlib. However, other classes from the react library are resolved.

In Kotlin 1.9.20, KGP passes kotlin-stdlib-js-1.9.20.klib and kotlin-react-18.2.0-pre.490.klib In Kotlin 1.8.20, despite using js(IR), KGP passes kotlin-stdlib-js-1.8.20.jar, which is legacy-compiled(see the comment below) ,and kotlin-react-18.2.0-pre.490.klib.

The old compiler backend has been deprecated since Kotlin 1.8.0. Starting with Kotlin 1.9.0, using compiler types LEGACY or BOTH leads to an error.

The AA cannot read legacy-compiled JS libraries.

Note: KGP 1.9.0-1.9.10 passes kotlin-stdlib-js-1.9.0.jar/kotlin-stdlib-js-1.9.10.jar as well, but kotlin-dom-api-compat contains HTMLAnchorElement.

vmishenev commented 1 week ago

The kotlin-stdlib-js-*.jar has both the legacy and IR content, but AA filters out .jar here.

vmishenev commented 1 week ago

The possible workaround is to add new stlib/kotlin-dom-api-compat into Dokka's classpath.

   implementation("org.jetbrains.kotlin:kotlin-stdlib-js:2.0.0")
   implementation("org.jetbrains.kotlin:kotlin-dom-api-compat:2.0.0")