[Compiler] Add abstract base class to ModuleLoader
And refactor the code. Now the js module loader will traverse the tree twice to not need to guess things.