Find out import, exports and root declarations' dependency relationships of an ES module file.
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:
dynamicImportclassPropertiesflowCommentsobjectRestSpreadfunctionBindjsxflow (.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.
Generated using TypeDoc