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

bugfix: Never set empty Scala JS version from sbt #2161

Merged
merged 1 commit into from
Sep 22, 2023
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
7 changes: 6 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ val integrations = file("integrations")
lazy val sbtBloop: Project = project
.enablePlugins(ScriptedPlugin)
.disablePlugins(ScalafixPlugin)
.enablePlugins(BuildInfoPlugin)
.in(integrations / "sbt-bloop")
.settings(
scriptedBufferLog := false,
Expand All @@ -347,7 +348,11 @@ lazy val sbtBloop: Project = project
sbtPlugin := true,
sbtVersion := SbtVersion,
target := (file("integrations") / "sbt-bloop" / "target" / SbtVersion).getAbsoluteFile,
libraryDependencies += Dependencies.bloopConfig
libraryDependencies += Dependencies.bloopConfig,
buildInfoPackage := "bloop.integrations.sbt",
buildInfoKeys := List[BuildInfoKey](
"latestScalaJsVersion" -> Dependencies.scalaJs1Version
)
)

lazy val buildpressConfig = (project in file("buildpress-config"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ object BloopDefaults {
private final val CompilerPluginConfig = "plugin->default(compile)"

/** Find native version. Copy pasted from Scala native. */
def findVersion(deps: Seq[ModuleID], org: String): Option[String] = {
def findNativePluginVersion(deps: Seq[ModuleID], org: String): Option[String] = {
def isPlugin(d: ModuleID, org: String) =
d.configurations.toList.contains(CompilerPluginConfig) && d.organization == org
deps.find(isPlugin(_, org)).map(_.revision)
Expand Down Expand Up @@ -762,7 +762,7 @@ object BloopDefaults {
val nativeLinkStubs = ScalaNativeKeys.nativeLinkStubs.?.value.getOrElse(emptyNative.linkStubs)
val nativeCompileOptions = ScalaNativeKeys.nativeCompileOptions.?.value.toList.flatten
val nativeLinkingOptions = ScalaNativeKeys.nativeLinkingOptions.?.value.toList.flatten
val nativeVersion = findVersion(libraryDeps, "org.scala-native").getOrElse(emptyNative.version)
val nativeVersion = findNativePluginVersion(libraryDeps, "org.scala-native").getOrElse(emptyNative.version)

val nativeMode = ScalaNativeKeys.nativeMode.?.value match {
case Some("debug") => Config.LinkerMode.Debug
Expand All @@ -777,25 +777,28 @@ object BloopDefaults {
}
} else if (pluginLabels.contains(ScalaJsPluginLabel)) {
Def.task {
val emptyScalaJs = Config.JsConfig.empty
val scalaJsVersion = findVersion(libraryDeps, "org.scala-js").getOrElse(emptyScalaJs.version)
val scalaJsVersion = libraryDeps
.find(module => module.organization == "org.scala-js" && module.name.startsWith("scalajs-library_"))
.map(_.revision)
.getOrElse(BuildInfo.latestScalaJsVersion)

val scalaJsStage = BloopKeys.bloopScalaJSStage.value match {
case Some(ScalaJsFastOpt) => Config.LinkerMode.Debug
case Some(ScalaJsFullOpt) => Config.LinkerMode.Release
case _ => emptyScalaJs.mode
case _ => Config.LinkerMode.Debug
}

val scalaJsModule = BloopKeys.bloopScalaJSModuleKind.value match {
case Some(NoJSModule) => Config.ModuleKindJS.NoModule
case Some(CommonJSModule) => Config.ModuleKindJS.CommonJSModule
case Some(ESModule) => Config.ModuleKindJS.ESModule
case _ => emptyScalaJs.kind
case _ => Config.ModuleKindJS.NoModule
}

val scalaJsEmitSourceMaps =
ScalaJsKeys.scalaJSEmitSourceMaps.?.value.getOrElse(emptyScalaJs.emitSourceMaps)
ScalaJsKeys.scalaJSEmitSourceMaps.?.value.getOrElse(false)
val jsdom = Some(false)
val jsConfig = Config.JsConfig(scalaJsVersion, scalaJsStage, scalaJsModule, scalaJsEmitSourceMaps, jsdom, None, None, emptyScalaJs.toolchain)
val jsConfig = Config.JsConfig(scalaJsVersion, scalaJsStage, scalaJsModule, scalaJsEmitSourceMaps, jsdom, None, None, Nil)
Config.Platform.Js(jsConfig, mainClass)
}
} else {
Expand Down
Loading