scala-js/scala-js-dom

libraryDependencies addition in Usage documentation doesn't work for me

Closed this issue · 6 comments

Hi, the Usage section of the docs says:

Add the following to your sbt build definition:

libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.0"

But for me, SBT can't resolve the dependency unless I instead use:

libraryDependencies +="org.scala-js" %%% "scalajs-dom_sjs0.6" % "0.9.1"

I'm fairly new to Scala and SBT, so maybe this isn't a bug, but is instead something I'm doing wrong.

sjrd commented

You are most likely putting this dependency in a JVM project. scalajs-dom is a Scala.js library, so it can only be used in a Scala.js project (one with enablePlugins(ScalaJSPlugin)).

Okay, thanks for that. You might want to add a note to that effect in the docs, so newbies like me don't get confused.

evbo commented

Just want to add that unless it's really hard to do, it would be nice to be able to add scala-js-dom to jvm projects.

Example use-case: I want to extract scala-js business logic (math, various UI logic) into a completely JVM only project that is easily unit tested, but part of my logic needs to be unit tested with some javascript context, such as org.scalajs.dom.ext.Extensions.KeyCode.

If only I could load bits and pieces of the dom I need for unit testing, it makes for lightening fast automated tests that can execute fully in IntelliJ without transcompiling!

sjrd commented

You would have to define a separate project that mimics the source API of scalajs-dom for the parts you want, but implemented in a JVM way.

This is totally out of scope for this project, but you could do it yourself in a separate project.

evbo commented

thanks for confirming. ScalaJS is an incredible project, even if unit testing takes a bit extra effort!

I think this issue can be closed, since it is usage question and answered.