I'm new to Scala.js. I'd like to use the Argonaut json library.
https://github.com/argonaut-io/argonaut
Its only dependencies appear to be Monocle and Scalaz which both have versions compiled for Scala.js. I'd be happy to work on porting Argonaut to Scala.js, but don't have a firm idea on how to begin. Does anyone have any pointers?
Thanks.
The first thing to try is to convert the build so that the JVM projects become Scala.js projects. The basis for this is pretty easy:
In project/plugins.sbt
, add the dependency to the Scala.js sbt plugin:
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.2")
In build.sbt
or project/Build.scala
(or similar, depending on what the given project uses), turn projects into Scala.js projects by adding:
.enablePlugins(ScalaJSPlugin)
to their definitions. For their dependencies, replace %%
dependencies by %%%
dependencies to depend on the Scala.js artifacts.
At this point, the code can be compiled, and can probably be used to write examples or to directly in your application. Complex builds can require more work.
If everything works fine in your application, then you've made a successful proof-of-concept that this library can be ported to Scala.js.
OK, so now that you have a quick proof-of-concept that the library can compile and work on Scala.js, you'll want to make a proper cross-compiling build instead of the quick fork. Indeed, now the build does not produce JVM artifacts anymore.
For this, you will need to re-transform all projects that need to cross-compiled into crossProject
s. For this, I recommend the cross-building documentation page as a source for further documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With