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

Installed peer dependencies are marked as unused #181

Closed
remcohaszing opened this issue Nov 22, 2016 · 9 comments
Closed

Installed peer dependencies are marked as unused #181

remcohaszing opened this issue Nov 22, 2016 · 9 comments
Labels
Milestone

Comments

@remcohaszing
Copy link

For example, babel-core is a peer dependency of babel-loader. It should not be marked as unused. The same goes for jasmine-core and karma-jasmine.

There are probably many more similar cases.

@lijunle
Copy link
Member

lijunle commented Nov 22, 2016

Hi, @remcohaszing

Thanks for reporting issues for depcheck. Which version of node and npm are you using?

@remcohaszing
Copy link
Author

$ node --version
v7.1.0
$ npm --version
4.0.2

@Matt-Webb
Copy link

Matt-Webb commented Nov 24, 2016

I am also seeing the same issue.

$ node --version
v4.4.4
$ npm --v
v 2.15.1

Note: I am using Webpack (v1.13.2) as my module bundler.

@lijunle
Copy link
Member

lijunle commented Nov 26, 2016

@remcohaszing It is strange, the peer dependencies should be supported. Which version of depcheck are you running?

@Matt-Webb If it is related to webpack, what is your file name of webpack config? Currently, it is hard code as webpack.config.js (related to #143).

@remcohaszing
Copy link
Author

I'm using depcheck@0.6.5.

Note that babel-core is marked as unused, not babel-loader.

webpack.config.js:

const path = require('path');

const HtmlWebpackPlugin = require('html-webpack-plugin');

const pkg = require('./package.json');


module.exports = {
  entry: path.resolve(__dirname, './app/main.jsx'),
  output: {
    path: path.resolve(__dirname, 'build/'),
    filename: 'gallery.js'
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    contentBase: path.resolve(__dirname, 'app')
  },
  devtool: 'inline-source-map',
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel',
        exclude: /node_modules/
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.css$/,
        loaders: ['style', 'css']
      },
      {
        test: /\.(eot|gif|jpe?g|png|svg|ttf|woff2?)(\?.*)?$/,
        loaders: ['file']
      }
    ]
  },
  externals: {
    // Workaround for https://github.com/airbnb/enzyme/issues/47
    'react/addons': true,
    'react/lib/ExecutionEnvironment': true,
    'react/lib/ReactContext': true
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: pkg.name
    })
  ]
};

@lijunle lijunle added the bug label Nov 29, 2016
@lijunle
Copy link
Member

lijunle commented Nov 29, 2016

Thank you @remcohaszing , I identify it as a bug.

Bascially, it is caused by the webpack detector returns an array as dependencies, For the such case, depcheck directly returns the array as dependencies without drill out its peer dependencies and optional dependencies.

@lijunle
Copy link
Member

lijunle commented Nov 29, 2016

Update: I published version 0.6.6 to resolve this issue. Please test it. Again, thank you for reporting this. 👍

@lijunle lijunle added this to the 0.6.6 milestone Nov 29, 2016
@remcohaszing
Copy link
Author

It works! Thanks 😄

@robross0606
Copy link

robross0606 commented Apr 5, 2021

This still appears to be happening. My project has a peer dependency on prom-client:

npm WARN prometheus-gc-stats@0.5.1 requires a peer of prom-client@>= 10 < 12 but none is installed. You must install peer dependencies yourself.

However, depcheck lists it as unused after installation:

C:\Code\code>depcheck --version
1.4.0

C:\Code\code>depcheck
Unused dependencies
* prom-client

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

4 participants