Scala.js 缺少 JS 库/

Scala.js Missing JS library/

我想通过 jsDependencies 添加 jquery。

我试过了

libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.8.1"

jsDependencies += "org.webjars" % "jquery" % "2.1.4" / "2.1.4/jquery.js"

结果:

Missing JS library: 2.1.3/jquery.js

jsDependencies += "org.webjars" % "jquery" % "2.1.4" / "2.1.4/jquery.js"

结果:

  Possible paths found on the classpath:
  - scala/tools/nsc/doc/html/resource/lib/jquery.js
  - META-INF/resources/webjars/jquery/2.1.4/jquery.js

如何将 jquery 添加到我的依赖项中?

更新 1: 我创建了一个解决方法来删除 scala/tools js 库:

(scalaJSNativeLibraries in Compile) <<= (scalaJSNativeLibraries in Compile).map({ l =>
  println("scalaJSNativeLibraries: " + l.data.map(x => x.toURI).mkString("\n"))
  l.map(virtualFiles => virtualFiles.filter(vf => {
    val f=vf.toURI.toString
    val no = f.endsWith(".js") && f.contains("scala/tools")
    if(no){
      println(s"removing $f")
    }
    ! no
  }))
})

结果:

scalaJSNativeLibraries: virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/diagrams.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/index.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery-ui.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/modernizr.custom.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/raphael-min.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/scheduler.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/template.js
virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/tools.tooltip.js
virtualfile:/home/nyxos/.ivy2/cache/org.webjars/jquery/jars/jquery-2.1.3.jar:META-INF/resources/webjars/jquery/2.1.3/jquery.js
virtualfile:/home/nyxos/.ivy2/cache/org.webjars/jquery/jars/jquery-2.1.3.jar:META-INF/resources/webjars/jquery/2.1.3/jquery.min.js
virtualfile:/home/nyxos/.ivy2/cache/org.webjars/jquery/jars/jquery-2.1.3.jar:META-INF/resources/webjars/jquery/2.1.3/webjars-requirejs.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/diagrams.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/index.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery-ui.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/modernizr.custom.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/raphael-min.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/scheduler.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/template.js
removing virtualfile:/home/nyxos/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/tools.tooltip.js

更新 2

我认为问题是由 scala-lang 依赖项和 scala.js scalaJSNativeLibraries 包括所有 js 文件引起的。 Scala 编译器包含像 org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery.js.

这样的 js 文件
libraryDependencies += "org.scala-lang" % "scala-compiler" % sv 

**更新 3* 在 0.9.0 版本中有效:

libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.9.0"
jsDependencies += "org.webjars" % "jquery" % "2.1.4" / "2.1.4/jquery.js"

这是由于 "feature" 的 scalajs-jquery 0.8.x 弊大于利。

在scalajs-jquery 0.9.0.:

中修复
libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.9.0"
jsDependencies += "org.webjars" % "jquery" % "2.1.4" / "2.1.4/jquery.js"