babel-dependency-parser
Parse require calls and return used dependencies
Last updated 2 months ago by f0x52 .
GPL-3.0 · Repository · Original npm · Tarball · package.json
$ cnpm install babel-dependency-parser 
SYNC missed versions from official npm registry.

Babel Dependency Parser

Simple babel plugin that parses all dependencies of the passed code.

Use:

"use strict";

const babel = require('@babel/core');
const dependencyParser = require('babel-dependency-parser');

let code = `let React = require('react');`;

let dependencies = [];
babel.transform(code, {
	plugins: [dependencyParser(dependencies)]
});

console.log(dependencies); // [ 'react' ]

If you need to parse CommonJS import statements, make sure to also add @babel/plugin-transform-modules-commonjs.

Current Tags

  • 1.1.0                                ...           latest (2 months ago)

2 Versions

  • 1.1.0                                ...           2 months ago
  • 1.0.0                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |