forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
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 was regressed and 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 reverts that regression and restores the documented behavior of searching for file extensions prior to searching directories. Fixes: nodejs#14990 PR-URL: nodejs#15015 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
Showing
5 changed files
with
41 additions
and
9 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,26 @@ | ||
'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' | ||
); |
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