Hierarchical JavaScript dependency injection