Skip to content

build a list of all files and dependencies transitively imported by starting file(s)

License

Notifications You must be signed in to change notification settings

codemodsquad/jscodeshift-build-import-list

Repository files navigation

jscodeshift-build-import-list

CircleCI Coverage Status semantic-release Commitizen friendly npm version

build a list of all files and dependencies transitively imported by starting file(s)

Installation

npm install --save-dev jscodeshift-build-import-list

Limitations

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())

About

build a list of all files and dependencies transitively imported by starting file(s)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published