diff --git a/build.sc b/build.sc index ff0c4e423ea..e8ae5dad964 100644 --- a/build.sc +++ b/build.sc @@ -97,6 +97,7 @@ object Deps { object Scalajs_1 { val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0" + val scalajsEnvExoegoJsdomNodejs = ivy"net.exoego::scalajs-env-jsdom-nodejs:2.1.0" val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.4.0" val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0" val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:1.11.0" @@ -672,6 +673,7 @@ object scalajslib extends MillModule { | val javaxServlet = "org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016" | val scalajsEnvNodejs = "${formatDep(Deps.Scalajs_1.scalajsEnvNodejs)}" | val scalajsEnvJsdomNodejs = "${formatDep(Deps.Scalajs_1.scalajsEnvJsdomNodejs)}" + | val scalajsEnvExoegoJsdomNodejs = "${formatDep(Deps.Scalajs_1.scalajsEnvExoegoJsdomNodejs)}" | val scalajsEnvPhantomJs = "${formatDep(Deps.Scalajs_1.scalajsEnvPhantomjs)}" | } |} @@ -701,6 +703,7 @@ object scalajslib extends MillModule { Deps.Scalajs_1.scalajsSbtTestAdapter, Deps.Scalajs_1.scalajsEnvNodejs, Deps.Scalajs_1.scalajsEnvJsdomNodejs, + Deps.Scalajs_1.scalajsEnvExoegoJsdomNodejs, Deps.Scalajs_1.scalajsEnvPhantomjs ) } diff --git a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala index 6b2bc01daab..1d6b763b4dd 100644 --- a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala +++ b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala @@ -5,7 +5,7 @@ import ch.epfl.scala.bsp4j.{BuildTargetDataKind, ScalaBuildTarget, ScalaPlatform import mill.api.{Loose, PathRef, Result, internal} import mill.scalalib.api.ZincWorkerUtil import mill.scalalib.Lib.resolveDependencies -import mill.scalalib.{DepSyntax, Lib, TestModule} +import mill.scalalib.{Dep, DepSyntax, Lib, TestModule} import mill.testrunner.TestRunner import mill.define.{Command, Target, Task} import mill.scalajslib.{ScalaJSWorker => DeprecatedScalaJSWorker} @@ -50,6 +50,21 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => ) } + def scalaJSJsEnvIvyDeps: Target[Agg[Dep]] = T { + val dep = jsEnvConfig() match { + case _: JsEnvConfig.NodeJs => + ivy"${ScalaJSBuildInfo.Deps.scalajsEnvNodejs}" + case _: JsEnvConfig.JsDom => + ivy"${ScalaJSBuildInfo.Deps.scalajsEnvJsdomNodejs}" + case _: JsEnvConfig.ExoegoJsDomNodeJs => + ivy"${ScalaJSBuildInfo.Deps.scalajsEnvExoegoJsdomNodejs}" + case _: JsEnvConfig.Phantom => + ivy"${ScalaJSBuildInfo.Deps.scalajsEnvPhantomJs}" + } + + Agg(dep) + } + def scalaJSLinkerClasspath: T[Loose.Agg[PathRef]] = T { val commonDeps = Seq( ivy"org.scala-js::scalajs-sbt-test-adapter:${scalaJSVersion()}" @@ -62,11 +77,8 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => ) case "1" => Seq( - ivy"org.scala-js::scalajs-linker:${scalaJSVersion()}", - ivy"${ScalaJSBuildInfo.Deps.scalajsEnvNodejs}", - ivy"${ScalaJSBuildInfo.Deps.scalajsEnvJsdomNodejs}", - ivy"${ScalaJSBuildInfo.Deps.scalajsEnvPhantomJs}" - ) + ivy"org.scala-js::scalajs-linker:${scalaJSVersion()}" + ) ++ scalaJSJsEnvIvyDeps() } // we need to use the scala-library of the currently running mill resolveDependencies( diff --git a/scalajslib/src/mill/scalajslib/api/ScalaJSApi.scala b/scalajslib/src/mill/scalajslib/api/ScalaJSApi.scala index e6c75248f69..41463bc7831 100644 --- a/scalajslib/src/mill/scalajslib/api/ScalaJSApi.scala +++ b/scalajslib/src/mill/scalajslib/api/ScalaJSApi.scala @@ -83,6 +83,7 @@ sealed trait JsEnvConfig object JsEnvConfig { implicit def rwNodeJs: RW[NodeJs] = macroRW implicit def rwJsDom: RW[JsDom] = macroRW + implicit def rwExoegoJsDomNodeJs: RW[ExoegoJsDomNodeJs] = macroRW implicit def rwPhantom: RW[Phantom] = macroRW implicit def rw: RW[JsEnvConfig] = macroRW @@ -99,6 +100,12 @@ object JsEnvConfig { env: Map[String, String] = Map.empty ) extends JsEnvConfig + final case class ExoegoJsDomNodeJs( + executable: String = "node", + args: List[String] = Nil, + env: Map[String, String] = Map.empty + ) extends JsEnvConfig + final case class Phantom( executable: String, args: List[String], diff --git a/scalajslib/src/mill/scalajslib/worker/ScalaJSWorker.scala b/scalajslib/src/mill/scalajslib/worker/ScalaJSWorker.scala index 358547a51bc..689d50a79bb 100644 --- a/scalajslib/src/mill/scalajslib/worker/ScalaJSWorker.scala +++ b/scalajslib/src/mill/scalajslib/worker/ScalaJSWorker.scala @@ -77,6 +77,12 @@ private[scalajslib] class ScalaJSWorker extends AutoCloseable { args = config.args, env = config.env ) + case config: api.JsEnvConfig.ExoegoJsDomNodeJs => + workerApi.JsEnvConfig.ExoegoJsDomNodeJs( + executable = config.executable, + args = config.args, + env = config.env + ) case config: api.JsEnvConfig.Phantom => workerApi.JsEnvConfig.Phantom( executable = config.executable, diff --git a/scalajslib/worker-api/src/ScalaJSWorkerApi.scala b/scalajslib/worker-api/src/ScalaJSWorkerApi.scala index 79316a0d883..475fcde7dbd 100644 --- a/scalajslib/worker-api/src/ScalaJSWorkerApi.scala +++ b/scalajslib/worker-api/src/ScalaJSWorkerApi.scala @@ -68,6 +68,12 @@ private[scalajslib] object JsEnvConfig { env: Map[String, String] ) extends JsEnvConfig + final case class ExoegoJsDomNodeJs( + executable: String, + args: List[String], + env: Map[String, String] + ) extends JsEnvConfig + final case class Phantom( executable: String, args: List[String], diff --git a/scalajslib/worker/0.6/src/ScalaJSWorkerImpl.scala b/scalajslib/worker/0.6/src/ScalaJSWorkerImpl.scala index 3007bff8633..e90247a61ff 100644 --- a/scalajslib/worker/0.6/src/ScalaJSWorkerImpl.scala +++ b/scalajslib/worker/0.6/src/ScalaJSWorkerImpl.scala @@ -197,5 +197,8 @@ class ScalaJSWorkerImpl extends ScalaJSWorkerApi { .withEnv(config.env) .withAutoExit(config.autoExit) ) + case _: JsEnvConfig.ExoegoJsDomNodeJs => throw new Exception( + "Not supported on Scala.js 0.6" + ) } } diff --git a/scalajslib/worker/1/src/ScalaJSWorkerImpl.scala b/scalajslib/worker/1/src/ScalaJSWorkerImpl.scala index a635b2544ae..5c42310bf56 100644 --- a/scalajslib/worker/1/src/ScalaJSWorkerImpl.scala +++ b/scalajslib/worker/1/src/ScalaJSWorkerImpl.scala @@ -301,6 +301,13 @@ class ScalaJSWorkerImpl extends ScalaJSWorkerApi { .withArgs(config.args) .withEnv(config.env) ) + case config: JsEnvConfig.ExoegoJsDomNodeJs => + new net.exoego.jsenv.jsdomnodejs.JSDOMNodeJSEnv( + net.exoego.jsenv.jsdomnodejs.JSDOMNodeJSEnv.Config() + .withExecutable(config.executable) + .withArgs(config.args) + .withEnv(config.env) + ) case config: JsEnvConfig.Phantom => new org.scalajs.jsenv.phantomjs.PhantomJSEnv( org.scalajs.jsenv.phantomjs.PhantomJSEnv.Config()