Skip to content

jakeleventhal/knip-1763-repro

Repository files navigation

Knip PR 1763 Reproduction

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.

Reproduce

npm install
npm run knip:without-pr

Expected 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-pr

Expected 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:workaround

That command disables the GraphQL Codegen plugin for packages/example/integrations and ignores the three plugin packages.

// TODO: Remove this entire block once https://github.com/webpro-nl/knip/pull/1763 is resolved
"packages/example/integrations": {
  "graphql-codegen": false,
  "ignoreDependencies": [
    "@graphql-codegen/typescript",
    "@graphql-codegen/typescript-graphql-request",
    "@graphql-codegen/typescript-operations"
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors