module: remove dead code · nodejs/node@d11c4be (original) (raw)

`@@ -65,16 +65,9 @@ let ModuleJob;

`

65

65

`let createDynamicModule;

`

66

66

``

67

67

`const {

`

68

``

`-

CHAR_UPPERCASE_A,

`

69

``

`-

CHAR_LOWERCASE_A,

`

70

``

`-

CHAR_UPPERCASE_Z,

`

71

``

`-

CHAR_LOWERCASE_Z,

`

72

68

`CHAR_FORWARD_SLASH,

`

73

69

`CHAR_BACKWARD_SLASH,

`

74

``

`-

CHAR_COLON,

`

75

``

`-

CHAR_UNDERSCORE,

`

76

``

`-

CHAR_0,

`

77

``

`-

CHAR_9,

`

``

70

`+

CHAR_COLON

`

78

71

`} = require('internal/constants');

`

79

72

``

80

73

`const isWindows = process.platform === 'win32';

`

`@@ -472,14 +465,10 @@ if (isWindows) {

`

472

465

`};

`

473

466

`}

`

474

467

``

475

``

-

476

``

`-

// 'index.' character codes

`

477

``

`-

const indexChars = [ 105, 110, 100, 101, 120, 46 ];

`

478

``

`-

const indexLen = indexChars.length;

`

479

``

`-

Module._resolveLookupPaths = function(request, parent, newReturn) {

`

``

468

`+

Module._resolveLookupPaths = function(request, parent) {

`

480

469

`if (NativeModule.canBeRequiredByUsers(request)) {

`

481

470

`debug('looking for %j in []', request);

`

482

``

`-

return (newReturn ? null : [request, []]);

`

``

471

`+

return null;

`

483

472

`}

`

484

473

``

485

474

`// Check for node modules paths.

`

`@@ -495,71 +484,24 @@ Module._resolveLookupPaths = function(request, parent, newReturn) {

`

495

484

`}

`

496

485

``

497

486

`debug('looking for %j in %j', request, paths);

`

498

``

`-

return (newReturn ? (paths.length > 0 ? paths : null) : [request, paths]);

`

``

487

`+

return paths.length > 0 ? paths : null;

`

499

488

`}

`

500

489

``

501

490

`// With --eval, parent.id is not set and parent.filename is null.

`

502

491

`if (!parent || !parent.id || !parent.filename) {

`

503

492

`// Make require('./path/to/foo') work - normally the path is taken

`

504

493

`// from realpath(__filename) but with eval there is no filename

`

505

``

`-

var mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths);

`

``

494

`+

const mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths);

`

506

495

``

507

496

`debug('looking for %j in %j', request, mainPaths);

`

508

``

`-

return (newReturn ? mainPaths : [request, mainPaths]);

`

509

``

`-

}

`

510

``

-

511

``

`-

// Is the parent an index module?

`

512

``

`-

// We can assume the parent has a valid extension,

`

513

``

`-

// as it already has been accepted as a module.

`

514

``

`-

const base = path.basename(parent.filename);

`

515

``

`-

var parentIdPath;

`

516

``

`-

if (base.length > indexLen) {

`

517

``

`-

var i = 0;

`

518

``

`-

for (; i < indexLen; ++i) {

`

519

``

`-

if (indexChars[i] !== base.charCodeAt(i))

`

520

``

`-

break;

`

521

``

`-

}

`

522

``

`-

if (i === indexLen) {

`

523

``

`-

// We matched 'index.', let's validate the rest

`

524

``

`-

for (; i < base.length; ++i) {

`

525

``

`-

const code = base.charCodeAt(i);

`

526

``

`-

if (code !== CHAR_UNDERSCORE &&

`

527

``

`-

(code < CHAR_0 || code > CHAR_9) &&

`

528

``

`-

(code < CHAR_UPPERCASE_A || code > CHAR_UPPERCASE_Z) &&

`

529

``

`-

(code < CHAR_LOWERCASE_A || code > CHAR_LOWERCASE_Z))

`

530

``

`-

break;

`

531

``

`-

}

`

532

``

`-

if (i === base.length) {

`

533

``

`-

// Is an index module

`

534

``

`-

parentIdPath = parent.id;

`

535

``

`-

} else {

`

536

``

`-

// Not an index module

`

537

``

`-

parentIdPath = path.dirname(parent.id);

`

538

``

`-

}

`

539

``

`-

} else {

`

540

``

`-

// Not an index module

`

541

``

`-

parentIdPath = path.dirname(parent.id);

`

542

``

`-

}

`

543

``

`-

} else {

`

544

``

`-

// Not an index module

`

545

``

`-

parentIdPath = path.dirname(parent.id);

`

546

``

`-

}

`

547

``

`-

var id = path.resolve(parentIdPath, request);

`

548

``

-

549

``

`-

// Make sure require('./path') and require('path') get distinct ids, even

`

550

``

`-

// when called from the toplevel js file

`

551

``

`-

if (parentIdPath === '.' &&

`

552

``

`-

id.indexOf('/') === -1 &&

`

553

``

`-

(!isWindows || id.indexOf('\') === -1)) {

`

554

``

`-

id = './' + id;

`

``

497

`+

return mainPaths;

`

555

498

`}

`

556

499

``

557

``

`-

debug('RELATIVE: requested: %s set ID to: %s from %s', request, id,

`

558

``

`-

parent.id);

`

``

500

`+

debug('RELATIVE: requested: %s from parent.id %s', request, parent.id);

`

559

501

``

560

502

`const parentDir = [path.dirname(parent.filename)];

`

561

``

`-

debug('looking for %j in %j', id, parentDir);

`

562

``

`-

return (newReturn ? parentDir : [id, parentDir]);

`

``

503

`+

debug('looking for %j', parentDir);

`

``

504

`+

return parentDir;

`

563

505

`};

`

564

506

``

565

507

`// Check the cache for the requested file.

`

`@@ -647,15 +589,15 @@ Module._resolveFilename = function(request, parent, isMain, options) {

`

647

589

`for (var i = 0; i < options.paths.length; i++) {

`

648

590

`const path = options.paths[i];

`

649

591

`fakeParent.paths = Module._nodeModulePaths(path);

`

650

``

`-

const lookupPaths = Module._resolveLookupPaths(request, fakeParent, true);

`

``

592

`+

const lookupPaths = Module._resolveLookupPaths(request, fakeParent);

`

651

593

``

652

594

`for (var j = 0; j < lookupPaths.length; j++) {

`

653

595

`if (!paths.includes(lookupPaths[j]))

`

654

596

`paths.push(lookupPaths[j]);

`

655

597

`}

`

656

598

`}

`

657

599

`} else {

`

658

``

`-

paths = Module._resolveLookupPaths(request, parent, true);

`

``

600

`+

paths = Module._resolveLookupPaths(request, parent);

`

659

601

`}

`

660

602

``

661

603

`// Look up the filename first, since that's the cache key.

`