-
Notifications
You must be signed in to change notification settings - Fork 81
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
Scala 3 JS modifier #504
Changes from 4 commits
9592734
513d5bb
8b4cc26
b647cb3
7073651
9093b1b
25fe55c
af00c2a
aa068bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,12 +275,11 @@ val jsdocs = project | |
.settings( | ||
sharedSettings, | ||
publish / skip := true, | ||
crossScalaVersions --= scala3, | ||
scalaJSLinkerConfig ~= { | ||
_.withModuleKind(ModuleKind.CommonJSModule) | ||
}, | ||
libraryDependencies ++= List( | ||
"org.scala-js" %%% "scalajs-dom" % scalajsDom | ||
"org.scala-js" %%% "scalajs-dom" % scalajsDom cross CrossVersion.for3Use2_13 | ||
), | ||
scalaJSUseMainModuleInitializer := true, | ||
Compile / npmDependencies ++= List( | ||
|
@@ -342,7 +341,6 @@ lazy val unitJS = project | |
.settings( | ||
sharedSettings, | ||
publish / skip := true, | ||
crossScalaVersions --= scala3, | ||
Compile / unmanagedSourceDirectories ++= multiScalaDirectories("tests/unit-js").value, | ||
libraryDependencies ++= List( | ||
"org.scalameta" %% "munit" % V.munit % Test | ||
|
@@ -400,7 +398,6 @@ lazy val js = project | |
.in(file("mdoc-js")) | ||
.settings( | ||
sharedSettings, | ||
crossScalaVersions --= scala3, | ||
moduleName := "mdoc-js", | ||
Compile / unmanagedSourceDirectories ++= multiScalaDirectories("js").value, | ||
libraryDependencies ++= crossSetting( | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
) | ||
) | ||
) | ||
.dependsOn(mdoc) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package mdoc.modifiers | ||
|
||
import scala.reflect.io.VirtualDirectory | ||
import mdoc.internal.markdown.MarkdownCompiler | ||
import scala.meta.inputs.Input | ||
import mdoc.Reporter | ||
import mdoc.internal.pos.TokenEditDistance | ||
import mdoc.internal.markdown.FileImport | ||
|
||
private[modifiers] object CompilerCompat { | ||
def abstractFile(tg: String) = new VirtualDirectory(tg, None) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package mdoc.modifiers | ||
|
||
import dotty.tools.io.{AbstractFile, VirtualDirectory} | ||
|
||
import mdoc.internal.markdown.MarkdownCompiler | ||
import scala.meta.inputs.Input | ||
import mdoc.Reporter | ||
import mdoc.internal.pos.TokenEditDistance | ||
import mdoc.internal.markdown.FileImport | ||
|
||
private[modifiers] object CompilerCompat { | ||
def abstractFile(tg: String) = new VirtualDirectory(tg, None) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,15 @@ class JsSuite extends BaseMarkdownSuite { | |
| required: Int | ||
|val x: Int = "" | ||
| ^^ | ||
""".stripMargin | ||
""".stripMargin, | ||
compat = Map( | ||
"3.0" -> | ||
""" | ||
|error: error.md:3:14 | ||
|Found: ("" : String) | ||
|Required: Int | ||
""".stripMargin | ||
) | ||
) | ||
|
||
check( | ||
|
@@ -93,7 +101,21 @@ class JsSuite extends BaseMarkdownSuite { | |
| required: String | ||
|val y: String = 42 | ||
| ^^ | ||
""".stripMargin | ||
""".stripMargin, | ||
compat = Map( | ||
"3.0" -> | ||
""" | ||
|error: edit.md:3:14: | ||
|Found: ("" : String) | ||
|Required: Int | ||
| val x: Int = "" | ||
| ^^ | ||
|error: edit.md:7:17: | ||
|Found: (42 : Int) | ||
|Required: String | ||
| val y: String = 42 | ||
""".stripMargin | ||
) | ||
) | ||
|
||
checkError( | ||
|
@@ -110,7 +132,14 @@ class JsSuite extends BaseMarkdownSuite { | |
"""|error: isolated.md:7:9: not found: value x | ||
|println(x) | ||
| ^ | ||
""".stripMargin | ||
""".stripMargin, | ||
compat = Map( | ||
"3.0" -> | ||
""" | ||
|error: isolated.md:7:9 | ||
|Not found: x | ||
""".stripMargin | ||
) | ||
) | ||
|
||
checkCompiles( | ||
|
@@ -171,7 +200,15 @@ class JsSuite extends BaseMarkdownSuite { | |
| required: String | ||
|val x: String = 42 | ||
| ^^ | ||
""".stripMargin | ||
""".stripMargin, | ||
compat = Map( | ||
"3.0" -> | ||
""" | ||
|-error: compile-only-error.md:3:17: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. This is not right. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :-/ |
||
|Found: (42 : Int) | ||
|Required: String | ||
""".stripMargin | ||
) | ||
) | ||
|
||
// It's easy to mess up stripMargin multiline strings when generating code with strings. | ||
|
@@ -247,7 +284,15 @@ class JsSuite extends BaseMarkdownSuite { | |
baseSettings.copy( | ||
site = baseSettings.site.updated("js-classpath", Classpath(noScalajsDom).syntax) | ||
) | ||
} | ||
}, | ||
compat = Map( | ||
"3.0" -> | ||
""" | ||
|error: | ||
|no-dom.md:3 (mdoc generated code) | ||
| value scalajs is not a member of org | ||
""".stripMargin | ||
) | ||
) | ||
|
||
checkError( | ||
|
There was a problem hiding this comment.
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.