Andy
Andy

Reputation: 8692

What happens when export names conflict in Meteor?

I read that in Meteor,

If your app uses the email package (and only if it uses the email package!) then your app can see Email and you can call Email.send. Most packages have only one export, but some packages might have two or three (for example, a package that provides several classes that work together).

So what happens if your app uses two packages that export a variable named Email? Which Email does your app get? Is Package.a.Email / Package.b.Email the only workaround?

Upvotes: 0

Views: 77

Answers (1)

Tarang
Tarang

Reputation: 75965

This is where meteor's namespacing system comes in. Only one of the two packages, typically the one added last will get the global Email variable.

The only work around is to use Package.a as you've mentioned.

If a package is dependent on another package there shouldn't be an issue if the package in question is referenced correctly with api.use("xxx") in the package.js

If you use two packages with exports as dependencies for a package you will have to use the Package.xx naming convention (note Meteor actually uses this under the hood, it will actually convert your code if you don't use Package.xx.

With the global variable, Email, you have to be careful as only one of the package will get the global variable.

Upvotes: 1

Related Questions