8000 fix(core): fixed package version matching when generating pnpm lockfile by nikrabaev · Pull Request #30373 · nrwl/nx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(core): fixed package version matching when generating pnpm lockfile #30373

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nikrabaev
Copy link

Current Behavior

When building an app using pnpm, webpack and NxAppWebpackPlugin with generatePackageJson: true, the error is thrown. This happens during pruned lockfile generation:

Cannot destructure property 'data' of 'undefined' as it is undefined.

Expected Behavior

No error should be thrown.

Related Issue(s)

Fixes #28627

@nikrabaev nikrabaev requested review from meeroslav and a team as code owners March 14, 2025 10:57
@nikrabaev nikrabaev requested a review from FrozenPandaz March 14, 2025 10:58
Copy link
vercel bot commented Mar 14, 2025

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

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview May 19, 2025 2:59pm

@jagzmz
Copy link
jagzmz commented Mar 29, 2025

Bump

@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label May 14, 2025
Comment on lines +607 to +609
const exactMatchedNode = nodes[`${nodeKeyPrefix}}@${packageJsonVersion}`]
|| nodes[`${nodeKeyPrefix}}@${packageJsonVersion.replace(/^~/, '')}`]
|| nodes[nodeKeyPrefix];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are syntax errors in the template literals - extra closing curly braces appear in both lines. Please correct:

// From:
nodes[`${nodeKeyPrefix}}@${packageJsonVersion}`]
nodes[`${nodeKeyPrefix}}@${packageJsonVersion.replace(/^~/, '')}`]

// To:
nodes[`${nodeKeyPrefix}@${packageJsonVersion}`]
nodes[`${nodeKeyPrefix}@${packageJsonVersion.replace(/^~/, '')}`]

These extra braces would cause incorrect key lookups in the nodes object.

Suggested change
const exactMatchedNode = nodes[`${nodeKeyPrefix}}@${packageJsonVersion}`]
|| nodes[`${nodeKeyPrefix}}@${packageJsonVersion.replace(/^~/, '')}`]
|| nodes[nodeKeyPrefix];
const exactMatchedNode = nodes[`${nodeKeyPrefix}@${packageJsonVersion}`]
|| nodes[`${nodeKeyPrefix}@${packageJsonVersion.replace(/^~/, '')}`]
|| nodes[nodeKeyPrefix];

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

return nodes[nodeKey];
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is missing a return value for the case when no compatible node is found. This could result in undefined being returned, potentially causing errors elsewhere. Consider adding a default return value or explicit error handling at the end of the function.

Suggested change
}
return null; // No compatible node found
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Medium Priority (not high, not low priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pruned lockfile generation with ^version's
4 participants
0