Load files ordering
In this little post we’ll see how load files ordering works in an Meteor application.
In fact the rules are quite simple:
Templates (.html files) are loaded before anything.
Files in the lib directory are loaded then.
Files in deeper directories are loaded before.
Ordering for files in the same directory is alphabetical.
Main. * Files are loaded last.
Here’s an example:
Because lib has a higher precedence, everything inside, will be loaded first, however, following the same rules mentioned above. As the /lib/1/2 is the deepest directory, files there are read before and a.js and z.js are loaded following the alphabetical order.
Why is this important? Because if you do not remember that, you could for example, trying to use a function that has not been defined, due to the fact that the file where it is, has not been loaded yet.
Although simple, is good to know details defined by the platform, to avoid headaches with little mistakes that in the end of day, end up taking much of our time.