Given a node js package, I can find packages it is dependant on. For each of the dependencies, how can I get the exports that current package uses ?
Example: In a javascript file, I have following lines of code
var async = require('async');
......
async.mapSeries(files, function (entry, done) {
......
I want to be able to extract out that this js uses mapSeries function from async
You could relatively easily do it with esprima
, for example, but like @DaveNewton said you might miss some, due to the very dynamic nature of JS, and the fact that exports
can be modified many different ways.
Not only will you have to "run the code" for complete, bullet-proof list, you would also have to run it with 100% coverage. Not really something worth doing, probably.