webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
6.93k stars 168 forks source link

🐛 Dev dependencies are reported as unused #772

Closed blake-newman closed 1 week ago

blake-newman commented 2 months ago

Prerequisites

Reproduction url

-

Reproduction access

Description of the issue

Currently dev dependencies are reported as unused if they are not included in any entry files.

However, commonly dev dependencies are used in none poduction code. I can't seem to find a way to tell knip that if it's used in a development file then it's okay.

Example configuration:

entry: ['src/index.{ts,tsx}!'],
project: [
  '**/*.{ts,tsx,vue}!',
  '!**/*.{bench,test,test-d}.{ts,tsx}!',
]

If a dev dependency is used in a test file it will still report as unused, the only way to resolve would be to include the test files as entry points. However; this is really slow (our monorepo won't run knip with that setting as it just hangs).

webpro commented 2 months ago

A reproduction is required, not sure exactly what you're doing and what you're expecting.

Did you add the --production or --strict flag? In strict production mode it won't report dev dependencies.

our monorepo won't run knip with that setting as it just hangs

You could try --isolate-workspaces.

webpro commented 1 week ago

Closing due to inactivity.