-
-
Notifications
You must be signed in to change notification settings - Fork 937
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
fix(resolve-dependencies): prefer versions found in parent packages only #6742
Conversation
if (newPreferredVersions[resolvedPackage.name] === preferredVersions[resolvedPackage.name]) { | ||
newPreferredVersions[resolvedPackage.name] = { ...preferredVersions[resolvedPackage.name] } | ||
} |
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.
alternative version:
if (!Object.prototype.hasOwnProperty.call(newPreferredVersions, resolvedPackage.name)) {
newPreferredVersions[resolvedPackage.name] = Object.create(preferredVersions[resolvedPackage.name])
}
let me check if there is a difference in performance for this
@@ -537,6 +537,9 @@ export async function resolveDependencies ( | |||
newPreferredVersions[resolvedPackage.name] = {} | |||
} |
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.
instead of the change below, this can be replaced with
if (!Object.prototype.hasOwnProperty.call(newPreferredVersions, resolvedPackage.name)) {
newPreferredVersions[resolvedPackage.name] = preferredVersions[resolvedPackage.name]
? Object.create(preferredVersions[resolvedPackage.name])
: {}
}
which is noticeably faster - 2m 50s vs 3m 16.8s for me
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.
But in npm-resolver we are then running Object.entries
and Object.keys
on newPreferredVersions[resolvedPackage.name]
, which will not list the properties if they were added with Object.create
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.
indeed that can be a problem, let's stick to safer option creating a copy
close #6737