{"id":443,"date":"2021-09-09T18:00:52","date_gmt":"2021-09-09T22:00:52","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=443"},"modified":"2021-09-09T18:01:06","modified_gmt":"2021-09-09T22:01:06","slug":"scala-js-referring-to-non-existent-class","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2021\/09\/09\/scala-js-referring-to-non-existent-class\/","title":{"rendered":"Scala.js &#8211; Referring to non-existent class"},"content":{"rendered":"<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nReferring to non-existent class MyClass$\n  called from JSClass$.jsMethod()void\n  called from JSClass$.$js$exported$meth$jsMethod()java.lang.Object\n  exported to JavaScript with @JSExport\ninvolving instantiated classes:\n  JSClass$\n    exported to JavaScript with @JSExport\nCannot access module for non-module MyClass$\n  called from JSClass$.jsMethod()void\n  called from JSClass$.$js$exported$meth$jsMethod()java.lang.Object\n  exported to JavaScript with @JSExport\ninvolving instantiated classes:\n  JSClass$\n    exported to JavaScript with @JSExport\n<\/pre><\/div>\n\n\n<p>Related issue: <a href=\"https:\/\/github.com\/scala-js\/scala-js\/issues\/629\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/scala-js\/scala-js\/issues\/629<\/a> <\/p>\n\n\n\n<p>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:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: scala; title: ; notranslate\" title=\"\">\nobject MyObject extends ScalaModule with ScalaJSModule with ScalafmtModule {\n  \/\/ ...\n}\n\n\/\/ Instead of\n\nobject MyObject extends ScalaModule with ScalafmtModule {\n  \/\/ ...\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>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:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[900],"tags":[941,701,926,940,901,939],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/443"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=443"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/443\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}