Skip to content

Commit

Permalink
Fix felixge#50: Circular requires that work with regular requires do …
Browse files Browse the repository at this point in the history
…not work with sandboxed-module
  • Loading branch information
wicharek committed Feb 28, 2016
1 parent 6bb1191 commit 16b5718
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/sandboxed_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ SandboxedModule.prototype._createRecursiveRequireProxy = function() {
if (request in cache) return cache[request];
return require(request);
}

// Quick and dirty fix for cyclic modules
// Basically, put exports in cache as soon as we require something else from this module
cache[this.filename] = this.exports;

// cached modules
var requestedFilename = requireLike(this.filename).resolve(request);
if (requestedFilename in cache) return cache[requestedFilename];
Expand Down

0 comments on commit 16b5718

Please sign in to comment.