Since new Function is a form of eval you can just eval
it:
eval("function testF(x,y){ console.log(require);}");
testF(1,2);
If you want to follow the original approach you'll need to pass those globals to the function scope:
var testF = new Function(
'exports',
'require',
'module',
'__filename',
'__dirname',
"return function(x,y){console.log(x+y);console.log(require);}"
)(exports,require,module,__filename,__dirname);
testF(1,2);