babylon-ast-dependencies
Inspects Babylon ASTs for dependency identifiers
Last updated 4 years ago by markfinger .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babylon-ast-dependencies 
SYNC missed versions from official npm registry.

babylon-ast-dependencies

Inspects Babylon ASTs for dependency identifiers

Install

npm install --save babylon-ast-dependencies

Example

import * as babylon from 'babylon'
import babylonAstDependencies from 'babylon-ast-dependencies';

const ast = babylon.parse(
  `
    import foo from "foo";
    require('./bar')
    export * from './woz'
  `,
  {sourceType: 'module'}
);

const deps = babylonAstDependencies(ast);

console.log(deps.map(dep => dep.source);
// ['foo', './bar', 'woz']

Notes

Lists of objects are returned, where each object has the value of the identifier as a source prop. Rather than simply returning lists of strings, we use objects as it leaves open the potential for more contextual information to be provided in a backwards-compatible manner.

Current Tags

  • 1.0.2                                ...           latest (4 years ago)

3 Versions

  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (4)
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |