1

ScalaJS

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

与(包括 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"

使用 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

我试过这个线程: 如何解决“对 JS 库的模糊引用”?以及如何解决 SBT 项目中 webjars 和 scala-js jars 之间的 JS 依赖关系?

但这并没有帮助我(还)

更新:我的构建项目定义了所有的部门

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

在哪里

  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"

更新 2 - “2.2.3/jquery.js” + 依赖

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

然后:

[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

更新 3 - “1.11.4/core.js” 如果:

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

然后:

[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

更新:

从 web-jar pom.xml,

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

我看不出它会依赖于 jquery 2.2.3 ...

--

作为一个用户,我想会等几年让它成熟。

4

2 回答 2

4

你的依赖

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

是模棱两可的,因为有几个文件与jquery.js您的类路径上的后缀匹配。您可以使用更长的后缀来消除它们的歧义,例如:

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

这将只匹配路径

META-INF/resources/webjars/jquery/2.2.3/jquery.js
于 2016-05-15T14:21:58.243 回答
0

刚刚使用了另一个包含 Draggbale 的 jquery-ui。

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

以及我的使用方式:

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

不知道为什么它拉了3.0.0-beta1dep

于 2016-05-19T00:52:26.763 回答