jscodeshift-build-import-list v1.4.1
jscodeshift-build-import-list
build a list of all files and dependencies transitively imported by starting file(s)
Installation
npm install --save-dev jscodeshift-build-import-listLimitations
Requires Node >= 8.
Dynamic require() and import() paths are not supported; an Error will be
thrown if dynamic path is encountered (unless you have a leading comment containing
@jscodeshift-build-import-list ignore).
However, calls to require-glob
with a string literal argument are supported.
API
buildImportList(files)
Builds a list of all files and npm packages imported from the given files,
the files imported by them, and sort forth.
files (string | string[])
The file(s) to start from.
Returns (Promise<{files: Set<string>, dependencies: Set<string>}>)
A Promise that will resolve to an object with two properties:
files
A Set of local files transitively imported by the starting file(s)
dependencies
A Set of npm packages transitively imported by the starting file(s)
Ignoring requires/imports
Add a leading comment containing @jscodeshift-build-import-list ignore, for example:
// @jscodeshift-build-import-list ignore
import foo from 'foo'
const bar = /* @jscodeshift-build-import-list ignore */ require(getBarPath())