1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package cbt
import java.io.File
case class ScalaJsLib(
scalaJsVersion: String, scalaVersion: String, cbtLastModified: Long, mavenCache: File
)(implicit logger: Logger, transientCache: java.util.Map[AnyRef,AnyRef], classLoaderCache: ClassLoaderCache){
sealed trait ScalaJsOutputMode {
def option: String
def fileSuffix: String
}
case object FastOptJS extends ScalaJsOutputMode{
override val option = "--fastOpt"
override val fileSuffix = "fastopt"
}
case object FullOptJS extends ScalaJsOutputMode{
override val option = "--fullOpt"
override val fileSuffix = "fullopt"
}
val lib = new Lib(logger)
def dep(artifactId: String) = MavenResolver( cbtLastModified, mavenCache, mavenCentral ).bindOne(
MavenDependency("org.scala-js", artifactId, scalaJsVersion)
)
def link(
outputPath: File,
scalaJsOptions: Seq[String], entriesToLink: Seq[File]
) = {
val scalaJsCliDep = dep( "scalajs-cli_"++lib.libMajorVersion(scalaVersion) )
outputPath.getParentFile.mkdirs
lib.runMain(
"org.scalajs.cli.Scalajsld",
Seq(
"--sourceMap",
"--stdlib", s"${scalaJsLibraryDependency.jar.getAbsolutePath}",
"--output", outputPath.string
) ++ scalaJsOptions ++ entriesToLink.map(_.getAbsolutePath),
scalaJsCliDep.classLoader
)
}
val scalaJsLibraryDependency = dep( "scalajs-library_"++lib.libMajorVersion(scalaVersion) )
// Has to be full Scala version because the compiler is incompatible between versions
val scalaJsCompilerDependency = dep( "scalajs-compiler_"++scalaVersion )
val scalacOptions = Seq(
"-Xplugin:" ++ scalaJsCompilerDependency.jar.string,
"-Xplugin-require:scalajs"
)
}
|