-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
module: revert checking for package.json before extensions #15015
Conversation
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.
would love this + a backport
I'm not sure we need to use the word "revert" if the current behavior was added a very long time ago. |
@mscdex it has accidental side effects, I would prefer to keep that word. |
If it was unintentional and undocumented, it's a bug - I think the term isn't bound by recency. |
/cc @nodejs/tsc I am in favor of this change |
I am also in favor of this. It seems like a more correct approach than the way it is currently working. As there was no progress for a long time, I would like to have the @nodejs/tsc to have a look at this and to decide on how to move forward. There are already two TSC votes in favor. |
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.
This needs a rebase. LGTM otherwise
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 comment
The 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 inner.js
export content to contain a property with a string, remove the message and use deepStrictEqual
. With the latter the error message should be explicit enough.
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.
@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.
@bmeck I guess you actually want this to be looked at and it to get merged, right? In that case it will need a rebase and the title should be changed accordingly. |
@BridgeAR I don't see any -1. With the approvals, I think we can go ahead and merge it (after a rebase). Can we take this off the TSC agenda? Or am I missing something? |
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.
LGTM with a better PR description and commit description
@fhinkel sure, I just removed the labels. I just wanted to make sure it is properly looked at as it was originally controversial if that should be changed or not. |
Ping @bmeck |
I can make a better description tomorrow and I think we are approved beyond that. |
Should be plenty of time for that assuming it lands by end of March... :-) |
Anyone know about the treatment of the trailing Update: Okay confirmed. Windows supports paths ending in |
The surrounding code is only looking at |
It looks like it goes
The Update: Filed the bug: #18299. |
} else if (rc === 1) { // Directory. | ||
if (exts === undefined) | ||
exts = Object.keys(Module._extensions); | ||
filename = tryPackage(basePath, exts, isMain); | ||
} |
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 the tryPackage
call on line 243.
Note: Assumes a fixed #18299
@bmeck it seems like there is a lint error and a tests constantly fails:
Would you be so kind and take a look? :-) |
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 <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
28d83f0
to
39f51aa
Compare
I just rebased this, fixed the linter error and fixed the test issue. I am a bit confused that the old test is now working as before. @bmeck can you please have a look at this? |
@BridgeAR I'm dealing w/ family, won't get to this in next few days. |
Ping @bmeck. I hope everything is fine on your side :-) |
@BridgeAR I'm still pretty under water with workload due to things, nothing seems really apparent on why it would fail. I could try to revert and then git bisect if desired but won't get to it for a while. |
And I rebased and pushed the changes here. So this is good to go if you give your LG. |
@BridgeAR that test change looks correct, this PR should be adding trailing |
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: nodejs#15015 Fixes: nodejs#14990 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Khaidi Chu <[email protected]>
Landed in 1ed36ae 🎉 |
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: nodejs#15015 Fixes: nodejs#14990 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Khaidi Chu <[email protected]>
This PR reverts a regression from a change in behavior that deviated from the documented behavior of the module resolution algorithm. The deviation caused the module resolution algorithm to check for
package.json
files when traversing up to a parent directory before following the documented module resolution algorithm.Link discussing the regression in greater depth
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
module