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

Minor changes for Scala.js 1.0 compatibility #3246

Merged
merged 2 commits into from
Jan 18, 2020
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ lazy val commonJsSettings = Seq(
parallelExecution := false,
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
// batch mode decreases the amount of memory needed to compile Scala.js code
scalaJSOptimizerOptions := scalaJSOptimizerOptions.value.withBatchMode(isTravisBuild.value),
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withBatchMode(isTravisBuild.value),
// currently sbt-doctest doesn't work in JS builds
// https://github.com/tkawachi/sbt-doctest/issues/52
doctestGenTests := Seq.empty
Expand Down
24 changes: 15 additions & 9 deletions js/src/test/scala/cats/tests/FutureTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@ import cats.js.instances.Await
import cats.js.instances.future.futureComonad
import cats.tests.{CatsSuite, ListWrapper}

import scala.concurrent.Future
import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.concurrent.duration._

import org.scalacheck.{Arbitrary, Cogen}
import org.scalacheck.Arbitrary.arbitrary
import cats.laws.discipline.arbitrary._

// https://issues.scala-lang.org/browse/SI-7934
@deprecated("", "")
class DeprecatedForwarder {
implicit def runNow = scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow
}
object DeprecatedForwarder extends DeprecatedForwarder
import DeprecatedForwarder.runNow

class FutureTests extends CatsSuite {
// Replaces Scala.js's `JSExecutionContext.runNow`, which is removed in 1.0.
// TODO: We shouldn't do this! See: https://github.com/scala-js/scala-js/issues/2102
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth creating and linking to a github issue about fixing this item

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #3247

implicit private object RunNowExecutionContext extends ExecutionContextExecutor {
def execute(runnable: Runnable): Unit =
try {
runnable.run()
} catch {
case t: Throwable => reportFailure(t)
}

def reportFailure(t: Throwable): Unit =
t.printStackTrace()
}

val timeout = 3.seconds

def futureEither[A](f: Future[A]): Future[Either[Throwable, A]] =
Expand Down
5 changes: 4 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.31")

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")
addSbtPlugin("com.github.gseitz" %% "sbt-release" % "1.0.12")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
Expand All @@ -10,7 +13,7 @@ addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.0.2")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.31")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")

Expand Down
12 changes: 12 additions & 0 deletions scripts/scala.js-1.0-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# For temporary use while cross-publishing for Scala.js 0.6 and 1.0.

SCALAJS_VERSION=1.0.0-RC2 sbt +kernelJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +kernelLawsJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +coreJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +lawsJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +freeJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +testkitJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +alleycatsCoreJS/publishSigned
SCALAJS_VERSION=1.0.0-RC2 sbt +alleycatsLawsJS/publishSigned