问题描述
我维护了一个名为Angular Modal Service的AngularJS库。我想更改依赖关系,以便我以AngularJS 1.3为目标,像这样:
I maintain an AngularJS library called Angular Modal Service. I would like to change the dependencies so that I target AngularJS 1.3, like this:
"dependencies": {
"angular": "~1.3.0"
}
但是,我绝对知道该库适用于〜1.2。我不想强迫想要升级我的代码最新版本的消费者,可以这样做:
However, I know categorically that the library works for ~1.2. I don't want to force consumers who want the latest version of my code to have to upgrade, it is possible to do this:
"dependencies": {
"angular": "~1.3.0 | ~1.2.0"
}
离开图书馆对我的影响仍然很小?如果可能的话,实际上是否合适?
Letting my library remain low impact? And if it is possible, is it in fact appropriate? Are there any good guidelines on this?
推荐答案
您可以做的一件事情是使用最低的最低版本,并允许每个版本大于此值
One of the things you can do is use your lowest minimum version and allow every version greater than that
>=1.2.0
但是最好还放置您测试过的尽可能高的版本,以防将来的版本不兼容。
But what might be better is to also put the highest possible version that you have tested just in case there is a future version that isn't compatible.
>=1.2.0 <=1.3.0
或者它的简写可能看起来像这样
Or a shorthand version of that might look something like this
1.2.0 - 1.3.0
如果从上面删除第二个等号,最终得到的是该节点的版本语法调用一个可以缩短到此范围的x范围
If you remove the second equal sign from the above what you end up with is a version syntax that node calls an x-range which can be shortened to this
1.2.x
>=1.2.0 <1.3.0
所有这些以及更多内容都可以在。
All of this and more can be found on the node semver page.
这篇关于支持AngularJS的多个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!