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

Fix #1103: Scala 3 support for Scala.js #1187

Merged
merged 1 commit into from
Mar 1, 2021
Merged

Fix #1103: Scala 3 support for Scala.js #1187

merged 1 commit into from
Mar 1, 2021

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Feb 28, 2021

No description provided.

@lolgab lolgab marked this pull request as ready for review February 28, 2021 17:02
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. But I don't understand one detail, see below.

@@ -107,7 +107,7 @@ object Lib{
else if (mill.scalalib.api.Util.isScala3(scalaVersion))
Agg(
// note that dotty-library has a binary version suffix, hence the :: is necessary here
ivy"$scalaOrganization::scala3-library:$scalaVersion".forceVersion()
ivy"$scalaOrganization::scala3-library::$scalaVersion".forceVersion()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why's that change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want it to be scala3-library_sjs1_3.0.0-RC1 on Scala.js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was obvious. Sorry for the poor question. I was wondering, why that works at all, as this method is also used outside of a Scala.js context. I would expect it to fail when compiling a simple scala project. Also this should affect Scala Native modules. My initial though was, that a Scala.js specific runtime/ compiler classpath should be applied to the ScalaJsModule, not the ScalaModule. You see me confused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platformSuffix works on any platform. It works correctly on ScalaModule because platformSuffix = "".
The main difference between Scala 2 and Scala 3 on Scala JS is that the Scala.js backend is not implemented as a compiler plugin but inside the Scala 3 compiler. So if Scala 2 removes the scala-library and replaces it with its scalajs-library (as you can see there is no super.scalacPluginIvyDeps() ++ in the Scala2 part of scalacPluginIvyDeps, which means that we don't want the scala-library from Scala but we'll use the Scala.js one instead), the Scala 3 compiler emits different scala3-library artifacts for every backend.
Regarding Scala Native, I expect that when it will be supported, its support will be done in a similar fashion as the Scala.js one, so there will be a scala3-library_native0.x_3... artifact that the ScalaNativeModule will automatically use.
I apologise in advance with the Scala.js team if I said something not completely precise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for that explanation. And sorry for not knowing that specific part of the Mill API better. The platform suffix handling still feels a bit odd, but that is another discussion. PR looks good to me!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to be sorry of! Thank you for the review and the merge 🙏😃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I wasn't that wrong with my suspicion. This assumes we only build with plain Scala Module or one of the built-in platform versions ScalaJSModule or ScalaNativeModule. But the platform concept is more general and if one module sets it to be unequal ""`, this implementation will fail. Instead, we should revert that specific line and implement it more specifically in the both modules that need it.

E.g. imagine, someone tries to build a Mill plugin with Scala 3 (which is currently not supported), the you would run into the following issue:

object millroot extends MillBuildRootModule {
  override def scalaVersion = "3.3.0"
  // ..
}
>> mill --meta-level 1 ivyDepsTree
[build.sc] [30/52] resolvedIvyDeps | Downloading [2/2] artifacts (~0/0 bytes)
1 targets failed
resolvedIvyDeps
Resolution failed for 1 modules:
--------------------------------------------
  org.scala-lang:scala3-library_mill0.11_3:3.3.0
	not found: /Users/me/ivy2/local/org.scala-lang/scala3-library_mill0.11_3/3.3.0/ivys/ivy.xml
	not found: https://repo1.maven.org/maven2/org/scala-lang/scala3-library_mill0.11_3/3.3.0/scala3-library_mill0.11_3-3.3.0.pom

Example adapted from https://matrix.to/#/!zXvttAKLPnvdnmiYsY:matrix.am/$FU_LdtZ6RFNOtmpbIlCGGzlkzWAV0NPUaF2BE7F2sqI?via=matrix.am&via=gitter.im&via=matrix.org

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened PR #2739

@lolgab lolgab requested a review from lefou March 1, 2021 07:38
@lefou lefou merged commit abb7ddc into master Mar 1, 2021
@lefou lefou added this to the after 0.9.5 milestone Mar 1, 2021
@lefou
Copy link
Member

lefou commented Mar 1, 2021

Thank you!

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 this pull request may close these issues.

2 participants