Once you have instantiated a module in a sandbox, all of the modules
in that sandbox have hard references to the instances of their
dependencies, so I don't recommend replacing instantiated modules.
However, Narwhal has a "sandbox" module which will let you instantiate
new sandboxes that can even share a module loader. The module loaders
will reload modules if they've changed.
Take a look at the "sandbox" method in the "sandbox" module. You can
even do clever things where you load your "base set" of modules and
then inherit those whenever you create a new sandbox to speed things
up.
Kris Kowal
Here's an example in Jack: https://github.com/280north/jack/blob/master/lib/jack/reloader.js
It's middleware that automatically reloads all files on every request. Not ideal but it works (unfortunately only in narwhal-rhino, not in narwhal-jsc though)
-tom