dokka icon indicating copy to clipboard operation
dokka copied to clipboard

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

Open vmishenev opened this issue 1 year ago • 4 comments

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

vmishenev avatar Aug 19 '24 10:08 vmishenev

Action point:

  • mention in known issues for K2 opt-in release
  • decide afterwards on priority

whyoleg avatar Aug 23 '24 12:08 whyoleg

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 avatar Aug 30 '24 16:08 vmishenev

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

vmishenev avatar Sep 02 '24 16:09 vmishenev

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")

vmishenev avatar Sep 03 '24 10:09 vmishenev

<1.9.0 is quite old version so it is closed as obsolete

vmishenev avatar Aug 06 '25 12:08 vmishenev