Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed true dependencies #846

Open
OfekShilon opened this issue Oct 28, 2023 · 2 comments
Open

Missed true dependencies #846

OfekShilon opened this issue Oct 28, 2023 · 2 comments
Labels

Comments

@OfekShilon
Copy link

Bug Description

I'm trying to use depcheck on compiler-explorer. I get:

Unused dependencies
* buffer
* eslint-plugin-header
* events
* pug
* ts-node
Unused devDependencies
* @babel/preset-typescript
* @types/chai-as-promised
* @types/tar-fs
* @types/webpack-env
* cheerio
* css-loader
* eslint-formatter-github
* eslint-import-resolver-typescript
* file-loader
* lint-staged
* sass
* sass-loader
* sinon
* source-map-loader
* supervisor
* ts-loader

but many of these seem to be real dependencies. Specifically:

  1. The compiler-explorer TypeScript source contains:
import {Buffer} from 'buffer';
...
import EventEmitter from 'events';
...
import * as cheerio from 'cheerio';
  1. The js file parsed_pug_file.js contains:
const pug = require('pug');
  1. The file webpack.config.esm.ts contains 'sass-loader', 'source-map-loader', 'css-loader' and 'ts-loader'
  2. Makefile includes 'supervisor' (this might be outside your scope, I get it)
  3. pre-commit includes 'lint-staged' (ditto)
  4. .eslint-license-header.yml includes 'eslint-plugin-header'

etc. I stopped there.

Code snippets

For a complete repro with context:

$ clone --depth=1 https://github.com/compiler-explorer/compiler-explorer
$ cd compiler-explorer
$ npm install # or `make`
$ depcheck .

I'll be happy to help collect more info or debug, if that would be helpful.

Versions

  • node -v: v18.17.1
  • npm -v: 10.2.0
  • depcheck --version: 1.4.7
@OfekShilon OfekShilon added the bug label Oct 28, 2023
mattgodbolt pushed a commit to compiler-explorer/compiler-explorer that referenced this issue Oct 31, 2023
I played with `depcheck` on CE. it has [many false "unused
deps"](depcheck/depcheck#846), I grepped the
tree for usages and checked manually `make`, `make dev` and `make check`
- all seems well.
@OfekShilon
Copy link
Author

OfekShilon commented Nov 4, 2023

Regarding the first two, buffer and events: they fail to be count as used despite being part of an import directive because they're classified as core modules. They are, but here (and in many other projects) they're used in the front end - and so must be installed in package.json and are not unused.

Perhaps there's a way to refine the 'core module' criterion?

@znarf
Copy link
Collaborator

znarf commented Nov 21, 2023

The parsed-pug folder is ignored because it contains a package.json.

See: https://github.com/depcheck/depcheck/blob/main/src/check.js#L232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants