cache param instead of global

Instead of using a global to store the cache, these commits let you pass in the cache as an optional parameter. With the global cache, multiple calls to `required()` can interfere even when the bundles should be separate.