Over the past two days, I have hacked up together this sbt plugin:
As the readme explains in detail, this sbt plugin, named sbt-dynscalajs (for dynamic Scala.js), allows to dynamically switch the target of projects in a build from JVM to JS, and also allows to switch between versions of Scala, based on the value of a setting. In a nutshell, all projects are JVM by default. And with a simple
set dynScalaJSVersion := Some("1.0.0-M1")
(which is basically the same difficulty, if not verbosity, as
++2.12.3), they are magically turned into Scala.js projects, using Scala.js 1.0.0-M1.
test, and all those good things are available as in normal Scala.js project. Other Scala.js versions that are supported are 0.6.19, as well as 0.6.20 but without
test support at the moment.
This plugin effectively makes it as easy as
++2.12.3 to switch between targets and between versions of Scala.js. However, it has caveats (see readme). It should for example definitely not be used by developers who are doing Scala.js-specific things. It is only intended for library maintainers who don’t want to deal with Scala.js, yet support it nevertheless.
Also, it obviously does not support Scala Native. So don’t use this if you also want to support Scala Native.
Make sure to read the readme, especially about the expectations you should (and should not) have about this plugin and its maintenance.
Also, I suggest you actually read the source code if you want to invest in the discussion on this thread, as it will provide you with a relative clear picture of the challenges