--production throws "Spacebars is not defined" error

So here’s a good one for you all.

My colleague cannot run our app with the --production flag, the bundled/minified app throws a “Uncaught ReferenceError: Spacebars is not defined” error.

I can run our app OK.

He sent me a .tgz of his project directory, and when I run his build on my machine, I see the same error.

For grins we did a clean checkout from Github on his machine, and that also throws the same error. We also reinstalled Meteor on his box.

Any idea how to debug this further? Thanks.

Well, I think I solved it. Despite declaring a dependency in package.js in one of our custom packages, that was loading before the package on which it depends was loaded, and that was somehow causing a problem deep down inside, and even though the application appears to be running, it was not. Wrapping the code in our package with Meteor.startup(function() seems to resolve it.