Open
Conversation
Author
|
For test consistency, I've added the Yarn PnP cache files. This is equivalent to committing the |
parksb
commented
Nov 22, 2025
|
|
||
| if (pnpApi != null) { | ||
| const packageJsonPath = join(packageName, 'package.json'); | ||
| const resolvedPath = pnpApi.resolveToUnqualified(packageJsonPath, dir); |
Author
There was a problem hiding this comment.
I used resolveToUnqualified to bypass exports map restrictions. This is necessary for reading metadata (bin, peerDependencies, types, ...) even when:
- Workspace packages don't have
./package.jsonentry in exports map - Packages have no JavaScript entry point (e.g.,
@types/*packages)
Actual resolution (oxc-resolver) still respects exports map, so invalid imports will be correctly detected.
f4844ad to
0faa3b8
Compare
23f8020 to
b6afc01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR continues the work from #924. Thanks @jwoo0122 :)
When a project uses Yarn PnP, this PR makes knip look for manifest files in the PnP file instead of searching in the
node_modulesdirectory. Previously, knip incorrectly reported peer dependencies required by packages as unused dependencies in Yarn PnP projects.Below is an example where knip reports react and react-dom as unused dependencies in a project using styled-components. (styled-components requires react and react-dom as peer dependencies.)
With Yarn PnP support in this PR, knip correctly reports no unused dependencies as shown below.