Skip to content

Commit

Permalink
Merge pull request #75 from armanbilge/topic/ci-node-js-18
Browse files Browse the repository at this point in the history
Use Node.js 18 in CI, fix JSDOM detection
  • Loading branch information
djspiewak authored Dec 29, 2022
2 parents 5d1e7c9 + 32bb479 commit 5b80ed1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Setup NodeJS v16 LTS
- name: Setup NodeJS v18 LTS
if: matrix.ci == 'ciNode' || matrix.ci == 'ciJSDOMNodeJS'
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: npm

- name: Install jsdom
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.16", "2.13.7", "3.1.3")
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v3"),
name = Some("Setup NodeJS v16 LTS"),
params = Map("node-version" -> "16", "cache" -> "npm"),
name = Some("Setup NodeJS v18 LTS"),
params = Map("node-version" -> "18", "cache" -> "npm"),
cond = Some("matrix.ci == 'ciNode' || matrix.ci == 'ciJSDOMNodeJS'"),
),
WorkflowStep.Run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,21 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
()
}

if (canUsePostMessage()) {
if (
js.typeOf(
js.Dynamic.global.navigator
) != Undefined && js.Dynamic.global.navigator.userAgent
.asInstanceOf[js.UndefOr[String]]
.exists(_.contains("jsdom"))
) {
val setImmediate =
js.Dynamic.global.Node.constructor("return setImmediate")()

{ k =>
setImmediate(k)
()
}
} else if (canUsePostMessage()) {
// postMessage is what we use for most modern browsers (when not in a webworker)

// generate a unique messagePrefix for everything we do
Expand Down Expand Up @@ -134,20 +148,6 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
channel.port2.postMessage(handle)
()
}
} else if (
js.typeOf(
js.Dynamic.global.navigator
) != Undefined && js.Dynamic.global.navigator.userAgent
.asInstanceOf[js.UndefOr[String]]
.exists(_.contains("jsdom"))
) {
val setImmediate =
js.Dynamic.global.Node.constructor("return setImmediate")()

{ k =>
setImmediate(k)
()
}
} else {
// we don't try to look for process.nextTick since scalajs doesn't support old node
// we're also not going to bother fast-pathing for IE6; just fall through
Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
libraryDependencies += "org.scala-js" %% "scalajs-env-nodejs" % "1.4.0"
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1"
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"

Expand Down

0 comments on commit 5b80ed1

Please sign in to comment.