Skip to content
This repository
Browse code

Support module.exports for replacing the exports

  • Loading branch information...
commit 11018d8d650b3a24bec16bd3e35b6c351addbebc 1 parent d8413f4
Kris Zyp authored

Showing 1 changed file with 6 additions and 0 deletions. Show diff stats Hide diff stats

  1. +6 0 lib/nodules.js
6 lib/nodules.js
@@ -226,6 +226,7 @@ function makeRequire(currentId){
226 226 module = modules[uri] = modules[uri] || new Module(uri),
227 227 currentFile = cachePath(uri),
228 228 factory = factories[uri],
  229 + originalExports = module.exports = exports,
229 230 nextRequire = makeRequire(uri);
230 231 module.dependents[currentId] = true;
231 232 exports = factory.call(exports, nextRequire, exports, module,
@@ -237,6 +238,11 @@ function makeRequire(currentId){
237 238 currentFile, currentFile.replace(/\/[^\/]*$/,''))
238 239 || exports;
239 240 }
  241 + if(originalExports != module.exports){
  242 + exports = module.exports;
  243 + }
  244 + Object.defineProperty(module, "exports",{value:exports});
  245 + moduleExports[uri] = exports;
240 246 var successful = true;
241 247 }
242 248 finally{

0 comments on commit 11018d8

Please sign in to comment.
Something went wrong with that request. Please try again.