Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcelometal/es6-import-list
List all es6 imports
https://github.com/marcelometal/es6-import-list
analytics analyzer cli es6 import imports javascript js json parser
Last synced: about 2 months ago
JSON representation
List all es6 imports
- Host: GitHub
- URL: https://github.com/marcelometal/es6-import-list
- Owner: marcelometal
- License: agpl-3.0
- Created: 2017-12-10T20:33:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-10T19:07:46.000Z (about 6 years ago)
- Last Synced: 2024-08-10T09:34:25.062Z (5 months ago)
- Topics: analytics, analyzer, cli, es6, import, imports, javascript, js, json, parser
- Language: JavaScript
- Homepage:
- Size: 61.5 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# es6-import-list [![Build Status](https://secure.travis-ci.org/marcelometal/es6-import-list.png?branch=master)](https://travis-ci.org/marcelometal/es6-import-list) [![npm version](https://img.shields.io/npm/v/es6-import-list.svg?style=flat)](https://www.npmjs.com/package/es6-import-list)
Utility for obtaining the dependency list from ES6 modules.
This module only analyzes imports declared using the ES module syntax.## Installation
```sh
npm install -g es6-import-list
```## CLI
```sh
$ 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
```sh
$ 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
```js
const getImports = require('es6-import-list');getImports('my-directory', importsList => {
console.log(importsList);
});
```Default options:
```js
const options = {
match: /.js$/,
exclude: [/^\./],
}
```es6-import-list uses [node-dir][node-dir], so you can pass additional options
parameter to match or ignore files, for example.```js
const getImports = require('es6-import-list');const options = {
match: /.js$/,
exclude: [/^\./],
excludeDir: ['dist', 'lib', 'node_modules'],
};getImports('my-directory', options, importList => {
console.log(importList);
});
```[node-dir]: https://github.com/fshost/node-dir