This is a minimal reproduction for webpro-nl/knip#1763.
It compares stock Knip 6.15.0 against the PR build from pkg.pr.new.
The package script in packages/example/integrations/package.json mirrors the relevant workspace shape:
"generate": "graphql-codegen --config ./src/codegen.ts"The GraphQL Codegen config intentionally reads a package-relative file:
readFileSync("./config/codegen-plugins.json", "utf8");That path is valid when ./src/codegen.ts is evaluated from packages/example/integrations, which is how the package script runs. It is invalid when stock Knip evaluates the config from the repository root.
npm install
npm run knip:without-prExpected behavior without the PR, using Knip 6.15.0: Knip reports the GraphQL Codegen plugins as unused dependencies, because it does not load the package script config from the workspace cwd.
ERROR: Error loading packages/example/integrations/src/codegen.ts (ENOENT: no such file or directory, open './config/codegen-plugins.json')
ERROR: Please fix or visit https://knip.dev/reference/known-issues
Unused devDependencies (3)
@graphql-codegen/typescript packages/example/integrations/package.json
@graphql-codegen/typescript-graphql-request packages/example/integrations/package.json
@graphql-codegen/typescript-operations packages/example/integrations/package.json
Run the PR build:
npm run knip:with-prExpected behavior with the PR: the GraphQL Codegen plugin dependencies are not reported.
The workaround block is preserved in knip.with-workaround.jsonc:
npm run knip:workaroundThat command disables the GraphQL Codegen plugin for packages/example/integrations and ignores the three plugin packages.