gpt4 book ai didi

sbt - 如何在 scalajs-react 项目中使用 sbt-scalajs 插件排除 javascript 依赖项?

转载 作者:行者123 更新时间:2023-12-04 23:51:17 24 4
gpt4 key购买 nike

如何使用 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”附加到命令中。

我得到的异常(exception)是:
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)

最佳答案

exclude是 sbt 的一个特性 libraryDependencies ,并且不会在 jsDependencies 中复制.所以你不能声明 exclude直接在你身上 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"

关于sbt - 如何在 scalajs-react 项目中使用 sbt-scalajs 插件排除 javascript 依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31493351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com