Scala.js缺少JS库/

时间:2016-02-12 23:44:27

标签: scala sbt scala.js

我想通过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"

1 个答案:

答案 0 :(得分:1)

这是由于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"