Open ingro opened 8 years ago
Hi, @ingro
Why import * as api from 'utils/api'
not import * as api from './utils/api'
? (The ./
difference)
Thanks for this feedback @ingro.
-s
skips this check, but it will still check all modules for what's out of date.
@lijunle can you make it so depcheck hands either use case?
@lijunle that's because I'm using webpack, so I can define many root paths for my modules, and I can include them with an absolute path instead of relatives
It seems that your usage is same as this one: https://github.com/depcheck/depcheck/issues/132
@ingro Could you share your webpack configuration file?
Sure, here it is:
var config = {
debug: true,
devtool: 'cheap-source-map',
entry: {
bundle: ['./src/scripts/index', 'webpack-hot-middleware/client?timeout=5000']
},
output: {
path: path.join(__dirname, 'public', 'dist', 'scripts'),
filename: '[name].js',
publicPath: '/dev/scripts/'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
__DEVTOOLS__: !!process.env.DEBUG,
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
})
],
resolve: {
modulesDirectories: ['node_modules', 'src/scripts'],
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [{
test: /\.js(x?)$/,
loader: 'babel',
exclude: /node_modules/,
query: {
plugins: ['transform-runtime']
}
}, {
test: /nunjucks\.js/,
loader: 'exports?nunjucks'
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff'
}, {
test: /\.(ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}, {
test: /\.(png|svg|jpg)$/,
loader: 'file-loader'
}],
noParse: [/sweetalert.min.js/]
},
watch: true
};
same issue here.
core 😟 MISSING! Not installed. 😟 PKG ERR! Not in the package.json. Found in: /app/src/core/actions/SystemActions.js
SystemActions.js liiks like this
import api from 'core/services/ExpApi';
also using webpack
+1 for it being a little overzealous. It now is flagging every one of my require() statements, even though I'm requiring a module defined within my project. It flags all different sorts, './file', '../../file', 'file'.
I just started noticing that my webpack requires are getting flagged as non existent, like the following error:
Registry error Package
!!script!mochadoesn't exist
@jharris4 What does the error come from? Related to npm-check?
Yes, the error shows when I run npm-check from the terminal.
It is caused by this line in one of my source files:
require('!!script!mocha/mocha.js');
The documentation for this syntax can be found here: https://webpack.github.io/docs/loaders.html
I have similar problems:
resolve.modules
in webpack config, so there are false positives for such modules. Config looks like this:resolve: {
modules: [
'web_modules',
'node_modules',
'shared'
]
}
I guess it's not that easy to support this, though (in this example, it would require checking every nested shared
folder in project).
!!style!css?modules!postcss!.
). This issue is more common, I believe, and is probably easier to fix: split by !
, normalize loader names (style
-> style-loader
) and then check them, something like that.The same here, when using webpack aliases:
resolve: {
modules: ['node_modules', 'bower_components'],
descriptionFiles: ['package.json'],
extensions: ['.js', '.jsx'],
alias: {
libs: path.join(__dirname, 'assets/libs'),
tests: path.join(__dirname, 'assets/tests'),
stores: path.join(__dirname, 'assets/stores'),
components: path.join(__dirname, 'assets/components'),
},
},
Hello! First of all, thanks for your work, I love this helper as I love to keep my projects with depencies up to date!
Anyway since updating to 5.1 I noticed an annoying behaviour:
npm-check
is starting to look for modules everywhere, even in.eslintrc
orkarma.conf.js
!The worst part is that I use
webpack
resolve'smodulesDirectories
options to load my modules with absolute paths from the root of my project, so I have a lot of this calls:import Header from 'components/header'
orimport * as api from 'utils/api'
Before 5.1 they were ignored, while now they are all caught making the report unreadable:
and so on.
I tried also with the
-s
flag but it skips a lot of modules so it's not viable either.