Problem
The library dependencies of the fetchJS project are JVM artifacts:
> fetchJS / dependencyTree
[info] com.47deg:fetch_sjs1_2.13:1.3.1+44-b82a1d66+20201112-1442-SNAPSHOT [S]
[info] +-org.scala-js:scalajs-library_2.13:1.3.0 [S]
[info] +-org.typelevel:cats-effect_2.13:2.2.0 [S]
[info] +-org.typelevel:cats-core_2.13:2.2.0 [S]
[info] +-org.typelevel:cats-kernel_2.13:2.2.0 [S]
As we can see the cats-effect_2.13 is a JVM artifact and not a Scala.js artifact.
It should be cats-effect_sjs1_2.13 instead.
The fetchJS project can be compiled but it cannot be linked:
- the
fetchJS / test are not executed
- no Scala.js
main class using fetch can be executed
For instance, fetchJS / test does not run any test:
> fetchJS / test
[info] fetchJS / test completed
Or if I create a Scala.js project depending on fetch, it cannot be linked:
// project/plugin.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")
// build.sbt
lazy val demo = project.in(file("."))
.settings(
scalaVersion := "2.13.3",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-effect" % "2.2.0",
"com.47deg" %%% "fetch" % "1.3.0"
),
scalaJSUseMainModuleInitializer := true
)
.enablePlugins(ScalaJSPlugin)
// src/main/scala/Main.scala
import fetch._
import scala.concurrent._
import scala.concurrent.duration._
import cats._
import cats.effect._
object Main extends App {
val executionContext: ExecutionContext = ExecutionContext.Implicits.global
implicit val timer: Timer[IO] = IO.timer(executionContext)
implicit val cs: ContextShift[IO] = IO.contextShift(executionContext)
def fetch[F[_]: ConcurrentEffect]: Fetch[F, Int] =
Fetch.pure[F, Int](42)
Await.result(Fetch.run[IO](fetch).map(println).unsafeToFuture(), Duration.Inf)
}
> > demo / run
[info] Fast optimizing /home/piquerez/47degrees/fetch-demo/target/scala-2.13/demo-fastopt
[error] Referring to non-existent class java.util.concurrent.locks.AbstractQueuedSynchronizer
...
Expectation
All library dependencies of the fetchJS project should be Scala.js dependencies:
> fetchJS / dependencyTree
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] com.47deg:fetch_sjs1_2.13:1.3.1+44-b82a1d66+20201112-1453-SNAPSHOT [S]
[info] +-org.scala-js:scalajs-library_2.13:1.3.0 [S]
[info] +-org.typelevel:cats-effect_sjs1_2.13:2.2.0 [S]
[info] +-org.scala-js:scalajs-library_2.13:1.1.1 (evicted by: 1.3.0)
[info] +-org.scala-js:scalajs-library_2.13:1.3.0 [S]
[info] +-org.typelevel:cats-core_sjs1_2.13:2.2.0 [S]
[info] +-org.scala-js:scalajs-library_2.13:1.1.1 (evicted by: 1.3.0)
[info] +-org.scala-js:scalajs-library_2.13:1.3.0 [S]
[info] +-org.typelevel:cats-kernel_sjs1_2.13:2.2.0 [S]
[info] +-org.scala-js:scalajs-library_2.13:1.1.1 (evicted by: 1.3.0)
[info] +-org.scala-js:scalajs-library_2.13:1.3.0 [S]
Problem
The library dependencies of the
fetchJSproject are JVM artifacts:As we can see the
cats-effect_2.13is a JVM artifact and not a Scala.js artifact.It should be
cats-effect_sjs1_2.13instead.The
fetchJSproject can be compiled but it cannot be linked:fetchJS / testare not executedmainclass using fetch can be executedFor instance,
fetchJS / testdoes not run any test:Or if I create a Scala.js project depending on fetch, it cannot be linked:
Expectation
All library dependencies of the
fetchJSproject should be Scala.js dependencies: