JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1952736
  • Score
    100M100P100Q213345F
  • License MIT

Get the dependencies of a CommonJS module by traversing its AST

Package Exports

  • detective-cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (detective-cjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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);

License

MIT