scalajs-env-jsdom-nodejs run fails with UnsupportedInputException

332 views Asked by At

I'm trying to put together a very simple project. It compiles, but when I try to run it, it fails with:

[error] org.scalajs.jsenv.UnsupportedInputException: Unsupported input: List(CommonJSModule(/home/esgott/Repos/onlyco/target/scala-2.12/scalajs-bundler/main/onlyco-fastopt.js))
[error]         at org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv.$anonfun$validateInput$1(JSDOMNodeJSEnv.scala:59)
[error]         at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
[error]         at scala.collection.immutable.List.foreach(List.scala:392)
[error]         at scala.collection.TraversableLike.map(TraversableLike.scala:238)
[error]         at scala.collection.TraversableLike.map$(TraversableLike.scala:231)
[error]         at scala.collection.immutable.List.map(List.scala:298)
[error]         at org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv.validateInput(JSDOMNodeJSEnv.scala:54)
[error]         at org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv.start(JSDOMNodeJSEnv.scala:35)
[error]         at org.scalajs.sbtplugin.Run$.runInterruptible(Run.scala:44)
[error]         at org.scalajs.sbtplugin.ScalaJSPluginInternal$.$anonfun$scalaJSConfigSettings$49(ScalaJSPluginInternal.scala:438)
[error]         at org.scalajs.sbtplugin.ScalaJSPluginInternal$.$anonfun$scalaJSConfigSettings$49$adapted(ScalaJSPluginInternal.scala:422)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] stack trace is suppressed; run last Compile / run for the full output
[error] (Compile / run) org.scalajs.jsenv.UnsupportedInputException: Unsupported input: List(CommonJSModule(/home/esgott/Repos/onlyco/target/scala-2.12/scalajs-bundler/main/onlyco-fastopt.js))

The project code is at https://github.com/esgott/onlyco. I am stuck at debugging this issue, do you have a clue?

1

There are 1 answers

4
sjrd On

When using scalajs-bundler, as you seem to be doing, it is not enough to specify jsEnv to be a JSDOMNodeJSEnv. Instead, as the reference documentation says, you should use the following scalajs-bundler-specific setting:

requireJsDomEnv in Test := true