-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: use undefined if no main #18593
Conversation
If the package.json file does not have a "main" entry, return undefined rather than an empty string. This is to make more consistent behavior. For example, when package.json is a directory, "main" is undefined rather than an empty string.
Would this naturally shake out of @guybedford's package.json reading work for the |
As long as they are the same that seems fine. I will still open up a PR to cache all the results unconditionally sometime in the future though. |
I'm going to mark this as blocked because it should only land if #18270 lands first. |
Landing #18270 as soon as I get green/yellow CI. Unblocking this. This could definitely use some more reviews. Ping @nodejs/collaborators |
seems like much saner behavior, lgtm |
Ci is yellow. 🎉 |
This is |
Also needs a CITGM run: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1266/ |
Just for context this change is sitting on top of other |
I only did a cursory look at first and saw this change affects the results of tests that are already in v9.x-staging. So it |
@nodejs/modules |
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.
👍
Still needs one more @nodejs/tsc approval. |
I don't have any strong feelings about this but would like to hear @bnoordhuis's opinion, if he has one. |
Can someone familiar with CITGM review the CITGM results or point me to documentation that will explain how to review result? https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1266/ I looked over them but I'm not sure how to tell what's expected failures and what's not. @nodejs/citgm |
@Trott that looks ok to me. I'm currently working on fixing some of those packages. |
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
If the package.json file does not have a "main" entry, return undefined rather than an empty string. This is to make more consistent behavior. For example, when package.json is a directory, "main" is undefined rather than an empty string. PR-URL: nodejs#18593 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Landed in bd4773a. |
Belated: this PR should have removed the More importantly, it undoes the optimization that a package.json without a 'main' property isn't loaded from disk repeatedly. That said, the logic in readPackage() looks kind of broken anyway. It's quite possibly no worse than before. |
Thanks. That can be fixed in a subsequent PR. I'll submit it shortly if no one else has done so already.
If I understand correctly (which is a pretty big caveat), that would be fixed by caching negative results, which @bmeck intends to introduce. Not sure if that is likely to get much push-back or not. |
@Trott pretty much, but I've been talking to @guybedford about some stuff we can do to make the cache a bit better and moved to C++ so that it can be used prior to crossing the C++/JS bridge and same as #18728 . Might be a little bit pending that. |
Remove unnecessary condition in lib/module.js. Refs: nodejs#18593 (comment)
Remove unnecessary condition in lib/module.js. Refs: nodejs#18593 (comment) PR-URL: nodejs#18768 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
If the package.json file does not have a "main" entry, return undefined rather than an empty string. This is to make more consistent behavior. For example, when package.json is a directory, "main" is undefined rather than an empty string. PR-URL: nodejs#18593 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Remove unnecessary condition in lib/module.js. Refs: nodejs#18593 (comment) PR-URL: nodejs#18768 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
If the package.json file does not have a "main" entry, return undefined
rather than an empty string. This is to make more consistent behavior.
For example, when package.json is a directory, "main" is undefined
rather than an empty string.
@bmeck @bnoordhuis Is this an acceptable resolution of the "package.json as a directory leaves
main
undefined if we land #18270, but package.json as a file without amain
setsmain
to an empty string" disagreement? Opening a PR because I figure it would be easier to determine "yes" or "no" with an actual proposal to look at. I believe @bmeck would prefer the empty string for both scenarios, but I also believe thatundefined
is acceptable to them too as long as it applies to both scenarios. But I could be wrong...Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
module