0

I guess the topic of Meteor forcing execution order heuristics on its users instead of providing import semantics has been discussed to death already.

Nevertheless, I think there should at the very least be a way to make 100% sure that a certain set of scripts can be run before everything else. From what I understand, since the load order heuristic goes depth-first over everything else (even if you have multiple lib folders in different places, the ones at a greater depth are run first for some reason), there is basically no way to ensure that some scripts are executed before everything else, no matter how deep it goes, unless you put it in a package.

Is that correct? And is there anything to be expected to remedy the situation in an upcoming release?

For now, I am considering writing a little load-order-util package that at the very least allows deferring execution of a callback until startup and after a given set of globally defined symbols are ready, like so:

Global.dependsOnSymbols = function(symbolNameOrNames, cb) { ... };

Any better suggestions?

Domi
  • 22,151
  • 15
  • 92
  • 122
  • What exactly are you trying to do in this script? Meteor related operations or just generic javascript to initialise something? – ravish.hacker Mar 25 '16 at 10:22
  • @ravish.hacker As I just commented on the first answer, I have a whole bunch of code, and some of that code is so impudent to depend on other code that is in other folders that might or might not be at a greater depth as itself. – Domi Mar 25 '16 at 10:27

1 Answers1

0

As you can realize by reading:

How do I change the order in which Meteor loads Javascript files?

and

In Meteor JS, how to control Javascript load order in relation to DOM load order? For animations

as things are right now, it is probably better to stick with the loading conventions offered by the framework itself.

Anyway, the upcoming 1.3 release should finally address the problem providing ES2015 modules support.

Community
  • 1
  • 1
Francesco Pezzella
  • 1,755
  • 2
  • 15
  • 18
  • The current framework does not offer a solution to my problem, where I have a whole bunch of folders, and code being so impudent to depend on other code that is in other folders that might or might not be at a greater depth as itself. I'll try my `startup` registration utility and share results later :) – Domi Mar 25 '16 at 10:26
  • 1
    Well, if you are going to write your own solution you may want to give a peek to some existing packages: https://atmospherejs.com/?q=load%20order Hope it helps :) – Francesco Pezzella Mar 25 '16 at 10:34
  • Thanks for the hint. I checked, and of the three packages: *One* is way too heavyweight, manually adding an entire stage to the meteor pipeline (by re-producing all files in a different file order in a sub-directory that mirrors your original code, but according to your configured load order preferences) and the other two are not quite what I'm looking for. – Domi Mar 25 '16 at 13:47