Search code examples
scalasbtscala.jssbt-plugin

error: not found: value jsDependencies value / is not a member of sbt.librarymanagement.ModuleID


I'm upgrading sbt-scalajs version from 0.6.x to 1.0.0.

This is my old plugins.sbt config

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.33")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")

My new plugins.sbt is

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

Below is my old build.sbt


 import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
 
name := "sjs-test-error"

version := "0.1"

scalaVersion := "2.12.10"

val commonSettings = Seq(
  scalaVersion := "2.12.10",
  crossScalaVersions := Seq("2.12.10"),
  scalacOptions ++= Seq("-feature", "-deprecation", "-Xlint",  "-Ypartial-unification"),
  Compile / compile / scalacOptions  += "-Ywarn-unused-import",
  Compile / doc / scalacOptions += "-no-link-warnings"
)

val core = crossProject(JSPlatform, JVMPlatform)
  .in(file("core"))
  .settings(commonSettings)
  .settings(
    name := "sjs-test-error",
  )
  .jsSettings(
    libraryDependencies ++= Seq(
      "org.scala-js" %%% "scalajs-dom" % "0.9.1"
    ),
    jsDependencies ++= Seq(
      "org.webjars.npm" % "viz.js" % "1.7.0" / "1.7.0/viz.js"
    )
  )

lazy val coreJVM = core.jvm
lazy val coreJS = core.js

lazy val root = project.in(file("."))
  .aggregate(coreJVM, coreJS)
  .settings(commonSettings)
 

My new build.sbt is same except the import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} is commented.

When I run sbt clean compile I get below error -

/Users/rajkumar.natarajan/Documents/Coding/OS/reftree/build.sbt:28: error: not found: value jsDependencies

jsDependencies ++= Seq( ^

/Users/rajkumar.natarajan/Documents/Coding/OS/reftree/build.sbt:31: error: value / is not a member of sbt.librarymanagement.ModuleID

 "org.webjars.npm" % "viz.js" % "1.7.0" / "1.7.0/viz.js"

This is working fine in 0.6.x sbt-scalajs plugin. I don't know how to write the same for 1.0.0 version

Any idea how to fix this issue?


Solution

  • As mentioned in the release notes of Scala.js 1.0.0:

    If you use jsDependencies (or rely on the jsDependencies of your transitive dependencies):

    • Add addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.0") in project/plugins.sbt
    • Add .enablePlugins(JSDependenciesPlugin) to Scala.js projects
    • Add .jsConfigure(_.enablePlugins(JSDependenciesPlugin)) to crossProjects