Recursively collect all the internal and external dependencies from an entry point
yarn add babel-collect-imports
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.
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';
Your custom aliasing is bad and you should feel bad. Try playing with
resolveOpts
.