-
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
Regression: Resolution algorithm collision #14990
Comments
ping @nodejs/ctc |
Is it just a test, or were there changes to the algorithm itself? If it's just a test, could we rework it to be correct? If there were changes to the algorithm, then we might want to update the docs instead. |
The test is invalid since it doesn't match the docs. We need to revert to the original algorithm to fix. I don't want to update docs because the behavior is very odd to me. |
As far as I see it the test (and code change) exists since iojs 1.0 and was introduced here 36777d2 |
Any way we look at it, we should fix the |
I'm +1 for reverting but we need to take a close look at the semver-i-iness of the change. |
The description in the documentation has been at odds with the implementation since at least v0.12, possibly v0.10. See #4595 (comment) for an example. |
@bnoordhuis ... given that, which do you prefer: modifying the docs to match the impl or modifying the impl to match the docs? |
The path of least resistance is to update the documentation; any change to the algorithm will almost certainly result in some fallout. |
How do we cleanly explain that it searches for directory package.json
before file extensions but directory index files after file extensions.
Mind you the change in the past was also breaking.
…On Aug 23, 2017 2:23 PM, "Ben Noordhuis" ***@***.***> wrote:
The path of least resistance is to update the documentation; any change to
the algorithm will almost certainly result in some fallout.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#14990 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAOUo663MpquVS8NKEyOS12g0P4Tq8p9ks5sbHwbgaJpZM4PAP2W>
.
|
It should be noted that userland implementations of resolution logic like resolve at 800k downloads per day don't exhibit this behavior. |
@bmeck if that's not too much effort, would you assemble a PR anyway? It is hard to understand the impact of this behaviour without a SHA reference and a full example. I think seeing the actual change you are planning to make would help. |
From a user perspective (and |
Made a PR people an look at. |
@bmeck do you have a trail on why this change was introduced? |
@mcollina Unclear on a few quick searches, but the test makes it seem to be because someone had the following:
And |
I do not think we can change that behavior now. |
@mcollina no userland impl uses this odd behavior. |
@bmeck definitely. However I fear there is plenty of code that is using that behavior, even in npm and also closed source. This makes it semver-major squared for me, and maybe the ship of changing this has sailed. Who did the original edits? I would ask to @isaacs what he thinks of this potential change. |
@mcollina to preserve the nature of the test, we could make |
if it matters console.log(new URL('../..', 'file://a/b/c/d').href); // file://a/ |
@bmeck is this a suggestion to change the behavior or just amend the test? Bear with me, you are way more familiar with the internal of the module system than myself, and I care that the current behavior is not changed, as I fear breakages. |
@mcollina in all scenarios, the behavior needs to change due to inconsistencies. See the test in the PR pointing to this issue for an example. The suggestion above about setting In particular given the dir structure:
If The behavior of approximately adding a trailing |
#14990 (comment) I am in favor of what you propose there. Is that related in #15015? Over there it mentions |
I think we should revert to the old (and documented) behavior. If there is concern about the ecosystem effects, we could allow it to be an opt-out with a flag? |
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>
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 <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>
At some time just before v4 a seemingly invalid test was introduced. It invalidates the resolve algorithm as documented by checking for
./foo/package.json
before./foo.js
when usingrequire('./foo')
always.The intent was for
require("..")
to prefer a directory instead of doing regular resolution. However, that does not match the documented algorithm which would require a/
to invalidate file searching.I don't have a clear way to explain the current behavior and would like to revert this behavior. We could state that matching
/${path_separator}.?./$
at the end of a require specifier would automatically add/
but that seems a bit odd.I want to revert this change.
The text was updated successfully, but these errors were encountered: