2

I want to add jquery by jsDependencies.

I tried

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

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

resulted in:

Missing JS library: 2.1.3/jquery.js

and

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

resulted in:

  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

How can I add jquery to my dependencies?

UPDATE 1: I created a workaround to remove scala/tools js libraries:

(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
  }))
})

Result:

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

Update 2

I think the problem is caused by the scala-lang dependency and scala.js scalaJSNativeLibraries including all js files. Scala-compiler contains the js files like org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:scala/tools/nsc/doc/html/resource/lib/jquery.js.

libraryDependencies += "org.scala-lang" % "scala-compiler" % sv 

**update 3* In the 0.9.0 version it works:

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

1 Answer 1

1

This is due to a "feature" of scalajs-jquery 0.8.x that has caused more harm than good.

It is fixed in 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"
Sign up to request clarification or add additional context in comments.

4 Comments

That does not fix the problem.
It worked perfectly well for me here: github.com/scala-js/scalajs-tutorial/commit/… :-s
did you try with libraryDependencies += "org.scala-lang" % "scala-compiler" % sv ?
Yes, it works just as fine. Are you sure you have written "2.1.4/jquery.js" after the /? If you just say "jquery.js" you will have issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.