es-stats
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.2 • Public • Published

es-stats

Find out import, exports and root declarations' dependency relationships of an ES module file.

Quick start

Intalling via npm:

npm i es-stats

Extract imports, exports, and root declarations' relationship with default settings:

const esStats = require('es-stats');
const fs = require('fs');

const { imports, exports, relations } = esStats(
  fs.readFileSync('myfile.js', 'utf-8')
);
console.log('Imports:', imports);
console.log('Exports:', exports);
console.log('Relations:', relations);

To support things like JSX, flow, dynamic imports, etc.. You will need to enable @babel/parser plugins:

const { imports, exports, relations } = esStats(
  fs.readFileSync('myfile.js', 'utf-8'),
  {
    plugins: ['jsx', 'dynamicImport'],
  }
);

Following plugins are enabled on .js|.jsx|.ts|.tsx files by default:

  • dynamicImport
  • classProperties
  • flowComments
  • objectRestSpread
  • functionBind
  • jsx
  • flow (.js and .jsx only)
  • typescript (.ts and .tsx only)

All the options in the 2nd parameter will be passed to @babel/parser directly. @babel/parser options can be found here.

Package Sidebar

Install

npm i es-stats

Weekly Downloads

96

Version

1.0.0-alpha.2

License

MIT

Unpacked Size

28.9 kB

Total Files

26

Last publish

Collaborators

  • jennieji