import-js icon indicating copy to clipboard operation
import-js copied to clipboard

Suggest packages not in dependencies

Open rhettlivingston opened this issue 9 years ago • 1 comments

To limit analysis overhead and encourage good practices (clearly documented dependencies), we will normally only analyze packages that are directly specified in a package.json or .meteor/packages file. But, we are in the business of helping to add imports that are missing - why not package specifications that are missing too?

What if we had an optional command to go deeper rather than just say that no modules were found to resolve an unresolved variable? We could do things like scan all of the packages under node_modules (I see 606 under my import-js/node_modules directory right now) or similar locations in Meteor's directories to see if there is a package that has been indirectly included that could resolve the variable.

If we find something that the user agrees to, we could then both add the dependency in the appropriate file and add the import.

Further down the road, we might even be able to wire in some automatic npm search for a match.

Just documenting a thought here. Low priority.

rhettlivingston avatar Aug 20 '16 23:08 rhettlivingston

It's an interesting thought, but I don't think we really need to do this. There is an eslint plugin that will tell you about missing package dependencies, and I think that people should use that. I also imagine that the number of cases where you happen to have a package in your node_modules that matches what you are trying to do but where you don't have it listed in your dependencies is probably pretty low. So even if we were to do this, it seems like it wouldn't really benefit people very often.

lencioni avatar Aug 20 '16 23:08 lencioni