How does meteor knows what js file run first?


#1

I’m having issues trying to understand the flow of meteor and why, for example, in the folder server I have
config.js
publications.js

how does meteor knows what to call first? If I change the file name publications.js it still works, why?


#2

Meteor guide to the rescue! https://guide.meteor.com/structure.html#load-order

Basically all files outside of imports/ are automatically loaded.


#4

Thank you sashko for the quick reply, in the context of flow-router, how does this happens using this as example: https://github.com/arunoda/hello-react-meteor

I’m going thru kadira’s flow router docs but no info on it.


#5

I’m not sure how this is related to Flow Router at all. The router has exactly 0 impact on when code is executed.


#6

In https://guide.meteor.com/structure.html#load-order says the nav.html template is loaded first, then main.html, but in the flow-router example how does this compares?


#7

That list is just an example of how the rules listed might apply:

  1. HTML template files are always loaded before everything else
  1. Files beginning with main. are loaded last
  2. Files inside any lib/ directory are loaded next
  3. Files with deeper paths are loaded next
  4. Files are then loaded in alphabetical order of the entire path

#8

Thank you sashko! didn’t get the meaning of it the first and 2nd time