detective-cjs
Get the dependencies of a CommonJS module by traversing its AST
Last updated 2 years ago by xhmikosr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install detective-cjs 
SYNC missed versions from official npm registry.

detective-cjs

CI npm version npm downloads

Get the dependencies of a CommonJS module by traversing its AST

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

const fs = require('fs');
const detective = require('detective-cjs');

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

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

// Use skipLazyLoaded to only include top-level requires,
// treating inline (lazy-loaded) requires as intentional and legal
const topLevelOnly = detective(mySourceCode, { skipLazyLoaded: true });

License

MIT

Current Tags

  • 6.0.0                                ...           latest (2 years ago)

18 Versions

  • 6.0.0                                ...           2 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.0                                ...           4 years ago
  • 3.1.3                                ...           4 years ago
  • 3.1.2                                ...           4 years ago
  • 3.1.1                                ...           8 years ago
  • 3.1.0                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           10 years ago
  • 1.0.5                                ...           10 years ago
  • 1.0.4                                ...           11 years ago
  • 1.0.3                                ...           11 years ago
  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Downloads
Today 0
This Week 6
This Month 14
Last Day 2
Last Week 8
Last Month 1
Dependencies (2)
Dev Dependencies (3)
Dependents (3)

Copyright 2013 - present © cnpmjs.org | Home |