@@ -14,33 +14,23 @@ import bloop.config.Config.ModuleKindJS
14
14
import bloop .data .Project
15
15
import bloop .logging .DebugFilter
16
16
import bloop .logging .{Logger => BloopLogger }
17
- import bloop .scalajs .jsenv .JsDomNodeJsEnv
18
- import bloop .scalajs .jsenv .NodeJSConfig
19
- import bloop .scalajs .jsenv .NodeJSEnv
20
17
21
18
import org .scalajs .jsenv .Input
19
+ import org .scalajs .jsenv .jsdomnodejs .JSDOMNodeJSEnv
20
+ import org .scalajs .jsenv .nodejs .NodeJSEnv
22
21
import org .scalajs .linker .PathIRContainer
22
+ import org .scalajs .linker .PathOutputDirectory
23
23
import org .scalajs .linker .PathOutputFile
24
24
import org .scalajs .linker .StandardImpl
25
25
import org .scalajs .linker .interface .{ModuleKind => ScalaJSModuleKind , _ }
26
26
import org .scalajs .logging .Level
27
27
import org .scalajs .logging .{Logger => JsLogger }
28
28
import org .scalajs .testing .adapter .TestAdapter
29
29
import org .scalajs .testing .adapter .TestAdapterInitializer
30
+ import java .nio .file .Files
30
31
31
32
/**
32
33
* Defines operations provided by the Scala.JS 1.x toolchain.
33
- *
34
- * The 1.x js bridge needs to inline the implementation of `NodeJSEnv`,
35
- * `JSDOMNodeJSEnv` and `ComRunner` because there is a bug in the latest
36
- * Scala.js release that does not run `close` on the underlying process,
37
- * skipping the destruction of the process running Scala.js tests. Aside
38
- * from leaking, this is fatal in Windows because the underlying process
39
- * is alive and keeps open references to the output JS file.
40
- *
41
- * We can remove all of the js environments and runners as soon as this
42
- * issue is fixed upstream. Note that our 0.6.x version handles cancellation
43
- * correctly.
44
34
*/
45
35
object JsBridge {
46
36
private class Logger (logger : BloopLogger )(implicit filter : DebugFilter ) extends JsLogger {
@@ -94,13 +84,13 @@ object JsBridge {
94
84
classpath : Array [Path ],
95
85
runMain : java.lang.Boolean ,
96
86
mainClass : Option [String ],
97
- target : Path ,
87
+ targetDirectory : Path ,
98
88
logger : BloopLogger ,
99
89
executionContext : ExecutionContext
100
90
): Unit = {
101
91
implicit val ec = executionContext
102
92
implicit val logFilter : DebugFilter = DebugFilter .Link
103
- val linker = ScalaJSLinker .reuseOrCreate(config, target )
93
+ val linker = ScalaJSLinker .reuseOrCreate(config, targetDirectory )
104
94
105
95
val cache = StandardImpl .irFileCache().newCache
106
96
val irContainersPairs = PathIRContainer .fromClasspath(classpath)
@@ -126,11 +116,14 @@ object JsBridge {
126
116
}
127
117
}
128
118
129
- val output = LinkerOutput (PathOutputFile (target))
130
-
131
119
val resultFuture = for {
132
120
libraryIRs <- libraryIrsFuture
133
- _ <- linker.link(libraryIRs, moduleInitializers, output, new Logger (logger))
121
+ _ <- linker.link(
122
+ libraryIRs,
123
+ moduleInitializers,
124
+ PathOutputDirectory (targetDirectory),
125
+ new Logger (logger)
126
+ )
134
127
} yield ()
135
128
136
129
Await .result(resultFuture, Duration .Inf )
@@ -151,11 +144,12 @@ object JsBridge {
151
144
if (nodeModules.toFile().exists()) {
152
145
logger.debug(" Node.js module path: " + nodeModules.toString())
153
146
val fullEnv = Map (" NODE_PATH" -> nodeModules.toString()) ++ env
154
- val config =
155
- NodeJSConfig ().withExecutable(nodePath).withCwd(Some (baseDirectory)).withEnv(fullEnv)
156
147
val nodeEnv =
157
- if (! jsConfig.jsdom.contains(true )) new NodeJSEnv (logger, config)
158
- else new JsDomNodeJsEnv (logger, config)
148
+ if (! jsConfig.jsdom.contains(true ))
149
+ new NodeJSEnv (
150
+ NodeJSEnv .Config ().withExecutable(nodePath).withEnv(fullEnv)
151
+ )
152
+ else new JSDOMNodeJSEnv (JSDOMNodeJSEnv .Config ().withExecutable(nodePath).withEnv(fullEnv))
159
153
160
154
// The order of the scripts mandates the load order in the JavaScript runtime
161
155
val input = jsConfig.kind match {
0 commit comments