scala.js: IDEA does not find individual JS and JVM implementations of an object, sbt compile / sbt test works fine

I have a crossProject which has JVM, JS and shared sources. Now, in jvm and js directories, I have individual implementations of an object, let's call it "somepackage.SomeObject" for now.

When I now reference this object somewhere in the "shared" source tree, IDEA highlights it as an error (i.e., makes it red) and complains it cannot find the object. However, "Build / Rebuild project" works, and "sbt compile" too.

Is this bug or some misconfiguration of my project structure?


I investigated some more, and found out that when putting the individual implementations in a separate crossProject and adding it as a dependency via dependsOn, they are referenced correctly and found by IDEA. So for now, as a workaround, I do the following:

  • create a crossProject which only contains the specific implementations of the functionality which has to be implemented differently for JVM and JS. I name this like "myproject_platform"
  • create a crossProject like "myProject" which "dependsOn(myProject_platform)" and put the tests and everything which uses the platform-specific implementations there.

For googling posterity ... this appears to still be an issue as of April 2022, and it has a YouTrack:


Please sign in to leave a comment.