Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

babel-collect-imports

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-collect-imports

Recursively collect all the internal and external dependencies from an entry point

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
8
166.67%
Maintainers
1
Weekly downloads
 
Created
Source

babel-collect-imports

Recursively collect all the internal and external dependencies from an entry point

Install

yarn add babel-collect-imports

Usage

const { collectImportsSync } = require('babel-collect-imports');

let { internal, external } = collectImportsSync('path/to/entry.js');
// { internal: ['path/to/entry.js', 'path/to/import.js', 'path/to/other/import.js'],
//   external: ['lodash', 'react'] }

When it discovers an "internal" dependency (one that is not a node package), it will follow the import and continue collecting dependencies.

API

collectImportsSync(entry, parserOpts?, resolveOpts?)

  • entry should be a full file path
  • parserOpts is Babylon's options
  • resolveOpts is resolve's options

FAQ

How are "internal" vs "external" imports determined?

It's all about the starting dot:

import internal from './internal-because-it-starts-with-a-dot';
import external from 'external-because-it-does-not-start-with-a-dot';

What about my special aliasing system?

Your custom aliasing is bad and you should feel bad. Try playing with resolveOpts.

Keywords

babel

FAQs

Package last updated on 11 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts