@caridy I don't see there is an issue here if foo is processed after lang. The logic is 
1. the first "for (m in resolvedMods)" will go though all the modules and if a module starts with lang/, then the name of the mojit is saved in an array.
2. the second "for (m in resolvedMods)" will go though all the module and if the mojit name is found in the array add lang info to the module.
So I don't think the order of processing the modules matters.
I don't like the second for loop, but looks like there is no good way to get those mojits directly just by name.