Meteor - Why do we need packages for single-file l

2019-07-16 00:03发布

问题:

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

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!

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?

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

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

回答1:

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

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.