Is there a way to control module resolution logic ('require') for code
executing in a child context AS WELL AS any other further modules
imported by that code?
Defining 'require' function in the sandbox passed to a new script
context created though the vm module allows me to intercept module
resolution for the immediate code executing in that script context:
function myRequire(name) {
var m = require(name);
//... my custom code here
return m;
}
vm.runInNewContext('var a = require("./a.js")', {require: myRequire});
Given the code above, myRequire is called to resolve './a.js'.
However, if a.js contains the following:
var b = require('b')
the myRequire is no longer called for 'b'.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en