Please note this question is about the yet-to-be-released Magento 2, which I'm still trying to get to grips with.
Each module contributes to each layout handle separately. For example, the
default handle is made up of these files:
base files come first followed by
frontend files, followed by a number of themes. I would like to know which order those in
frontend are used. I think
Magento/Theme/... must be first because many others make references to it's blocks, be it adding, moving or removing.
I considered they might be following dependency order but that isn't adequate because there are many circular dependencies. For example,
Magento_Customer depends on
Magento_Theme as you would expect, but
Magento_Theme also depends on
Magento_Customer. If the wrong order is followed then important customer blocks would not be shown.
By setting breakpoints I've worked out the files are not loaded in any particular order, they are just dumped into a merged DOM to be dealt with later. But I cannot tell what happens to the merged data afterwards, is it some kind of magic?