Reputation: 61
I have a library in a jar that I would like to use in a Scala.js project. Is any jar usable as a dependency of a Scala.js project? Or should the jar have been compiled in a specific way?
Upvotes: 1
Views: 159
Reputation: 22085
The jar must have been compiled by the Scala.js compiler, so that it contains the .sjsir
files, necessary for compilation to JavaScript. If it was compiled by the regular Scala/JVM compiler, you will not be able to use it in a Scala.js project (unless it only contains macros).
See also How to add lib with jars to shared folder?
Upvotes: 1
Reputation: 2659
It depends on the library, and exactly how you're trying to use it -- there are some macro libraries that work, for example, and you can technically put anything in a jar -- but usually this doesn't make sense. Jars are usually composed mainly of JVM classes, which aren't compatible with Scala.js' JavaScript environment.
This is really the biggest practical difference between ScalaJVM and Scala.js -- while the language is identical, the libraries are entirely separate...
Upvotes: 1