Recursively or non-recursively gets all ES6 imports and exports used within a project.
Returns an object in the form:
imports:'full path of ./b': 'default''full path of ./c': '*''full path of lodash': 'find'exports:'full path of ./a': 'default''full path of ./b': '*''full path of ./c': 'find'
;const imports exports loadedFiles stats = await;
files is an array of paths for JS files you want to check.
recurse option will recursively look at the files imported to find more imports. Will not recurse and look for dependencies within node_modules, but imports to these files are still recorded.
exclude option is an array of file globs for files you don't want to check when recursing. As with node_modules, imports to these files are still reported.
parserOptions options are identical to ESLint. By default, it will supports ES6 modules and JSX.
resolveOptions is passed to resolve to resolve imports.
imports is a map of absolute file path to an array of imports. Named imports are left as-is, default imports are reported as
'default', and namespace imports are reported as
; // 'a'; // 'a'; // 'default'; // '*'
Note that exports can also report as an import.
; // equates to import * from 'lodash'
exports is also a map of absolute filepath to an array, but this time, exports. As before, the same naming convention is used.
const five = 5; // 'five'5; // 'default'; // '*'
loadedFiles is the files that were loaded and checked.
stats is an array of warnings. Currently the only warning is if a file failed to parse, and had an extension that wasn't .js (which would otherwise throw).
The default parser and default parser options are exported for your convenience.