You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
π Unused subpaths: test-only #imports reported in --production modeΒ #2342
Thanks for adding the unused subpath imports check in 6.45.0 (#2317), it's a useful one.
In --production mode, a package.json#imports key that is only referenced from test files gets reported as an unused subpath. The default (non-production) run correctly sees the references and reports nothing.
src/math.test.ts imports from #lib/math.ts and #test/fixtures.ts
$ knip
βοΈ Excellent, Knip found no issues.
$ knip --production
Unused subpaths (1)
#test/* package.json:6:6
Expected
No issue in --production mode. An imports entry is module-resolution config, not shipped code, so I'd expect it to be treated like a devDependency: if only non-production files reference it, production mode shouldn't call it unused. There's also no change that satisfies the check: removing #test/* breaks the tests.
Workarounds
knip --production --exclude subpaths, or ignoreIssues: { "package.json": ["subpaths"] }. Both turn the check off for every key, not just the test-only one.
Two things that would help, either on its own would be enough:
In --production, skip imports keys that are referenced only from non-production files.
A way to ignore individual subpath keys (similar to ignoreDependencies).
Activity
github-actions commentedon Nov 11, 2026
Preview release available:
webpro commentedon Nov 11, 2026
Thanks for the report! Fix (skip subpath imports in production mode) should go out soon.
webpro commentedon Nov 11, 2026
π This issue has been resolved in v6.45.1. See Release 6.45.1 for release notes.
Using Knip in a commercial project? Please consider becoming a sponsor.
Don't report unused subpaths in production mode (resolve webpro-nl#2342)