Permalink
Browse files

Support module.exports for replacing the exports

  • Loading branch information...
1 parent d8413f4 commit 11018d8d650b3a24bec16bd3e35b6c351addbebc @kriszyp committed Aug 27, 2010
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/nodules.js
View
@@ -226,6 +226,7 @@ function makeRequire(currentId){
module = modules[uri] = modules[uri] || new Module(uri),
currentFile = cachePath(uri),
factory = factories[uri],
+ originalExports = module.exports = exports,
nextRequire = makeRequire(uri);
module.dependents[currentId] = true;
exports = factory.call(exports, nextRequire, exports, module,
@@ -237,6 +238,11 @@ function makeRequire(currentId){
currentFile, currentFile.replace(/\/[^\/]*$/,''))
|| exports;
}
+ if(originalExports != module.exports){
+ exports = module.exports;
+ }
+ Object.defineProperty(module, "exports",{value:exports});
+ moduleExports[uri] = exports;
var successful = true;
}
finally{

0 comments on commit 11018d8

Please sign in to comment.