Skip to content

Commit 5b80ed1

Browse files
authored
Merge pull request #75 from armanbilge/topic/ci-node-js-18
Use Node.js 18 in CI, fix JSDOM detection
2 parents 5d1e7c9 + 32bb479 commit 5b80ed1

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ jobs:
6666
~/Library/Caches/Coursier/v1
6767
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
6868

69-
- name: Setup NodeJS v16 LTS
69+
- name: Setup NodeJS v18 LTS
7070
if: matrix.ci == 'ciNode' || matrix.ci == 'ciJSDOMNodeJS'
7171
uses: actions/setup-node@v3
7272
with:
73-
node-version: 16
73+
node-version: 18
7474
cache: npm
7575

7676
- name: Install jsdom

build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.16", "2.13.7", "3.1.3")
4747
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
4848
WorkflowStep.Use(
4949
UseRef.Public("actions", "setup-node", "v3"),
50-
name = Some("Setup NodeJS v16 LTS"),
51-
params = Map("node-version" -> "16", "cache" -> "npm"),
50+
name = Some("Setup NodeJS v18 LTS"),
51+
params = Map("node-version" -> "18", "cache" -> "npm"),
5252
cond = Some("matrix.ci == 'ciNode' || matrix.ci == 'ciJSDOMNodeJS'"),
5353
),
5454
WorkflowStep.Run(

core/src/main/scala/org/scalajs/macrotaskexecutor/MacrotaskExecutor.scala

+15-15
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,21 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
8484
()
8585
}
8686

87-
if (canUsePostMessage()) {
87+
if (
88+
js.typeOf(
89+
js.Dynamic.global.navigator
90+
) != Undefined && js.Dynamic.global.navigator.userAgent
91+
.asInstanceOf[js.UndefOr[String]]
92+
.exists(_.contains("jsdom"))
93+
) {
94+
val setImmediate =
95+
js.Dynamic.global.Node.constructor("return setImmediate")()
96+
97+
{ k =>
98+
setImmediate(k)
99+
()
100+
}
101+
} else if (canUsePostMessage()) {
88102
// postMessage is what we use for most modern browsers (when not in a webworker)
89103

90104
// generate a unique messagePrefix for everything we do
@@ -134,20 +148,6 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
134148
channel.port2.postMessage(handle)
135149
()
136150
}
137-
} else if (
138-
js.typeOf(
139-
js.Dynamic.global.navigator
140-
) != Undefined && js.Dynamic.global.navigator.userAgent
141-
.asInstanceOf[js.UndefOr[String]]
142-
.exists(_.contains("jsdom"))
143-
) {
144-
val setImmediate =
145-
js.Dynamic.global.Node.constructor("return setImmediate")()
146-
147-
{ k =>
148-
setImmediate(k)
149-
()
150-
}
151151
} else {
152152
// we don't try to look for process.nextTick since scalajs doesn't support old node
153153
// we're also not going to bother fast-pathing for IE6; just fall through

project/plugins.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
libraryDependencies += "org.scala-js" %% "scalajs-env-nodejs" % "1.4.0"
12
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1"
23
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"
34

0 commit comments

Comments
 (0)