Skip to content

Misdetection of common JS modules in the sbt build #715

Open
@tindzk

Description

@tindzk

While working on #634, I noticed that the sbt plug-in fails to detect CommonJS modules. I could trace it down to this function in SbtBloop.scala:

  lazy val findOutScalaJsModuleKind: Def.Initialize[Option[String]] = Def.settingDyn {
    try {
      val stageClass = Class.forName("core.tools.linker.backend.ModuleKind")
      val stageSetting = proxyForSetting("scalaJSModuleKind", stageClass)
      Def.setting {
        stageSetting.value.toString match {
          case "Some(NoModule)" => Some(NoJSModule)
          case "Some(CommonJSModule)" => Some(CommonJSModule)
          case _ => None
        }
      }
    } catch {
      case _: ClassNotFoundException => Def.setting(None)
    }
  }

A ClassNotFoundException gets triggered. When I changed stageClass to classOf[AnyRef], stageSetting.value would always be None.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions