Implements module caching like commonjs modules