@@ -1451,7 +1451,7 @@ object Build {
1451
1451
lazy val `scala3-bootstrapped-new` = project
1452
1452
.aggregate(`scala3-interfaces`, `scala3-library-bootstrapped-new` , `scala-library-bootstrapped`,
1453
1453
`tasty-core-bootstrapped-new`, `scala3-compiler-bootstrapped-new`, `scala3-sbt-bridge-bootstrapped`,
1454
- `scala3-staging-new`, `scala3-tasty-inspector-new`)
1454
+ `scala3-staging-new`, `scala3-tasty-inspector-new`, `scala-library-sjs` )
1455
1455
.settings(
1456
1456
name := " scala3-bootstrapped" ,
1457
1457
moduleName := " scala3-bootstrapped" ,
@@ -1833,6 +1833,94 @@ object Build {
1833
1833
target := target.value / " scala3-library-bootstrapped" ,
1834
1834
)
1835
1835
1836
+ /* Configuration of the org.scala-js:scalajs-scalalib_2.13:*.**.**-bootstrapped project */
1837
+ lazy val `scala-library-sjs` = project.in(file(" library-js" ))
1838
+ // We add a dependency to the JVM library to have the classfile available
1839
+ // (as they are not part of this artifact)
1840
+ .dependsOn(`scala3-library-bootstrapped-new`)
1841
+ .settings(
1842
+ name := " scala-library-sjs" ,
1843
+ organization := " org.scala-js" ,
1844
+ // This is very tricky here since this is a Scala 3 project, but to be able to smoothly
1845
+ // migrate the ecosystem, we need to be able to evict the Scala 2 library from the classpath.
1846
+ // The problem is that the Scala 2 library for Scala.js has a _2.13 in the module's name, so we need
1847
+ // to release Scala 3 for Scala.js with the same _2.13 instead of the _3.
1848
+ // Yes, I know, this is weird and feels wrong.
1849
+ moduleName := " scalajs-scalalib_2.13" ,
1850
+ version := dottyVersion,
1851
+ versionScheme := Some (" semver-spec" ),
1852
+ crossPaths := false ,
1853
+ // sbt defaults to scala 2.12.x and metals will report issues as it doesn't consider the project a scala 3 project
1854
+ // (not the actual version we use to compile the project)
1855
+ scalaVersion := referenceVersion,
1856
+ // Add the source directories for the stdlib (non-boostrapped)
1857
+ Compile / unmanagedSourceDirectories := Seq (baseDirectory.value / " src" ),
1858
+ Compile / unmanagedSourceDirectories ++=
1859
+ (`scala-library-bootstrapped` / Compile / unmanagedSourceDirectories).value,
1860
+ // NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1861
+ Compile / scalacOptions := Seq (" -deprecation" , " -feature" , " -unchecked" , " -encoding" , " UTF8" , " -language:implicitConversions" , " -nowarn" ),
1862
+ Compile / scalacOptions += " -Yno-stdlib-patches" ,
1863
+ Compile / scalacOptions += " -scalajs" ,
1864
+ // Packaging configuration of the stdlib
1865
+ Compile / packageBin / publishArtifact := true ,
1866
+ Compile / packageDoc / publishArtifact := false ,
1867
+ Compile / packageSrc / publishArtifact := true ,
1868
+ // Only publish compilation artifacts, no test artifacts
1869
+ Test / publishArtifact := false ,
1870
+ // Do not allow to publish this project for now
1871
+ publish / skip := false ,
1872
+ // Take into account the source files from the `library` folder
1873
+ // but give the priority to the files in `library-js` that override files in `library`
1874
+ Compile / sources := {
1875
+ val files = (Compile / sources).value
1876
+ val overwrittenSources =
1877
+ (files ++ Seq (
1878
+ baseDirectory.value / " src" / " scala" / " runtime" / " BoxesRunTime.java" ,
1879
+ baseDirectory.value / " src" / " scala" / " math" / " ScalaNumber.java" ,
1880
+ ))
1881
+ .flatMap(_.relativeTo(baseDirectory.value / " src" )).toSet
1882
+
1883
+ files.filterNot(file =>
1884
+ file.relativeTo((`scala-library-bootstrapped` / baseDirectory).value / " src" )
1885
+ .exists(overwrittenSources.contains))
1886
+
1887
+ },
1888
+ libraryDependencies += (" org.scala-js" %% " scalajs-library" % scalaJSVersion).cross(CrossVersion .for3Use2_13),
1889
+ libraryDependencies += (" org.scala-js" % " scalajs-javalib" % scalaJSVersion),
1890
+ // Project specific target folder. sbt doesn't like having two projects using the same target folder
1891
+ target := target.value / " scala-library" ,
1892
+ // we need to have the `scala-library` artifact in the classpath for `ScalaLibraryPlugin` to work
1893
+ // this was the only way to not get the artifact evicted by sbt. Even a custom configuration didn't work
1894
+ // NOTE: true is the default value, just making things clearer here
1895
+ managedScalaInstance := true ,
1896
+ // Configure the nonbootstrapped compiler
1897
+ scalaInstance := {
1898
+ val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1899
+
1900
+ // IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1901
+ // just directories containing classfiles because sbt maintains a cache of
1902
+ // compiler instances. This cache is invalidated based on timestamps
1903
+ // however this is only implemented on jars, directories are never
1904
+ // invalidated.
1905
+ val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
1906
+ val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
1907
+ val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1908
+ val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
1909
+
1910
+ Defaults .makeScalaInstance(
1911
+ dottyNonBootstrappedVersion,
1912
+ libraryJars = Array (scalaLibrary),
1913
+ allCompilerJars = Seq (tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
1914
+ allDocJars = Seq .empty,
1915
+ state.value,
1916
+ scalaInstanceTopLoader.value
1917
+ )
1918
+ },
1919
+ scalaCompilerBridgeBinaryJar := {
1920
+ Some ((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
1921
+ },
1922
+ )
1923
+
1836
1924
// ==============================================================================================
1837
1925
// ===================================== TASTY CORE LIBRARY =====================================
1838
1926
// ==============================================================================================
0 commit comments