Skip to content
Get the dependencies of a CommonJS module by traversing its AST
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.jscsrc
.npmignore
.travis.yml
LICENSE
Readme.md
index.js
package-lock.json
package.json

Readme.md

detective-cjs npm npm

Get the dependencies of an CommonJS module

npm install detective-cjs

But dude, substack already built this: node-detective. Yes, but I needed the capability to reuse an AST and this was unlikely to be merged timely. I can also support jsx and other syntactic constructs faster.

Usage

var detective = require('detective-cjs');

var mySourceCode = fs.readFileSync('myfile.js', 'utf8');

// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);

License

MIT

You can’t perform that action at this time.