Optimize construction of dependency and component graph