detective-module
TypeScript icon, indicating that this package has built-in type declarations

3.1.4 • Public • Published

detective-module npm npm

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",
      },
    ],
  },
];

License

MIT

/detective-module/

    Package Sidebar

    Install

    npm i detective-module

    Weekly Downloads

    13

    Version

    3.1.4

    License

    MIT

    Unpacked Size

    6.79 kB

    Total Files

    4

    Last publish

    Collaborators

    • noyobo