Felix Dietze
Felix Dietze

Reputation: 690

How do I cross-compile a sbt top-level project with Scalajs 0.6 and 1.0.0?

I want to cross-compile a ScalaJS facade. This facade is a top-level sbt project. But when I compile, I get the following error for ScalaJS 1.0.0-M8:

Option not understood: sjsDefinedByDefault

Here is a minimal reproduction (https://github.com/fdietze/scala-js-d3v4/tree/sjsDefinedByDefault):

build.sbt:

name := "scala-js-d3v4"
version := "master-SNAPSHOT"
scalaVersion := "2.12.8"

enablePlugins(ScalaJSPlugin)
scalacOptions += "-P:scalajs:sjsDefinedByDefault"

plugins.sbt:

val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.28")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

Building with 0.6.28 works, while 1.0.0-M8 fails with:

Option not understood: sjsDefinedByDefault

Travis build: https://travis-ci.org/fdietze/scala-js-d3v4/builds/560544812

Must scalajs-projects be subprojects to apply the option as a scalajs setting only? Why does it work with 0.6.28 then?

For reference: https://www.reddit.com/r/scala/comments/786gco/error_bad_option_pscalajssjsdefinedbydefault/

Upvotes: 0

Views: 324

Answers (1)

sjrd
sjrd

Reputation: 22085

As explained at the end of the release notes of Scala.js 1.0.0-M8, you need to use the following setting:

scalacOptions ++= {
  if (scalaJSVersion.startsWith("0.6.")) Seq("-P:scalajs:sjsDefinedByDefault")
  else Nil
}

Upvotes: 1

Related Questions