Skip to content

feat: add support for packageExtensions in yarn and pnpm#1847

Merged
webpro merged 9 commits into
webpro-nl:mainfrom
trueberryless:feat/pnpm-yarn-extensions
Jul 4, 2026
Merged

feat: add support for packageExtensions in yarn and pnpm#1847
webpro merged 9 commits into
webpro-nl:mainfrom
trueberryless:feat/pnpm-yarn-extensions

Conversation

@trueberryless

@trueberryless trueberryless commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds support for the packageExtensions setting for yarn and pnpm (only peerDependencies). While at it, I also refactored some of the existing code (extracting types, adding enablers to pnpm, stuff like that) and also consolidate the tests and fixtures a little bit.

@pkg-pr-new

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@1847
npm i https://pkg.pr.new/@knip/language-server@1847
npm i https://pkg.pr.new/@knip/mcp@1847

commit: ba46fbb

@trueberryless trueberryless changed the title feat: add support for packageExtensions in yarn and pnpm feat: add support for packageExtensions in yarn and pnpm Jul 1, 2026

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR! Much appreciated. A few comments I have.

Comment thread packages/knip/test/plugins/pnpm.test.ts Outdated
Comment thread packages/knip/src/plugins/pnpm/index.ts Outdated
Comment thread packages/knip/src/plugins/pnpm/types.ts Outdated
@@ -0,0 +1,16 @@
export type PnpmConfig = {
pnpm?: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see why we are doing this, but any chance we could extend and use PackageJson?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I refactored them in 269d602 (this PR), but I am not totally sure if you meant it that way. Let me know what you think 👍

@trueberryless

Copy link
Copy Markdown
Contributor Author

The change of moving the .pnpmfile.cjs from config to entry (see linked suggestion) resulted in the test reporting files: 1. I adapted it in bdaebcd (this PR), but tbh I am not that sure if this is correct. Shouldn't the file be included in Knip's graph if it's in entry? I think I am missing something - maybe a missing mapping again? 🤔

@webpro

webpro commented Jul 4, 2026

Copy link
Copy Markdown
Member

Sorry forgot about that. If resolveConfig is implemented, we should also add basically entry.map(toEntry) to the returned inputs. The idea is that plugins would otherwise not override the defaults but only add which would be "globby overhead" (and in some edge cases could even lead to incorrect results).

@trueberryless

Copy link
Copy Markdown
Contributor Author

Sorry forgot about that. If resolveConfig is implemented, we should also add basically entry.map(toEntry) to the returned inputs. The idea is that plugins would otherwise not override the defaults but only add which would be "globby overhead" (and in some edge cases could even lead to incorrect results).

Thank you very much. That makes a lot of sense!

@webpro
webpro merged commit 61d3164 into webpro-nl:main Jul 4, 2026
30 checks passed
@webpro

webpro commented Jul 4, 2026

Copy link
Copy Markdown
Member

Thank you! Nice work.

@trueberryless
trueberryless deleted the feat/pnpm-yarn-extensions branch July 4, 2026 15:08
@webpro

webpro commented Jul 7, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.25.0. See Release 6.25.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💡 Feature request: support Yarn's packageExtensions

2 participants