流星-为什么我们需要单文件库的软件包? [英] Meteor - Why do we need packages for single-file libraries?

查看:72
本文介绍了流星-为什么我们需要单文件库的软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解Meteor完全是关于软件包的-毕竟,Meteor实际上只是软件包的集合.

I understand that Meteor is all about packages - after all, Meteor is really just a collection of packages.

我了解到有一些专门为Meteor创建的软件包,例如Iron Router,它将为我们节省大量从头开始创建路由器的工作!

I understand there are packages created especially for Meteor, like the Iron Router, which would save us a lot of effort recreating a router from scratch!

但是,有些软件包我根本看不到它的用途.例如,我不明白为什么需要一个 jQuery包建议采用推荐方式在流星中安装jQuery.经过仔细检查,它只是打包了一个自定义jQuery文件.为什么我不能简单地下载jQuery并将其添加到/client/lib/目录?

However, there are packages which I simply do not see the purpose for. For example, I do not understand why there needs to be a jQuery package, as suggested to be recommended way to install jQuery in Meteor. Upon close inspection, it is simply packaging a custom jQuery file. Why can I not simply download jQuery and add it to the /client/lib/ directory?

这不是唯一的示例-现代 jQuery Block UI

This is not the only example - modernizr, jQuery Block UI

tl;博士
请从概念上向我解释在软件包中使用简单的单文件库(例如jQuery)而不是独立文件的价值

tl;dr
Please explain to me conceptually the value of using a simple single-file library (e.g. jQuery) inside a package instead of a standalone file

推荐答案

如果维护该软件包,则始终可以免费获得该库的最新版本.

If the package is maintained, you always have the latest version of the library for free.

如果您使用两个都使用同一个库的不同软件包,则它们不需要包括它们自己的库副本.取而代之的是,他们使用提供该库的软件包,Meteor确保仅加载该库的一个实例,并且两个软件包都可以访问该库.

If you use two different packages that both make use of the same library, they don't need to include their own copy of the library. Instead they use a package providing the library, and Meteor makes sure only one instance of the library is loaded, and that both packages have access to it.

这篇关于流星-为什么我们需要单文件库的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆