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

Support Scala 3 on ScalaJSModule #1103

Closed
lolgab opened this issue Jan 11, 2021 · 4 comments
Closed

Support Scala 3 on ScalaJSModule #1103

lolgab opened this issue Jan 11, 2021 · 4 comments
Milestone

Comments

@lolgab
Copy link
Member

lolgab commented Jan 11, 2021

Currently ScalaJSModule doesn't support Scala 3.

The support should be something along the lines of what is done in the Scala.js sbt plugin

@lefou
Copy link
Member

lefou commented Jan 12, 2021

FYI, technically, the only thing we need to do is to adapt the Scala libraries. See this Gitter thread from Sept. 2020: https://gitter.im/lihaoyi/mill?at=5f52a9d759ac794e02ea6b82

I'm quoting the ad-hoc solution:

override def mapDependencies = T.task{ d: coursier.Dependency =>
  d match {
    case d if d.module.name.value == "scalajs-library_0.27" =>
      d.withModule(d.module.withName(coursier.core.ModuleName("scalajs-library_2.13")))
    case d if d.module.name.value == "scalajs-compiler_0.27.0-RC1" =>
      d.withModule(d.module.withName(coursier.core.ModuleName("scalajs-compiler_2.13.3")))
    case x => x
  }
}

@megri
Copy link
Contributor

megri commented Feb 25, 2021

Artifacts on the 3.0.0-x branch requires slightly different intervention, as the scalajs compiler is builtin and enabled by a compiler flag. I had some success with this setup but I'm not sure if it's a 100 % correct:

trait Scala3JSModule extends ScalaJSModule {
  override def scalacPluginIvyDeps = T { Seq() }

  def scalacOptions = Seq("-scalajs")

  override def scalaLibraryIvyDeps = T {
    Agg(
      ivy"org.scala-lang:scala3-library_sjs1_${scalaVersion()}:${scalaVersion()}",
      ivy"org.scala-js:scalajs-test-bridge_2.13:${scalaJSVersion()}"
    )
  }
}

object myJSModule extends Scala3JSModule {
  //
}

lolgab added a commit that referenced this issue Feb 28, 2021
lolgab added a commit that referenced this issue Feb 28, 2021
lolgab added a commit that referenced this issue Feb 28, 2021
@lefou lefou closed this as completed in abb7ddc Mar 1, 2021
@lefou lefou added this to the after 0.9.5 milestone Mar 2, 2021
@bbarker
Copy link
Contributor

bbarker commented Apr 17, 2021

Artifacts on the 3.0.0-x branch requires slightly different intervention, as the scalajs compiler is builtin and enabled by a compiler flag. I had some success with this setup but I'm not sure if it's a 100 % correct:

trait Scala3JSModule extends ScalaJSModule {
  override def scalacPluginIvyDeps = T { Seq() }

  def scalacOptions = Seq("-scalajs")

  override def scalaLibraryIvyDeps = T {
    Agg(
      ivy"org.scala-lang:scala3-library_sjs1_${scalaVersion()}:${scalaVersion()}",
      ivy"org.scala-js:scalajs-test-bridge_2.13:${scalaJSVersion()}"
    )
  }
}

object myJSModule extends Scala3JSModule {
  //
}

I saw that Scala 3 + Scala.js is supported in mill 0.9.6 - is this still the best way to go about it in 0.9.6?

@lolgab
Copy link
Member Author

lolgab commented Apr 17, 2021

@bbarker No, you just need a normal Scala.js module and set the Scala version to 3.0.0-RC2. It should work just fine.

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

No branches or pull requests

4 participants