-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
module,cli: fix module loading for paths ending with /.
or /..
#52532
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
Conversation
Review requested:
|
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.
Please always include tests in a PR. The test should fail on current main and pass in your branch.
This change seems like it would be a semver major breaking change. It's not clear to me that the current behavior is buggy; is there documentation that describes the intended behavior, where a test can confirm that Node behaves not in accordance with that?
Hi! I'm about to push tests that will fail in the current version of node, but not in my patch.
Consider the directory setup below (assuming your current working directory is
In the latest version of NodeJS, executing |
/.
or /..
I believe this is the correct behaviour. |
IMO it's not, as one would assume: |
The relevant documentation is at https://nodejs.org/api/cli.html#program-entry-point:
So reading this literally, an entry point string of You might argue that this is nonsensical, that no one would want this behavior, and I would agree with that. In which case it’s not a bugfix but just a change, and the documentation needs to be updated along with the behavior. I would argue, though, that if we’re going to make a semver-major change to how the resolution of the entry point happens, we might want to go a bit bigger and eliminate the CommonJS resolution from this entirely: if you want to run |
True, with all of the changes that could be made around this functionality, you'd probably right that a discussion with @nodejs/loaders (or the relevant team). |
Related to #24256
Fixes #32008
Fixes #24210
This PR appends a trailing slash to certain paths to ensure they resolve correctly. Before this page, the module loader would prefer
(cwd).js
instead of(cwd)/index.js
when runningnode .
.