dylang / npm-check

Check for outdated, incorrect, and unused dependencies.
https://www.npmjs.com/package/npm-check
MIT License
6.56k stars 239 forks source link

"Two Package.json" Electron Apps Don't Properly Check #147

Open framerate opened 8 years ago

framerate commented 8 years ago

electron-userland/electron-builder recommends a two package.json format, with your compile tools in /package.json and your project/electron specific deps in app/package.json

Running npm-check in / just reports everything missing, since they're imported from /app/src/js/ etc.

I'm imagining it sees package.json inside /app and stops parsing that folder? Is that intentional?

lijunle commented 8 years ago

The short answer is Yes. When it encounters another package.json when walk through the folder structure, it will consider that is another project and stop on that.

Do you know why Electron recommends to place package.json inside app folder?

framerate commented 8 years ago

Yeah, actually. I've been struggling to get a nice solid electron foundation setup the last few days that builds multi-platform.

They have a nice write up here on why they recommend the two package system.

Personally, after setting it up I kind of like having electron stuff separate from my app itself (so the app could be built for web etc) but I don't really want the two pjson's since webpack builds all my dependencies anyways.

framerate commented 8 years ago

@lijunle Could you point me a direction of where the package.json skipping happens? Maybe I can add a flag or something that will ignore that file.

lijunle commented 8 years ago

It is using the depcheck project to check the usage of dependencies. The code logic is here: https://github.com/depcheck/depcheck/blob/master/src/check.js#L155

jacobwgillespie commented 8 years ago

@framerate one idea that I took from a project someplace and added here is to use the root package.json to contain all the dependencies, but as part of the build step, copy it into app and rewrite it. This solves the issue with npm-check and also with eslint-plugin-import.

https://github.com/radiant-player/radiant-player-electron/blob/87d10f800226409823c0d3518528824a48215471/gulpfile.babel.js#L64-L80