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

Scala 3 JS modifier #504

Merged
merged 9 commits into from
May 17, 2021
Merged

Scala 3 JS modifier #504

merged 9 commits into from
May 17, 2021

Conversation

keynmol
Copy link
Collaborator

@keynmol keynmol commented May 15, 2021

Closes #500

Enable JS modifier for Scala 3

What helps here is that mdoc SBT plugin already collects all of the info that ScalaJS needs - Scala.js' own SBT plugin configures the scalacOptions and libraryDependencies depending on Scala version: #504

Which means that it's mostly a game of jenga to arrange the types + fixing a bug in compileSources to reset the context correctly.

Fix compat messages in tests

  1. in checkError we were applying compat to both the obtained errors and expectations - which means with overrides those were always passing.
  2. I've removed the usages of strings for scala versions, to give a little more correctness.

scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.CommonJSModule)
},
libraryDependencies ++= List(
"org.scala-js" %%% "scalajs-dom" % scalajsDom
"org.scala-js" %%% "scalajs-dom" % scalajsDom cross CrossVersion.for3Use2_13
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DOM library won't be published for Scala 3.

@@ -409,7 +406,9 @@ lazy val js = project
"org.scala-js" % "scalajs-compiler" % scalajs cross CrossVersion.full,
"org.scala-js" %% "scalajs-linker" % scalajs
),
if3 = List()
if3 = List(
"org.scala-js" %% "scalajs-linker" % scalajs cross CrossVersion.for3Use2_13
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After we obtain sjsir files, it doesn't matter which linker we use.

@keynmol keynmol marked this pull request as ready for review May 15, 2021 13:02
@keynmol keynmol changed the title WIP: Scala 3 JS modifier Scala 3 JS modifier May 15, 2021
compat = Map(
"3.0" ->
"""
|-error: compile-only-error.md:3:17:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm. This is not right.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right. Seems like it's because the scala binary version has changed for 3.0.0 stable - so our tests aren't actually verifying Scala 3 assertions :-/

assertNoDiff(
Compat(obtainedErrors, compat, postProcessObtained),
Compat(obtainedErrors, Map.empty, postProcessObtained),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I looked at this and couldn't quite understand - my thinking is that we don't want to apply compat layers to obtained output, otherwise it resolves to the expectation itself and the test trivially passes (which was the reason that before some of the tests for errors were not doing anything)

@keynmol keynmol requested review from olafurpg and tgodzik May 15, 2021 15:49
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Looks amazing! I asked two smaller questions, but this is nothing blocking.

@tgodzik tgodzik merged commit 15513ae into main May 17, 2021
@tgodzik tgodzik deleted the scala3-js-modifier branch May 17, 2021 14:58
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.

Scala 3 support for JS modifier
2 participants