Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong library dependency configuration for Scala.js #391

Closed
adpi2 opened this issue Nov 12, 2020 · 0 comments · Fixed by #392
Closed

Wrong library dependency configuration for Scala.js #391

adpi2 opened this issue Nov 12, 2020 · 0 comments · Fixed by #392

Comments

@adpi2
Copy link
Contributor

adpi2 commented Nov 12, 2020

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant