Load plugin configs from workspace cwd#1763
Conversation
|
Not sure if you have a better approach here |
commit: |
|
AST resolver is fine (better), but ideally it's either/or (not both Btw documentation for users at https://knip.dev/reference/known-issues#exceptions-from-config-files |
2d007b3 to
eb02261
Compare
|
Thanks. I reworked this to avoid combining Looking at the repro again, the issue is not that the config throws and Knip should recover with AST. It’s that Knip evaluates the The updated PR keeps the existing |
|
While I understand it should just work and it's on Knip, yet still: why not follow good practice and use |
6f3bfc8 to
079846f
Compare
|
@webpro check again |
|
Thanks! Much better, performance is no longer an argument against this. However, I'm still on the fence with this one, because with this type of change there's basically no going back once merged and it blocks potential future parallel work. |
|
@webpro what's the path forward here? |
|
Let's close it and not shoot ourselves in the foot. I'll close it by updating docs soon. |
|
@webpro then how can I solve cases like this: https://github.com/jakeleventhal/knip-1763-repro |
|
That link 404s. Probably I would answer:
|
|
err, sorry can you check again please @webpro |
|
🚀 This issue has been resolved in v6.16.0. See Release 6.16.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
Summary
load()caller.--config ./src/codegen.tsfile reads package-relative config and only resolves when evaluated from the package cwd.Root Cause
graphql-codegen --config ./src/codegen.tsis discovered from the package script, so the config should be evaluated the same way that package script runs: from the workspace/package cwd. When Knip loads the config from the repo-root cwd, relative paths inside the config resolve incorrectly and plugin dependencies referenced by the loaded config can be reported as unused.Validation
node --test packages/knip/test/plugins/graphql-codegen.test.tspnpm exec oxfmt --check packages/knip/src/util/loader.ts packages/knip/src/util/plugin.ts packages/knip/test/plugins/graphql-codegen.test.ts packages/knip/fixtures/plugins/graphql-codegen-script-config-cwd-context/**/*.ts packages/knip/fixtures/plugins/graphql-codegen-script-config-cwd-context/**/*.jsonpnpm run --dir packages/knip lintpnpm run --dir packages/knip buildnode /Users/jakeleventhal/Documents/Codex/2026-05-22/update-my-pr-based-on-this/knip/packages/knip/src/cli.ts --directory /Users/jakeleventhal/Developer/rip-technologies --no-progress --workspace @artelo/integrations