microsoft / vscode-loader

An universal Asynchronous Module Definition (AMD) Loader developed primarily to load VSCode's sources.
Other
170 stars 55 forks source link

Unload or ability to redefine a module? #9

Open joewood opened 7 years ago

joewood commented 7 years ago

It would be useful to redefine a module using define or provide a function to unload a module. Right now calling define with the same module name (with ignore duplicates) ignores the contents if it has changed.

joewood commented 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.

alexdima commented 6 years ago

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...

SamB commented 5 years ago

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?