微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

node.js – 在ScalaJs sbt构建中,使用webjars而不是“提供”的npm或bower有什么优势吗?

当我几个月前第一次发现webJars时,我对此持怀疑态度,因为这些构建/构建系统中的一些构建/构建系统的复杂性非常大,并且考虑到js文件发布的频率,这将是一种处理客户端依赖关系的可行方法.第二个问题当然不是有根据的,但是经过花费近36个小时的时间,我觉得第一个关心是无庸置疑的,现在尝试使用大约10个scss / css / less-type webJars和8个JS webJars来生活在一个jsDependencies屋顶下.

当我遇到JS依赖关系3,4或5的时候,我发现了这样一个可笑的时间循环:

1.“哦,诺斯!fastOptJS失败了,因为有一些随机文件在webjar中也被命名为一个依赖关系!”

[trace] Stack trace suppressed: run last client/compile:resolvedJSDependencies for the full output.
[error] (client/compile:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries Could not be resolved:
[error] - Ambiguous reference to a JS library: bootstrap.min.js
[error]   Possible paths found on the classpath:
[error]   - meta-inf/resources/webjars/bootstrap/3.3.6/js/bootstrap.min.js
[error]   - meta-inf/resources/webjars/bootstrap3-dialog/1.34.4/examples/assets/bootstrap/js/bootstrap.min.js
[error]   originating from: client:compile,client:compile,client:compile
[error] - Ambiguous reference to a JS library: bootstrap.js
[error]   Possible paths found on the classpath:
[error]   - meta-inf/resources/webjars/bootstrap3-dialog/1.34.4/examples/assets/bootstrap/js/bootstrap.js
[error]   - meta-inf/resources/webjars/bootstrap/3.3.6/js/bootstrap.js
[error]   originating from: client:compile,client:compile

我知道该怎么办我将添加一个版本到定义的js!

lazy val           webjarbs   =   "org.webjars"               %    "bootstrap"                       % version.bootstrap  / s"${version.bootstrap}/bootstrap.js"                      minified s"${version.bootstrap}/bootstrap.min.js"         dependsOn    "jquery.js" commonjsName  "bootstrap"

“哦不,fastOptJS失败了!”

[trace] Stack trace suppressed: run last client/compile:resolvedJSDependencies for the full output.
[error] (client/compile:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries Could not be resolved:
[error] - Missing JS library: 3.3.6/bootstrap.js
[error]   originating from: client:compile,client:compile
[error] - Missing JS library: 3.3.6/bootstrap.min.js
[error]   originating from: client:compile,client:compile

gg男孩.

这样一来又一遍又一遍,然后我就要开始做

lazy val         bs_sidebar   = ( "org.webjars"               %    "bootstrap-sidebar"              % version.bs_sidebar intransitive())  / "js/sidebar.js" dependsOn(s"bootstrap.js",s"bootstrap.min.js")

现在我甚至没有使用webjar,但它有一个名为X的jsependencies,我不能改变那个…

嗯?如果我只是做了我以前做的工作,而是将应用程序建立在一些巨大的文件或一组文件中,然后将其加载到构建中的依赖项?我有一个在线的概念证明,我得到它的工作(我认为是https://github.com/wav/material-ui-scalajs-react/blob/master/src/main/scala/wav/web/muiwrapper/package.scala)几乎工作,并给了我的想法.

我知道npm的工作比sbt好多了,我仍然可以把它放到我的包中…有什么不利的地方,我是否缺少关于sbt的东西?

解决方法

我赞同你.一旦应用程序开始对JavaScript库有不平凡的依赖,jsDependencies就不会扩展.这主要是因为WebJars缺少关键功能(就像传递性依赖)一样,而且因为jsDependencies不是一个被设计为扩展的机制.

随着时间的流逝,用户已经要求越来越多的jsDependencies的功能,因为他们希望将其用作真正的应用程序规模(无论什么意思)依赖机制.因此,我们已经在jsDependencies之上修补越来越多的功能/黑客.结果不是世界上最漂亮的事情,它绝对有缺点.

我实际上会鼓励使用npm来解决你的依赖关系,特别是如果你熟悉它,并且知道如何将它集成到你的工作流中.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐