Skip to content

require.undef() does not clear cache #125

@kitsonk

Description

@kitsonk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions