add scala.js support - #33
Open
sief wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24. Scala.js support was dropped in 8771b8b when Scala 3 support was
added; this adds the
.jsPlatformrows back.Since the build already uses sbt-projectmatrix, this mirrors the existing
.jvmPlatformrows rather than restructuring into crossProject. Publishedartifacts go from 3 to 6 (Scala 3.3.8 / 2.13.18 / 2.12.21 × JVM / JS).
scala2Settings/scala3Settingssoboth platforms share them instead of duplicating across four rows
%%→%%%to resolve the_sjs1_artifactsjavax.annotation-apimoves to ajvmSettingsseq — it's a plain Javaartifact used only by
AnnotationTest%%%, note the Node requirement, and correct the installsnippet from 4.0.0 to 5.0.0
Toolchain bumps
The Scala.js artifacts require newer standard libraries than the pinned
compilers, so adding the JS rows would otherwise leave each row compiling
against a
scala-librarynewer than its own compiler — the direction SIP-51warns about:
scalajs-library_2.131.22.0scalajs-library_2.121.22.0scala3-library_33.3.5Scala moves to 3.3.8 / 2.13.18 / 2.12.21, staying on the 3.3.x LTS line.
sbt moves 1.9.9 → 1.13.0, which is what enforces SIP-51 — on 1.9.9 the
mismatch above compiles silently, so pinning 1.13.0 makes it a checked
invariant rather than a convention.
test,mdocandpublishLocalare allclean on 1.13.0, and
ci-releasebehaves identically to 1.9.9 withsbt-ci-release 1.9.2.
No main-source changes were needed
src/mainhas no platform directories, so the source compiled for JS isidentical to the JVM source.
AnnotationTestalready lives insrc/test/scalajvm, so projectmatrix excludes it from the JS rows.ConstantsTestreferences the Java classJavaConstants, but only insidenameOf(...), which the macro erases to a string literal — javac compiles itso the test typechecks, and no reference reaches the linker.
src/test/scalajs/ScalaJsTest.scalais new: it coversjs.*types and facademembers, and asserts the macros still produce compile-time constants via
@JSExportTopLevel, whose argument must be a literal string. That property isotherwise only tested by the JVM-only
AnnotationTest, so without it the JSrows would lose the guarantee entirely.
Verification
sbt test mdocpasses on all six rows:The JVM/JS delta is 2 on every version: JS lacks
AnnotationTest's 5 casesand gains
ScalaJsTest's 3.Separately, I published the artifacts locally and built a small consumer
project against them —
%%on the JVM and%%%on Scala.js, bothprovided,as the README instructs. All four combinations (JVM/JS × Scala 3.3.8/2.13.18)
resolve, link, and print the expected names, and the fully optimized JS output
contains the computed names as literals with no reference to the library.
Scala.js 1.22.0's linker is Java 8 bytecode, so CI stays on JDK 8.
Note: no 5.x release has JS artifacts yet, so the README's Scala.js line
deliberately doesn't pin a version — the first release cut after this merge
will be the first resolvable with
%%%.