4

如何使用 sbt-scalajs 插件排除 scalajs 依赖项?

我正在尝试导入以下库

"org.webjars.bower" % "react-bootstrap-datetimepicker" % "0.0.14" / "react-bootstrap-datetimepicker.js"

但是这个库正在下载我的项目中已经存在的其他依赖项(“react”和“react-bootstrap”),并且我遇到了版本冲突。

我试过使用排除功能

"org.webjars.bower" % "react-bootstrap-datetimepicker" % "0.0.14" exclude ("org.webjars.bower", "react") 

但这不允许我将/“react-bootstrap-datetimepicker.js”附加到命令中。

我得到的例外是:

org.scalajs.core.tools.classpath.JSLibResolveException: Some references to JS libraries could not be resolved:
- Ambiguous reference to a JS library: react-bootstrap.js
  Possible paths found on the classpath:
  - META-INF/resources/webjars/react-bootstrap/0.16.1/react-bootstrap.js
  - META-INF/resources/webjars/react-bootstrap/0.23.7/react-bootstrap.js
  originating from: adminJS:compile

    at org.scalajs.core.tools.classpath.PartialClasspath.resolveAllResourceNames(PartialClasspath.scala:137)
    at org.scalajs.core.tools.classpath.PartialClasspath.resolveDependencies(PartialClasspath.scala:80)
    at org.scalajs.core.tools.classpath.PartialClasspath.resolve(PartialClasspath.scala:64)
    at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$11.apply(ScalaJSPluginInternal.scala:140)
    at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$11.apply(ScalaJSPluginInternal.scala:137)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
4

1 回答 1

5

exclude是 sbt 的一个特性,libraryDependenciesjsDependencies. 所以你不能exclude直接在 you中声明一个jsDependencies。但是,由于jsDependencies构建在 之上libraryDependencies,您可以通过将两者结合起来实现您想要的,并使用一些重复的代码:

libraryDependencies +=
  "org.webjars.bower" % "react-bootstrap-datetimepicker" % "0.0.14" exclude ("org.webjars.bower", "react")
jsDependencies +=
  "org.webjars.bower" % "react-bootstrap-datetimepicker" % "0.0.14" / "react-bootstrap-datetimepicker.js"
于 2015-07-18T17:00:04.777 回答