babel-collect-imports
Recursively collect all the internal and external dependencies from an entry point
Install
yarn add babel-collect-imports
Usage
const collectImportsSync = ; let internal external = ;// { 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?)
FAQ
How are "internal" vs "external" imports determined?
It's all about the starting dot:
;;
What about my special aliasing system?
Your custom aliasing is bad and you should feel bad. Try playing with
resolveOpts
.