es6-import-list

0.2.1 • Public • Published

es6-import-list Build Status npm version

Utility for obtaining the dependency list from ES6 modules. This module only analyzes imports declared using the ES module syntax.

Installation

npm install -g es6-import-list

CLI

$ es6-import-list -d src/
 
// Output:
 
┌────────────────────────┬─────────────────────────┐
│ Modules                │ Import List             │
├────────────────────────┼─────────────────────────┤
│ megadraft              │ MegadraftEditor         │
│                        │ MegadraftIcons          │
│                        │ editorStateFromRaw      │
├────────────────────────┼─────────────────────────┤
│ react                  │ Component               │
│                        │ React                   │
├────────────────────────┼─────────────────────────┤
│ react-dom              │ render                  │
└────────────────────────┴─────────────────────────┘

Generate a JSON output with all the dependency information

$ es6-import-list -d src/ --json
 
// Output:
 
{
  "megadraft": [
    "MegadraftEditor",
    "MegadraftIcons",
    "editorStateFromRaw"
  ],
  "react": [
    "Component",
    "React"
  ],
  "react-dom": [
    "render"
  ]
}

Try es6-import-list --help for more information.

API

getImports(dir, [options], callback)

Examples

const getImports = require('es6-import-list');
 
getImports('my-directory', importsList => {
  console.log(importsList);
});

Default options:

const options = {
  match: /.js$/,
  exclude: [/^\./],
}

es6-import-list uses node-dir, so you can pass additional options parameter to match or ignore files, for example.

const getImports = require('es6-import-list');
 
const options = {
  match: /.js$/,
  exclude: [/^\./],
  excludeDir: ['dist', 'lib', 'node_modules'],
};
 
getImports('my-directory', options, importList => {
  console.log(importList);
});

Readme

Keywords

Package Sidebar

Install

npm i es6-import-list

Weekly Downloads

1

Version

0.2.1

License

AGPLv3+

Unpacked Size

51.6 kB

Total Files

8

Last publish

Collaborators

  • dnsaoki
  • metal
  • ricobl
  • vierno