Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

babel-dependency-parser

1.1.0 • Public • Published

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.

Install

npm i babel-dependency-parser

DownloadsWeekly Downloads

3

Version

1.1.0

License

GPL-3.0

Unpacked Size

37 kB

Total Files

4

Last publish

Collaborators

  • avatar