-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: refactor node.ideallyInert to node.inert #8602
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
a69f632
to
5699f19
Compare
5699f19
to
73820c6
Compare
The test failures are in two cases of reifying with It shows a difference in how omitted and failed deps are represented in the "actual" tree that is saved to the hidden lockfile and returned from
I don't think this difference should exist. The next question is, do they belong in the actual tree or not? I don't think they need to be. #8184 could also have been solved by checking for missing optional deps alongside invalid when building the ideal tree from lockfile. That check might still be needed regardless. Omitting from actualTree and lockfile would however require recalc of omitted and failed deps on every ideal tree build. If the intention of the hidden lockfile is to avoid this, then better to save both. |
This solution was already suggested here: #8127 (comment)
Rebuilding ideal tree should only happen when there is no package lock, so relatively infrequently. As to the intention of the hidden lockfile, it looks like it was always intended to represent the actual tree, not ideal. Adding failed optional deps came with #8184. I think there is value in preserving omitted and failed deps in the actual tree, marked as |
ada5af9
to
5424f3e
Compare
|
"dev": true, | ||
"license": "ISC" | ||
}, | ||
"node_modules/fsevents": { |
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.
We normally do not allow changes to the package-lock.json
file. It makes sense that this change is here now given that this is an optional dep of chokidar
.
In order that we don't complicate things I removed the package-lock.json
from my local copy of this branch and ran npm run resetdeps
to verify that what's in here now is valid. The package lock was identical, so we're good to allow it in this PR as changed.
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.
I only updated this after CI failed complaining about mismatched package lock. This is the result of fixing missing optional deps here: https://github.com/npm/cli/pull/8602/files#diff-02626074e1a4a170693607e4a3a69dfc08ee52067734717833b22cf162923e07R354
Landing this is going to be a real good test of our recent fixes to not prune optional deps from the package-lock, when CI runs on windows and linux. |
const loc = relpath(this.idealTree.realpath, path) | ||
const node = this.idealTree.inventory.get(loc) | ||
if (node && node.root === this.idealTree && !node.ideallyInert) { | ||
if (node && node.root === this.idealTree) { |
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.
if (node && node.root === this.idealTree) { | |
if (node?.root === this.idealTree) { |
After a quick review the code changes seem to make sense. The deletion of tests of course always makes me nervous so I'll probably want to think on those a little more to be sure they weren't somehow load bearing. |
I added comments explaining the deletions. Hope it makes sense. |
This helps so much! |
Discovered while investigating #8535 (comment)
Similar to #8566, relates to #8184
Moves
inert
(uninstallable optional) calculation intobuildIdealTree
so it can be used in diff.Also removes most of #8184 in favor of a simpler fix, see PR comments for the journey.
Improvements:
createSparseTree
no longer creates dirs that will only be cleaned laterFor the example in the linked issue, it changes output from
added 156 packages
toadded 12 packages
and combined with #8537 it changes toadded 6 packages
, the expected result.