@@ -77,7 +77,6 @@ const {
7777 CHAR_FORWARD_SLASH ,
7878 CHAR_BACKWARD_SLASH ,
7979 CHAR_COLON ,
80- CHAR_DOT ,
8180 CHAR_UNDERSCORE ,
8281 CHAR_0 ,
8382 CHAR_9 ,
@@ -382,18 +381,6 @@ Module._findPath = function(request, paths, isMain) {
382381 }
383382
384383 if ( filename ) {
385- // Warn once if '.' resolved outside the module dir
386- if ( request === '.' && i > 0 ) {
387- if ( ! warned ) {
388- warned = true ;
389- process . emitWarning (
390- 'warning: require(\'.\') resolved outside the package ' +
391- 'directory. This functionality is deprecated and will be removed ' +
392- 'soon.' ,
393- 'DeprecationWarning' , 'DEP0019' ) ;
394- }
395- }
396-
397384 Module . _pathCache [ cacheKey ] = filename ;
398385 return filename ;
399386 }
@@ -497,35 +484,23 @@ Module._resolveLookupPaths = function(request, parent, newReturn) {
497484 return ( newReturn ? null : [ request , [ ] ] ) ;
498485 }
499486
500- // Check for non-relative path
501- if ( request . length < 2 ||
502- request . charCodeAt ( 0 ) !== CHAR_DOT ||
503- ( request . charCodeAt ( 1 ) !== CHAR_DOT &&
504- request . charCodeAt ( 1 ) !== CHAR_FORWARD_SLASH &&
505- ( ! isWindows || request . charCodeAt ( 1 ) !== CHAR_BACKWARD_SLASH ) ) ) {
506- var paths = modulePaths ;
507- if ( parent ) {
508- if ( ! parent . paths )
509- paths = parent . paths = [ ] ;
510- else
511- paths = parent . paths . concat ( paths ) ;
512- }
487+ // Check for node modules paths.
488+ if ( request . charAt ( 0 ) !== '.' ||
489+ ( request . length > 1 &&
490+ request . charAt ( 1 ) !== '.' &&
491+ request . charAt ( 1 ) !== '/' &&
492+ ( ! isWindows || request . charAt ( 1 ) !== '\\' ) ) ) {
513493
514- // Maintain backwards compat with certain broken uses of require('.')
515- // by putting the module's directory in front of the lookup paths.
516- if ( request === '.' ) {
517- if ( parent && parent . filename ) {
518- paths . unshift ( path . dirname ( parent . filename ) ) ;
519- } else {
520- paths . unshift ( path . resolve ( request ) ) ;
521- }
494+ let paths = modulePaths ;
495+ if ( parent != null && parent . paths && parent . paths . length ) {
496+ paths = parent . paths . concat ( paths ) ;
522497 }
523498
524499 debug ( 'looking for %j in %j' , request , paths ) ;
525500 return ( newReturn ? ( paths . length > 0 ? paths : null ) : [ request , paths ] ) ;
526501 }
527502
528- // with --eval, parent.id is not set and parent.filename is null
503+ // With --eval, parent.id is not set and parent.filename is null.
529504 if ( ! parent || ! parent . id || ! parent . filename ) {
530505 // Make require('./path/to/foo') work - normally the path is taken
531506 // from realpath(__filename) but with eval there is no filename
0 commit comments