Skip to content

Commit 21e68af

Browse files
committed
Fix scala-js#3661: Load linker via reflection from main build
This will allow us to give resources to the linker that the build itself compiles first.
1 parent e02fe17 commit 21e68af

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

project/Build.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Keys._
1010
import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport._
1111
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
1212

13+
import java.net.URLClassLoader
1314
import java.util.Arrays
1415

1516
import scala.collection.mutable
@@ -104,6 +105,13 @@ object MyScalaJSPlugin extends AutoPlugin {
104105
jsEnv := new NodeJSEnv(
105106
NodeJSEnv.Config().withSourceMap(wantSourceMaps.value)),
106107

108+
scalaJSLinkerImpl := {
109+
val deps = (fullClasspath in (Build.linker, Runtime)).value
110+
val urls = Attributed.data(deps).map(_.toURI.toURL).toArray
111+
112+
LinkerImpl.default(new URLClassLoader(urls, getClass.getClassLoader))
113+
},
114+
107115
// Link source maps to GitHub sources
108116
addScalaJSCompilerOption(Def.setting {
109117
"mapSourceURI:" +

project/build.sbt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0")
66

77
addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.0")
88

9-
libraryDependencies += "com.google.javascript" % "closure-compiler" % "v20190513"
10-
119
libraryDependencies += "com.google.jimfs" % "jimfs" % "1.1"
1210

11+
// Bump guava for closure compiler used by linker.
12+
// Since it is loaded by reflection, the normal eviction doesn't work.
13+
// Expect that you need to update this if you update closure-compiler.
14+
libraryDependencies += "com.google.guava" % "guava-testlib" % "25.1-jre"
15+
1316
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit.pgm" % "3.2.0.201312181205-r"
1417

1518
unmanagedSourceDirectories in Compile ++= {
@@ -20,8 +23,6 @@ unmanagedSourceDirectories in Compile ++= {
2023
root / "logging/jvm/src/main/scala",
2124
root / "linker-interface/shared/src/main/scala",
2225
root / "linker-interface/jvm/src/main/scala",
23-
root / "linker/shared/src/main/scala",
24-
root / "linker/jvm/src/main/scala",
2526
root / "js-envs/src/main/scala",
2627
root / "nodejs-env/src/main/scala",
2728
root / "test-adapter/src/main/scala",

0 commit comments

Comments
 (0)