Refactored recursiveModuleCompile with promises.

Did some simplification of existing logic in recursiveModuleCompile, to
use promises more canonically.