derek
derek

Reputation: 10207

Meteor does not require to import a package for use?

Just realized that Meteor did not require a "import" to use a package.

For example, I am using a package here: https://github.com/reactioncommerce/meteor-security

meteor add ongoworks:security

After that, I can directly use the packge without import it.

It is kind of a myth to me. What is happening underneath? Does Meteor automatically load all added packages?

Thanks

Derek

Upvotes: 0

Views: 172

Answers (2)

JeremyK
JeremyK

Reputation: 3240

This is known as eager evaluation or loading, and predates meteor having any module system. It remains there for to support backwards compatibility, including meteor's atmosphere packages.

The downside is that everything exported by the package is in the global namespace, though in this case it looks like it is just the Security that is being added to the global namespace.

Upvotes: 1

zim
zim

Reputation: 2386

from the Meteor Guide (https://guide.meteor.com/atmosphere-vs-npm.html#when-atmosphere):

Atmosphere packages are packages written specifically for Meteor and have several advantages over npm when used with Meteor. In particular, Atmosphere packages can:
- Get direct access to Meteor’s package namespacing and package global exports without having to explicitly use ES2015

Upvotes: 2

Related Questions