-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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(npm): add support for npm packages in lock files #15938
Conversation
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 think we'll need to add version requirement to version resolution to the lockfile before landing this.
Discussed offline with @dsherret. This PR needs more work as we need to store way more information in the lock file. After some discussion we are in agreement that we need a new format for the config file, which is a much bigger endeavor and will probably be done in v1.27. |
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 think we should take the time to change the API to prepare this for use in the language server.
cli/lockfile.rs
Outdated
.unwrap_or(&package.dist.shasum); | ||
if &package_info.integrity != integrity { | ||
return Err(anyhow!( | ||
"Integrity check failed for npm package: {}. Pass --lock-write to update the lockfile.", |
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.
Do other tools recommend to update the lockfile if the integrity check fails?
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.
Example from yarn:
Incorrect integrity when fetching from the cache for "vite". Cache has "sha512-m7jJe3nufUbuOfotkntGFupinL/fmuTNuQmiVE7cH2IZMuf4UbfbGYMUT3jVWgGYuRVLY9j8NnrRqgw5rr5QTg== sha1-+ikUQWfRm3c7r/1ls5cupMEjWck=" and remote has "sha512-asdfasdf". Run `yarn cache clean` to fix the problem
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!
cli/lockfile.rs
Outdated
Resolved to \"{}@{}\" and lockfile expects \"{}\". | ||
Use \"--lock-write\" flag to update the lockfile.", | ||
package_req.name, package_req.name, version, resolved_specifier | ||
))); |
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'm not sure this would ever occur because the resolution should be informed by the lockfile and it seems there's no test for this. Maybe we should remove this function?
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.
Okay, I'm going to remove it then.
Closes #15696