detective-module
v3.1.4
Published
Get the dependencies specifier of an es6 module
Downloads
68
Maintainers
Readme
detective-module
Get the dependencies specifier of an ES6 module And Require()
npm install detective-module
Usage
var {
detectiveModuleAndRequire,
detectiveModule,
} = require("detective-module");
var mySourceCode = fs.readFileSync("myfile.js", "utf8");
// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);
// input:
import Abc, * as BBBBBB from "mylib";
// output
[
{
name: "mylib",
default: "Abc",
star: true,
alias: "BBBBBB",
},
];
Example
// input:
import { foo as Foo, bar } from "mylib";
// output
[
{
name: "mylib",
members: [
{
name: "foo",
alias: "Foo",
},
{
name: "bar",
alias: "bar",
},
],
},
];
- Supports JSX, Flow, and any other features that node-source-walk supports.
License
MIT