Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS IR compiler cannot find dependency #497

Open
Sarah-Gallitz opened this issue Jun 9, 2022 · 1 comment
Open

JS IR compiler cannot find dependency #497

Sarah-Gallitz opened this issue Jun 9, 2022 · 1 comment

Comments

@Sarah-Gallitz
Copy link

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?

@AlexanderPrendota
Copy link
Collaborator

cc @ilgonmic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants