Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Node.js 18 in CI, fix JSDOM detection #75

Merged
merged 3 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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