Hello! I'm using Kotlin 1.3.70. When I compile kot...
# compiler
p
Hello! I'm using Kotlin 1.3.70. When I compile kotlin-js with
Copy code
-Xir-produce-js
I got a lot of compilation error from jsTest that it can't find symbols that located in jsMain. Without setting this flag all compiles well. Please advise me how can i compile my Kotlin code to js using IR? P.S. it is the same for browser{} and nodejs{}
s
Hello! You should use
-Xir-produce-klib
in your main module. Note that JS IR in 1.3.* is in pre-alpha state and these compiler flags are temporary. 1.4.0 Gradle plugin will have proper support for JS IR.
p
Hello, @Svyatoslav Kuzmich [JB], thanks for your answer! But as i test this flag is not supported in 1.3.70: w: Flag is not supported by this version of the compiler: -Xir-produce-klib. What version of Kotlin compiler should I use for it?
s
@PHondogo Sorry, it is
-*Xir*-*produce*-*klib*-*dir*
p
Thank you very much for your quick reply, @Svyatoslav Kuzmich [JB] . When I use suggested flag I've got another error: e: java.lang.IllegalStateException: No module deserializer found for <kotlin> is a module[ModuleDescriptorImpl@1e9ce2dc]. May be you can advice some solution? Thanks in advance!
s
Looks like it fails to find recent standard library. Do you have a dependency on stdlib-js? Like
Copy code
dependencies {
    implementation(kotlin("stdlib-js"))
 }
p
Yes.
Copy code
val jsMain by getting {
                        dependencies {
                            implementation(kotlin("stdlib-js"))
                                                    }
                    }

                    val jsTest by getting {
                        dependencies {
                            implementation(kotlin("test-js"))
                        }
                    }
Hello, @Svyatoslav Kuzmich [JB]! Thank you for your replies. Now I'm much closer to make JS unit tests work in my project. May be you can advise me one more time? When I build my project I've got this: Error: Couldn't find package "source-map-support@0.5.16" required by "test-project@0.0.1-SNAPSHOT" on the "npm" registry. Do you have any suggestions how to make it fixed? Thanks in advance!
s
@PHondogo Sorry for late reply. Its hard to tell. Could it be that you have a private NPM repo with a missing package? Or some network issue on your or NPM side? Otherwise NPM should be able to download the package from https://www.npmjs.com/package/source-map-support
p
@Svyatoslav Kuzmich [JB] You right! It was firewall issue. Thank you very much for your help!!!