gpt4 book ai didi

underscore.js - Bower 覆盖依赖

转载 作者:行者123 更新时间:2023-12-04 15:22:29 25 4
gpt4 key购买 nike

我有一个应用程序,用 Marionette 和其他一些依赖项用 Backbone 编写,通过 管理。 bower :

{
"name": "admin",
"version": "0.1.1",
"main": "public/javascripts/app.js",
"dependencies": {
"lodash": "~2.4.1",
"console-polyfill": "~0.1.0",
"jquery": "~2.1.1",
"normalize-css": "~2.1.2",
"marionette": "~1.7.4",
"bootstrap": "~3.1.1",
"font-awesome": "~4.1.0",
"backbone-pageable": "~1.4.5",
"moment": "~2.5.1",
"swag": "~0.6.1",
"jquery-form": "~3.46.0",
"jquery-file-upload": "~9.5.7",
"underscore.string": "~2.3.3",
"bootstrap-switch": "~3.0.1",
"joint": "~0.9.0"
},
"overrides": {
"backbone": {
"dependencies": {
"lodash": "*",
"jquery": "*"
},
"main": "backbone.js"
},
"backbone.wreqr": {
"dependencies": {
"backbone": "*"
},
"main": "lib/amd/backbone.wreqr.js"
},
"backbone-pageable": {
"dependencies": {
"backbone": "*"
},
"main": "lib/backbone-pageable.js"
},
"jquery-file-upload": {
"dependencies": {
"jquery": "*"
},
"main": [
"js/vendor/jquery.ui.widget.js",
"js/jquery.iframe-transport.js",
"js/jquery.fileupload.js"
]
},
"underscore.string": {
"dependencies": {
"lodash": "*"
},
"main": "lib/underscore.string.js"
},
"joint": {
"dependencies": {
"lodash": "*"
},
"main": "dist/joint.clean.js"
}
},
"resolutions": {
"jquery": "~2.1.1"
}
}

我要加 Joint.js ( http://www.jointjs.com/ ),这取决于 洛达什 (替代 下划线 ),但我不知道如何在我的配置中替换它,因为 Marionette、Backbone 和其他一些库直接依赖于下划线。所以在加载下划线覆盖 lodash,应用程序无法正确启动。

最佳答案

我已经更改了顺序,并将 lodash 作为最新的依赖项,并且它起作用了。

同样作为解决方案,可以选择使用 bower Hook ,如以下答案中所述
https://stackoverflow.com/a/23289270/575338

We had a similar situation where we had Backbone depend on Underscore in its bower.json, but we're using Lo-Dash in its stead, so Bower was unnecessarily pulling down Underscore for each install. We have automated checks for 3rd party license compliance, so we didn't want anything we don't actually use.

I realize this isn't exactly what they're meant for, but Bower's install-hooks can be used to clean unneeded deps post-install (at least until Bower gets the sort of "no thanks" resolution you hinted at). In your .bowerrc:

{
"directory": "app/bower_components",
"scripts": {
"postinstall": "rm -rf app/bower_components/underscore"
}
}

It's a bit of a hack, but works.

关于underscore.js - Bower 覆盖依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24231184/

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