Skip to content
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(core): normalizing key of patched packages with its actual resolved version and not the one from the key #18192

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

veimox
Copy link
Contributor

@veimox veimox commented Jul 19, 2023

Current Behavior

As described in #17873

My understanding of the sitatuion is that it is an edge case. The issue can be replicated in the repo from @ganlhi where the following happens:

  1. In the package.json there is the definition "typescript": "~5.1.3" but in the lock file it is resolved with 5.1.6
  2. When generating the keys for the yarn.lock it uses, not the version from the string defined by the user (5.1.3), but the actual version resolved by yarn (5.1.6)
  3. Then we go an prepare the objects to be pruned. For the specific case of the packages that have patch in berry we use its nomalised key to prune the lock file . This normalised key uses the version from the string, and not the resolved from yarn, which then in this bit is trigerred as a deletion because it does not match the version.
  4. This effectively deletes the key giving the issue described in Lockfile generated by @nx/next:build is invalid #17873 with an empty "" key for the value of the typescript package. It can seen better in the screenshot
image

This PR solves the issue but calculating the normalizedKey by using the resolved version of yarn and fixes the issue.

That said, perhaps there is a better way of fixing this because I do not have in-depth knowledge on the matter. Hopefully will give some info to the dev that can fix it 😄

Expected Behavior

It generates a valid yarn.lock

Related Issue(s)

#17873
(Maybe) #17853 done by @meeroslav

Fixes #17873

@veimox veimox requested review from a team and meeroslav as code owners July 19, 2023 16:15
@veimox veimox requested a review from AgentEnder July 19, 2023 16:15
@vercel
Copy link

vercel bot commented Jul 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2023 1:18pm

@veimox
Copy link
Contributor Author

veimox commented Aug 9, 2023

@meeroslav @AgentEnder any feedback on this PR or the blocking issue?

@meeroslav meeroslav self-assigned this Aug 9, 2023
@meeroslav
Copy link
Contributor

Sorry for waiting. I will look into it as soon as possible.

@meeroslav
Copy link
Contributor

Thank you for this PR!

@meeroslav meeroslav merged commit 5ac66e4 into nrwl:master Aug 14, 2023
15 checks passed
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lockfile generated by @nx/next:build is invalid
2 participants