Skip to content

JS IR compiler cannot find dependency #497

@Sarah-Gallitz

Description

@Sarah-Gallitz

I tried to add the kotlinx.html dependency for JS compilation. It seems to work ok with legacy compilation, but IR compilation is not resolving the import.

Steps:

  1. Add maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") at L62 build.gradle.kts
  2. Add kotlinJsDependency("org.jetbrains.kotlinx:kotlinx-html-js:0.7.5") at L89 build.gradle.kts
  3. This caused a duplicates error so I added duplicatesStrategy = DuplicatesStrategy.INCLUDE at L42 build.gradle.kts
  4. I then built with ./gradlew build -x test and ran with ./gradlew bootRun

Non IR curl works

curl --request POST \
  --url 'http://localhost:8080/api/compiler/translate?ir=false' \
  --header 'content-type: application/json' \
  --data '{
      "files": [
        {
          "name": "File.kt",
          "text": "import kotlinx.html.div\n\nfun main() {\n    println(\"test123\")\n }"
        }
      ]
}'

But the IR one doesn't

curl --request POST \
  --url 'http://localhost:8080/api/compiler/translate?ir=true' \
  --header 'content-type: application/json' \
  --data '{
      "files": [
        {
          "name": "File.kt",
          "text": "import kotlinx.html.div\n\nfun main() {\n    println(\"test123\")\n }"
        }
      ]
}'

The response was

{
  "jsCode": null,
  "exception": {
    "message": "UNRESOLVED_REFERENCE: Unresolved reference: html (1,16) in /File.kt",
    "fullName": "java.lang.IllegalStateException",
    "stackTrace": [
      {
        "className": "org.jetbrains.kotlin.diagnostics.DiagnosticSink$2",
        "methodName": "report",
        "fileName": "DiagnosticSink.java",
        "lineNumber": 46
      },
      {
        "className": "org.jetbrains.kotlin.resolve.AnalyzingUtils",
        "methodName": "throwExceptionOnErrors",
        "fileName": "AnalyzingUtils.kt",
        "lineNumber": 63
      },
      {
        "className": "org.jetbrains.kotlin.resolve.AnalyzingUtils",
        "methodName": "throwExceptionOnErrors",
        "fileName": "AnalyzingUtils.kt",
        "lineNumber": 58
      }
    ],
    "cause": null,
    "localizedMessage": null
  },
  "errors": {

  },
  "text": ""
}

I tried with both 1.7.0-RC2 and 1.6.21


I was also wondering is it possible to configure the JS compiler to bundle all necessary dependencies into the jsCode output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions