-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: check file ext before dir as documented
The documented resolution algorithm started to search for package.json files prior to searching for file extensions when searching for a specifier. Oddly, it did not search for index files at same time it searched for package.json. This restores the documented behavior of searching for file extensions prior to searching directories. PR-URL: #15015 Fixes: #14990 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe>
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/module-extension-over-directory/inner/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"main": "./package.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
// fixes regression from v4 | ||
require('../common'); | ||
const assert = require('assert'); | ||
const fixtures = require('../common/fixtures'); | ||
const path = require('path'); | ||
|
||
const fixturesRequire = require( | ||
fixtures.path('module-extension-over-directory', 'inner')); | ||
|
||
assert.strictEqual( | ||
fixturesRequire, | ||
require(fixtures.path('module-extension-over-directory', 'inner.js')), | ||
'test-require-extension-over-directory failed to import fixture' + | ||
' requirements' | ||
); | ||
|
||
const fakePath = [ | ||
fixtures.path('module-extension-over-directory', 'inner'), | ||
'fake', | ||
'..' | ||
].join(path.sep); | ||
const fixturesRequireDir = require(fakePath); | ||
|
||
assert.strictEqual( | ||
fixturesRequireDir, | ||
require(fixtures.path('module-extension-over-directory', 'inner/')), | ||
'test-require-extension-over-directory failed to import fixture' + | ||
' requirements' | ||
); |