Compdigitec Labs

« | Home

Scala.js – Referring to non-existent class

By admin | September 9, 2021

Referring to non-existent class MyClass$
  called from JSClass$.jsMethod()void
  called from JSClass$.$js$exported$meth$jsMethod()java.lang.Object
  exported to JavaScript with @JSExport
involving instantiated classes:
  JSClass$
    exported to JavaScript with @JSExport
Cannot access module for non-module MyClass$
  called from JSClass$.jsMethod()void
  called from JSClass$.$js$exported$meth$jsMethod()java.lang.Object
  exported to JavaScript with @JSExport
involving instantiated classes:
  JSClass$
    exported to JavaScript with @JSExport

Related issue: https://github.com/scala-js/scala-js/issues/629

If the issue is coming from a shared module being used in both a Scala.js and JVM setting, the issue may be that the shared module is not being compiled for Scala.js. We can fix that as follows by compiling it for both. Mill example below:

object MyObject extends ScalaModule with ScalaJSModule with ScalafmtModule {
  // ...
}

// Instead of

object MyObject extends ScalaModule with ScalafmtModule {
  // ...
}

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Code | No Comments »

Comments