felixge / node-sandboxed-module

A sandboxed node.js module loader that lets you inject dependencies into your modules.
MIT License
342 stars 42 forks source link

module.parent undefined #20

Closed stereobooster closed 11 years ago

stereobooster commented 11 years ago

see #18

var SandboxedModule = require('sandboxed-module');

var app = SandboxedModule.require('./../app', {
  requires: {'somemodule': {}}
});

vs

var app = require('./../app');

app.js

if (!module.parent) {
  console.log('Should not be called if module required');
}
domenic commented 11 years ago

Thanks for your interest and investigation. It's prompted me to move giving sandboxed-module some love toward the front of my weekend queue :)

domenic commented 11 years ago

This doesn't seem that easy, but if you want to give it a shot, go ahead. I'd think maybe after we set module.filename, you can try setting module.parent... but to what value?

domenic commented 11 years ago

Fixed by c3df0b57beaa4c0df82f046862a73fb57884fcbe!