-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
module: revert checking for package.json before extensions #15015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"main": "./package.json" | ||
} |
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a new eslint rule in place that prevents messages without dynamic content (or it is at least planned). I do see that it makes sense to have a individual message here, so we should either explicitly accept the message here or maybe just change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BridgeAR If that rule ever comes to pass, we can always disable it with a comment for the instances where a string literal makes sense. So this can stay as is, if the proposed lint rule is the only motivation for changing it. |
||
); | ||
|
||
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' | ||
); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👆 at the moment because the trailing slash check is for forward-slash-only, on Windows paths ending in a backslash hit that code path (which is removed in this PR). This means it will now fall through to the
tryExtensions
call on line 234, instead of thetryPackage
call on line 243.Note: Assumes a fixed #18299