Skip to content

Commit

Permalink
Prepare the Scala.js integration for SIP-51 (#2988)
Browse files Browse the repository at this point in the history
When using Scala.js 1.15.0+ together with Scala 2, we now add an
explicit dependency to the `scalajs-scalalib` artifact. That artifact
comes with Scala.js 1.15.0+, and is double-versioned with the Scala
version and the Scala.js version.

As SIP-51 gets implemented and future versions of the Scala library may
break forward binary compatibility, the new `scalajs-scalalib` will be
able to bring in new APIs back to existing Scala.js versions.

This commit mimics the changes done to sbt-scalajs in
scala-js/scala-js#4913

Pull request: #2988
  • Loading branch information
sjrd committed Jan 23, 2024
1 parent 8b99dd0 commit 710ac88
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions scalajslib/src/mill/scalajslib/ScalaJSModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,25 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer =>

/** Adds the Scala.js Library as mandatory dependency. */
override def mandatoryIvyDeps = T {
super.mandatoryIvyDeps() ++ Seq(
ivy"org.scala-js::scalajs-library:${scalaJSVersion()}".withDottyCompat(scalaVersion())
)
val prev = super.mandatoryIvyDeps()
val scalaVer = scalaVersion()
val scalaJSVer = scalaJSVersion()

val scalaJSLibrary =
ivy"org.scala-js::scalajs-library:$scalaJSVer".withDottyCompat(scalaVer)

/* For Scala 2.x and Scala.js >= 1.15.0, explicitly add scalajs-scalalib,
* in order to support forward binary incompatible changesin the standard library.
*/
if (
scalaVer.startsWith("2.") && scalaJSVer.startsWith("1.")
&& scalaJSVer.drop(2).takeWhile(_.isDigit).toInt >= 15
) {
val scalaJSScalalib = ivy"org.scala-js::scalajs-scalalib:$scalaVer+$scalaJSVer"
prev ++ Seq(scalaJSLibrary, scalaJSScalalib)
} else {
prev ++ Seq(scalaJSLibrary)
}
}

// publish artifact with name "mill_sjs0.6.4_2.12" instead of "mill_sjs0.6_2.12"
Expand Down

0 comments on commit 710ac88

Please sign in to comment.