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

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

我正在将 sbt-scalajs 版本从 0.6.x 升级到 1.0.0.

这是我的旧 plugins.sbt 配置

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

我的新plugins.sbt是

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

下面是我的老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)
 

我的新 build.sbt 除了 import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} 被注释之外是一样的。

当我 运行 sbt clean compile 我得到以下错误 -

/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"

这在 0.6.x sbt-scalajs 插件中工作正常。我不知道如何为 1.0.0 版本编写相同的内容

知道如何解决这个问题吗?

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