Open joewood opened 7 years ago
Another solution to being able to redefine a module would be to use a local AMDLoader ModuleManager. Right now the loader is defined to be global (AMDLoader
is defined in global scope and not inside a function enclosure). Adding a parent function enclosure to optionally define a separate local AMDLoader, with its own ModuleManager would make it easier to tear down and redefine modules.
Today, it is possible to reset the state via require.reset()
, but I like the idea of being able to overwrite a specific module if necessary, without resetting everything...
Is this about reloading modules to try out changes during development (which is a thing that people are going to sometimes want with more-or-less any module loader, whether that's practical or not), or for some kind of mocking/shimming/SxS type thing?
It would be useful to redefine a module using
define
or provide a function to unload a module. Right now callingdefine
with the same module name (with ignore duplicates) ignores the contents if it has changed.