davidB / scala-maven-plugin

The scala-maven-plugin (previously maven-scala-plugin) is used for compiling/testing/running/documenting scala code in maven.
https://davidb.github.io/scala-maven-plugin/
The Unlicense
562 stars 151 forks source link

Question: how to compile a Scala JS project #804

Open mcallisto opened 2 months ago

mcallisto commented 2 months ago

I understand from https://github.com/davidB/scala-maven-plugin/issues/604#issuecomment-2336750291 that it is possible to use the scala-maven-plugin to compile a project as Scala JS.

But I would need some help, from @jam01 or any other kind soul, in order to actually understand how.

I have a Scala3 project which is perfectly compiled on the JVM thanks to the plugin by using this POM.xml https://gist.github.com/mcallisto/29bfd600a13f885e904d83b7d9b37f64

On the other hand I tried to compile it as Scala JS by using (derived maybe incorrectly from https://github.com/jam01/json-schema/blob/0.1.0/js/pom.yaml) this modified POM.xml https://gist.github.com/mcallisto/1557877830225b06ebe9de0c80ae4ffc

But the compile phase fails with these errors:

[INFO] --- scala:4.9.1:compile (default) @ foo ---
[INFO] compiling 5 Scala sources to /.../foo/target/classes ...
[ERROR] /.../foo/Logic.scala:10:20: package scala.scalajs.js does not have a member method constructorOf
[ERROR] /.../foo/Logic.scala:12:15: package scala.scalajs.js.Dynamic does not have a member field or getter literal
[...many more of the same...]

Any hint?

mcallisto commented 2 months ago

I just want to add that my project (a library, with no main method) can be successfully compiled as Scala JS by sbt, so in my view the code itself is not causing the issue.

jam01 commented 2 months ago

Try removing the scala3-library_3 dep. You shouldn't need it.