Created
February 2, 2010 13:54
-
-
Save blaine/292682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in some global context. this is just a sketch, not intended to be deployed. | |
function watchModuleUrl(url, parent) { | |
var resolvedModule = resolveModulePath(request, parent); | |
var id = resolvedModule[0], | |
paths = resolvedModule[1]; | |
findModulePath(url, paths, function (filename) { | |
if (!filename) return; | |
process.watchFile(filename, function () { | |
loadPromise = loadModule(url, parent); | |
loadPromise.addCallback(function (module) { | |
parent.unCacheModule(url); | |
parent.requireAsync(url).addCallback(child) { | |
child.moduleCache = {}; | |
process.mixin(child.moduleCache, globalModuleCache); | |
}; | |
}); | |
}); | |
} | |
// in Module.loadScript | |
function requireHotAsync (url) { | |
watchModuleUrl(url, self); | |
return requireAsync(url); | |
} | |
function requireHot (url) { | |
return requireHotAsync(url).wait(); | |
} | |
require.hot = requireHot; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment