Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dependents/node-detective-es6
Get the dependencies of an ES6 module by traversing its AST
https://github.com/dependents/node-detective-es6
ast dependency detective detective-es6 es6 javascript module
Last synced: 5 days ago
JSON representation
Get the dependencies of an ES6 module by traversing its AST
- Host: GitHub
- URL: https://github.com/dependents/node-detective-es6
- Owner: dependents
- License: mit
- Created: 2014-10-25T22:10:35.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2024-08-31T04:14:10.000Z (2 months ago)
- Last Synced: 2024-11-03T16:37:21.277Z (10 days ago)
- Topics: ast, dependency, detective, detective-es6, es6, javascript, module
- Language: JavaScript
- Homepage:
- Size: 343 KB
- Stars: 34
- Watchers: 3
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# detective-es6
[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-detective-es6/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-detective-es6/actions/workflows/ci.yml?query=branch%3Amain)
[![npm version](https://img.shields.io/npm/v/detective-es6?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-es6)
[![npm downloads](https://img.shields.io/npm/dm/detective-es6)](https://www.npmjs.com/package/detective-es6)> Get the dependencies of an ES6 module
```sh
npm install detective-es6
```## Usage
```js
const fs = require('fs');
const detective = require('detective-es6');const mySourceCode = fs.readFileSync('myfile.js', 'utf8');
// Pass in a file's content or an AST
const dependencies = detective(mySourceCode);
```* Supports JSX, Flow, and any other features that [node-source-walk](https://github.com/dependents/node-source-walk) supports.
You may also (optionally) configure the detective via a second object argument detective(src, options) that supports the following options:
- `skipTypeImports`: (Boolean) whether or not to omit type imports (`import type {foo} from "mylib";`) in the list of extracted dependencies.
- `skipAsyncImports`: (Boolean) whether or not to omit async imports (`import('foo')`) in the list of extracted dependencies.## License
[MIT](LICENSE)