Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(npm): Speed-up getting the remote package details #10059
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
feat(npm): Speed-up getting the remote package details #10059
Changes from all commits
30bfebe
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 136 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L136
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.
Why this special value ? Is it from empirical testing ?
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.
It aligns with other similar code that was introduced by @mnonnenmacher in 23c9bb0. But I agree that we should afterwards probably extract a constant.
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.
In 23c9bb0
20
was chosen randomly, simply because I had not time to test which number provides the best performance in each of the places. I think adding a constant would give the false impression that there is any reason to use the same number in all of the places.Check warning on line 195 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L193-L195
Check warning on line 198 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L197-L198
Check warning on line 200 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L200
Check warning on line 210 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L209-L210
Check warning on line 213 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L213
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.
Out of curiosity: Aren't
isProject
andisInstalled
mutually exclusive? I.e. can a project ever get installed?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.
isInstalled
refers to whether there is apackageJson
file existing underPath
.The
!isProject
can be interpreted asisPackage
and combining this withisInstalled
to me makes a lot of sense.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.
For the record, here's what I did to confirm that statement for my own confidence. Drilling down,
isInstalled
is implemented asand
path
is documented as(emphasis mine, as that's the part that confused me). Also,
ModuleInfo
is populated from output ofnpm list
, which is documented as "This command will print to stdout all the versions of packages that are installed". So to me that sounded like we'll only get data inModuleInfo
(and thepath
property) for things that have been installed before vianpm install
.But the root project itself seems to be an exception to that. Running
npm list --json --long
e.g. inplugins/package-managers/node/src/funTest/assets/projects/synthetic/pnpm/nested-project
creates JSON output that does contain apath
for the root project'spackage.json
. However, it does not contain apath
forsub/package.json
.Check warning on line 217 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L217
Check warning on line 220 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L220
Check warning on line 223 in plugins/package-managers/node/src/main/kotlin/npm/Npm.kt
plugins/package-managers/node/src/main/kotlin/npm/Npm.kt#L223