I’ve been upgrading several Meteor applications to 1.3 and I’ve been using a quick trick to help ease some of the pain. Check out my most recent post on transitioning to modules with global imports.
Importing modules and then exposing them as globals may seem like a backwards move at first, but it can definitely help ease some of the awkwardness of moving from a 1.2-style application over to 1.3 without the (minor) potential dangers and extra work of explicitly importing your module in every file it’s used.
Hopefully this helps some people out there who are tackling larger upgrades and want to keep their sanity.
You’re brilliant! Thank you so much! This is exactly what we’ve been talking about re: autoimport package. Add this into a package, and we have the perfect upgrade path for Blaze users, people with existing large apps, or beginners who aren’t yet comfortable with imports. Fantastic stuff!
Thanks all! I don’t know about brilliant… Usually the simplest solutions are the best solutions.
@chompomonim - Glad you figured out your problem. Honestly, I’m not sure how 1.3 packages will deal with collections moving forward. @sashko’s idea of passing in collection references is probably the most bullet-proof.
Su, @sashko’s idea is good in almost all cases, but I think we should be also be able to do the same with methods. I mean to pass collection as a method parameter Meteor.call('my_method', AwesomeCollection, (err, res) => {}).
Going to create feature request on github for that.
If you go down that road, definitely make sure you’re securing yourself. Don’t perform arbitrary transformations on any collection that a user gives you - that’ll open the door for worlds of trouble.