@ -274,17 +274,6 @@ Module._load = function(request, parent, isMain) {
debug ( 'Module._load REQUEST %s parent: %s' , request , parent . id ) ;
}
// REPL is a special case, because it needs the real require.
if ( request === 'internal/repl' || request === 'repl' ) {
if ( Module . _ cache [ request ] ) {
return Module . _ cache [ request ] ;
}
var replModule = new Module ( request ) ;
replModule . _ compile ( NativeModule . getSource ( request ) , ` ${ request } .js ` ) ;
NativeModule . _ cache [ request ] = replModule ;
return replModule . exports ;
}
var filename = Module . _ resolveFilename ( request , parent ) ;
var cachedModule = Module . _ cache [ filename ] ;
@ -376,27 +365,9 @@ var resolvedArgv;
// the file.
// Returns exception, if any.
Module . prototype . _ compile = function ( content , filename ) {
var self = this ;
// remove shebang
content = content . replace ( shebangRe , '' ) ;
function require ( path ) {
return self . require ( path ) ;
}
require . resolve = function ( request ) {
return Module . _ resolveFilename ( request , self ) ;
} ;
require . main = process . mainModule ;
// Enable support to add extra extension types
require . extensions = Module . _ extensions ;
require . cache = Module . _ cache ;
var dirname = path . dirname ( filename ) ;
// create wrapper function
var wrapper = Module . wrap ( content ) ;
@ -421,8 +392,10 @@ Module.prototype._compile = function(content, filename) {
global . v8debug . Debug . setBreakPoint ( compiledWrapper , 0 , 0 ) ;
}
}
var args = [ self . exports , require , self , filename , dirname ] ;
return compiledWrapper . apply ( self . exports , args ) ;
const dirname = path . dirname ( filename ) ;
const require = internalModule . makeRequireFunction . call ( this ) ;
const args = [ this . exports , require , this , filename , dirname ] ;
return compiledWrapper . apply ( this . exports , args ) ;
} ;
@ -488,10 +461,10 @@ Module._initPaths = function() {
Module . globalPaths = modulePaths . slice ( 0 ) ;
} ;
// bootstrap repl
Module . requireRepl = function ( ) {
return Module . _ load ( 'internal/repl' , '. ' ) ;
} ;
// TODO(bnoordhuis) Unused, remove in the future.
Module . requireRepl = internalUtil . deprecate ( function ( ) {
return Native Module. require ( 'internal/repl' ) ;
} , 'Module.requireRepl is deprecated.' ) ;
Module . _ preloadModules = function ( requests ) {
if ( ! Array . isArray ( requests ) )