Ambiguous reference to a JS library: jquery.js

家住魔仙堡 提交于 2019-12-24 15:25:57

问题


ScalaJS

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.9")

with (after included jquery-ui dep):

libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.9.0",
jsDependencies += "org.webjars" % "jquery" % 2.2.3 / "jquery.js",
jsDependencies += "org.webjars.bower" % "jquery-ui" % "1.11.4" / "draggable.js"

error on compile with fastOptJS:

[error] - Ambiguous reference to a JS library: jquery.js
[error]   Possible paths found on the classpath:
[error]   - META-INF/resources/webjars/jquery/2.2.3/jquery.js
[error]   - META-INF/resources/webjars/jquery/3.0.0-beta1/src/jquery.js
[error]   - META-INF/resources/webjars/jquery/3.0.0-beta1/dist/jquery.js

I've tried with this thread: How to resolve "Ambiguous reference to a JS library"? and this How to troubleshoot JS dependencies between webjars and scala-js jars in an SBT project?

but that have not helped me (yet)

UPDATED: My Build Project with all deps defined

object BuildProject extends Build {

lazy val myPluginProject = Project(id = "my-site", base = file(".")).

settings(   

 version      := "0.1",
 scalaVersion := Versions.scala,

 ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },

 libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.9.0" exclude("org.webjars","jquery"),
 libraryDependencies += "com.lihaoyi" %%% "upickle" % Versions.upickle,

 libraryDependencies += "com.lihaoyi" %%% "scalatags" % Versions.scalaTags,

 // we will not use use DOM directly so commenting it
 libraryDependencies += "org.scala-js" %%% "scalajs-dom" % Versions.dom,


 jsDependencies += "org.webjars" % "jquery" % Versions.jquery / "jquery.js",

 jsDependencies += "org.webjars.bower" % "jquery-ui" % Versions.jqueryUI / "draggable.js",

  jsDependencies += "org.webjars.bower" % "webcomponents.js" % Versions.webcomponents / "webcomponents-lite.js",

 skip in packageJSDependencies := false,

 jsDependencies += RuntimeDOM,

 scalaJSUseRhino in Global := false ) .enablePlugins(ScalaJSPlugin)}

where

  val dom = "0.9.0"
  val upickle = "0.4.0"
  val jquery = "2.2.3"
  val jqueryUI = "1.11.4"
  val webcomponents = "0.7.21"

UPDATE 2 - "2.2.3/jquery.js" + dependsON

  jsDependencies += "org.webjars" % "jquery" % Versions.jquery / "2.2.3/jquery.js",

 jsDependencies += "org.webjars.bower" % "jquery-ui" % Versions.jqueryUI / "core.js" dependsOn "META-INF/resources/webjars/jquery/2.2.3/jquery.js",

Then:

[error]   Possible paths found on the classpath:
[error]   - META-INF/resources/webjars/jquery-ui/1.11.4/ui/core.js
[error]   - META-INF/resources/webjars/jquery/3.0.0-beta1/src/core.js

UPDATE 3 - "1.11.4/core.js" If:

   jsDependencies += "org.webjars.bower" % "jquery-ui" % Versions.jqueryUI / "1.11.4/core.js" dependsOn "META-INF/resources/webjars/jquery/2.2.3/jquery.js",

then:

[error] (compile:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries could not be resolved: [error] - Missing JS library:
1.11.4/core.js

UPDATE:

from the web-jar pom.xml,

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.11.1</version>
</dependency>
</dependencies>

I do not see that it would depend on jquery 2.2.3 ...

--

as a user, i guess will wait couple of years to make it mature.


回答1:


Your dependency

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

is ambiguous, because there are several files matching the suffix jquery.js on your classpath. You can use a longer suffix to disambiguate them, for example:

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

which will only match the path

META-INF/resources/webjars/jquery/2.2.3/jquery.js



回答2:


Just made use of another jquery-ui that has draggbale in it.

 jsDependencies += "org.webjars" % "jquery" % Versions.jquery / "jquery.js",
 jsDependencies += "org.webjars" % "jquery-ui" % "1.11.4" / "jquery-ui.js" dependsOn "jquery.js"

And the way I use:

val containerDyn  = jQuery("#launcher-main-container")
containerDyn.asInstanceOf[js.Dynamic].draggable()

And not sure why it pulled 3.0.0-beta1 dep



来源:https://stackoverflow.com/questions/37239261/ambiguous-reference-to-a-js-library-jquery-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!