@@ -70,7 +70,6 @@ const {
70
70
CHAR_FORWARD_SLASH ,
71
71
CHAR_BACKWARD_SLASH ,
72
72
CHAR_COLON ,
73
- CHAR_DOT ,
74
73
CHAR_UNDERSCORE ,
75
74
CHAR_0 ,
76
75
CHAR_9 ,
@@ -306,7 +305,6 @@ function findLongestRegisteredExtension(filename) {
306
305
return '.js' ;
307
306
}
308
307
309
- var warned = false ;
310
308
Module . _findPath = function ( request , paths , isMain ) {
311
309
if ( path . isAbsolute ( request ) ) {
312
310
paths = [ '' ] ;
@@ -375,18 +373,6 @@ Module._findPath = function(request, paths, isMain) {
375
373
}
376
374
377
375
if ( filename ) {
378
- // Warn once if '.' resolved outside the module dir
379
- if ( request === '.' && i > 0 ) {
380
- if ( ! warned ) {
381
- warned = true ;
382
- process . emitWarning (
383
- 'warning: require(\'.\') resolved outside the package ' +
384
- 'directory. This functionality is deprecated and will be removed ' +
385
- 'soon.' ,
386
- 'DeprecationWarning' , 'DEP0019' ) ;
387
- }
388
- }
389
-
390
376
Module . _pathCache [ cacheKey ] = filename ;
391
377
return filename ;
392
378
}
@@ -490,35 +476,23 @@ Module._resolveLookupPaths = function(request, parent, newReturn) {
490
476
return ( newReturn ? null : [ request , [ ] ] ) ;
491
477
}
492
478
493
- // Check for non-relative path
494
- if ( request . length < 2 ||
495
- request . charCodeAt ( 0 ) !== CHAR_DOT ||
496
- ( request . charCodeAt ( 1 ) !== CHAR_DOT &&
497
- request . charCodeAt ( 1 ) !== CHAR_FORWARD_SLASH &&
498
- ( ! isWindows || request . charCodeAt ( 1 ) !== CHAR_BACKWARD_SLASH ) ) ) {
499
- var paths = modulePaths ;
500
- if ( parent ) {
501
- if ( ! parent . paths )
502
- paths = parent . paths = [ ] ;
503
- else
504
- paths = parent . paths . concat ( paths ) ;
505
- }
479
+ // Check for node modules paths.
480
+ if ( request . charAt ( 0 ) !== '.' ||
481
+ ( request . length > 1 &&
482
+ request . charAt ( 1 ) !== '.' &&
483
+ request . charAt ( 1 ) !== '/' &&
484
+ ( ! isWindows || request . charAt ( 1 ) !== '\\' ) ) ) {
506
485
507
- // Maintain backwards compat with certain broken uses of require('.')
508
- // by putting the module's directory in front of the lookup paths.
509
- if ( request === '.' ) {
510
- if ( parent && parent . filename ) {
511
- paths . unshift ( path . dirname ( parent . filename ) ) ;
512
- } else {
513
- paths . unshift ( path . resolve ( request ) ) ;
514
- }
486
+ let paths = modulePaths ;
487
+ if ( parent != null && parent . paths && parent . paths . length ) {
488
+ paths = parent . paths . concat ( paths ) ;
515
489
}
516
490
517
491
debug ( 'looking for %j in %j' , request , paths ) ;
518
492
return ( newReturn ? ( paths . length > 0 ? paths : null ) : [ request , paths ] ) ;
519
493
}
520
494
521
- // with --eval, parent.id is not set and parent.filename is null
495
+ // With --eval, parent.id is not set and parent.filename is null.
522
496
if ( ! parent || ! parent . id || ! parent . filename ) {
523
497
// Make require('./path/to/foo') work - normally the path is taken
524
498
// from realpath(__filename) but with eval there is no filename
0 commit comments