-
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
[rfc] module: change load order #4595
Comments
The current behavior appears to be at odds with the pseudo-code algorithm from the documentation, that clearly says that foo.js should always be loaded: first It seems to be a regression in v0.12. v0.10 always prints '0', v0.12 and newer print either '1' or '0', depending on the value of the I guess I'll cook up a PR that restores the v0.10 behavior. I'm not wildly thrilled by the inefficiency of the algorithm but at least it's consistent. |
If something as fundamental as module load order is going to be changed after many official releases, then I think it would be a good opportunity to address "#3402: Don't resolve symlinks when requiring" at the same time. |
If the regression has existed since 0.12 and there haven't been complaints then that means that the no., of people using the |
This is probably fine, since the inconsistency being described assumes that people are modifying |
Should definitely be consistent. I like the idea of optimizing it... I can't think of anybody using the setup described, where a package and a module exist side-by-side. The fact that we've already "betaed" the new behaviour by accident since 0.12 makes me think it should be proposed for the next major. |
@bnoordhuis ... still something you wanna do? |
Yes, it is, but the question is: do we restore the v0.10 behavior or go with the efficient approach? I think the consensus is that it should be the latter but it wouldn't hurt for @nodejs/ctc to chime in. |
Efficiency! Is what is being proposed here a separate change from say #5689? |
They're not quite the same. Issue #5689 is about |
+1 to making the change. Should we be using GitHub reactions for this? |
-1 to GitHub reactions |
I think I'm +1 on this change also. |
+1 for the more efficient approach, but also +1 to addressing other important module loading problems at the same time, if possible: #3402 |
I'm |
Oh yes please can we get #3402 fixed as part of this |
@bnoordhuis ... any reason to keep this open? |
I still have this in my backlog but if we decide not to make the change, the documentation would need to be updated. |
I don't think I'm going to get around to this so I'll go close it out. |
Consider the following:
In other words,
node_modules/foo.js
takes precedence overnode_modules/foo/index.js
. I have trouble understanding when this would ever be the desired behavior inside anode_modules/
directory.Even more awkward, adding a package.json with a
main
property suddenly turns the precedence around:I propose to harmonize this behavior and make
node_modules/foo/index.js
always take precedence overnode_modules/foo.js
.If nothing else, the current behavior is woefully inefficient because of all the superfluous stat(2) calls:
On my system, with a cold disk cache (
echo 3 > /proc/sys/vm/drop_caches
), this moderately large benchmark application:Ergo, we could shave off 20% of the absolute start-up time and 45% of the total system time.
/cc @sam-github
The text was updated successfully, but these errors were encountered: