require.undef() does not clear cache
kitsonk opened this issue · 0 comments
kitsonk commented
Bug
If you use require.undef(mid)
but you had originally injected the module via the require.cache()
API, the module does not clear the cache, and therefore when the module is attempted to be loaded again, the module will revert to the cached module, which is unlikely undesired.
Package Version: beta1
Code
require.cache({
'some/mid'() {
define([], () => { return 'foo'; });
}
});
require.cache({}); // needed because of #124
/* use module === 'foo' */
require.undef('some/mid');
/* module will still === 'foo' */
Expected behavior:
That when a module is require.undef()
it will full undefine the module, not running the cached factory again.
Actual behavior:
The cached factory is run again, instead of being purged.