Adding the same file twice in the same package is now an
error. Previously, this could either lead to the file being included
multiple times (eg, JS), or to a build time crash (eg, client-side
assets).
Before:
While reading package from
`/private/tmp/meteor-duplicate-path-error/packages/dupe`:
/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/package-api.js:22:5:
Invalid 'where' argument: '[object Object]'
at Array.forEach (native)
at Function._.each._.forEach
(/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
at toArchArray
(/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/package-api.js:22:5)
at PackageAPI._.extend.addFiles
(/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/package-api.js:287:12)
at package.js:2:7
After:
While reading package from
`/private/tmp/meteor-duplicate-path-error/packages/dupe`:
package.js:2:7: Invalid 'where' argument: '[object Object]'
The major problem here was that numeric useMyCaller never quite worked,
since useMyCaller was only used to calculate the file/line/etc for the
error, and not to convince formatMessages to not print the rest of the
stack.
The other issue is that `_.each` adds two levels of stack over just
using a `for` loop, whereas 8bcbd6534 only added 1 to the useMyCaller
argument.
Summary:
The methods of the ad-hoc `api` object needed access to very few variables
from the surrounding lexical environment, and those few variables
(`sources`, `exports`, `uses`, `implies`) are better regarded as member
variables of the `PackageAPI` class.
Test Plan: `meteor test-packages`
Reviewers: Slava, dgreensp, glasser
Reviewed By: glasser
Differential Revision: https://phabricator.meteor.io/D30