https://github.com/codemodsquad/jscodeshift-build-import-list
build a list of all files and dependencies transitively imported by starting file(s)
https://github.com/codemodsquad/jscodeshift-build-import-list
jscodeshift
Last synced: about 1 month ago
JSON representation
build a list of all files and dependencies transitively imported by starting file(s)
- Host: GitHub
- URL: https://github.com/codemodsquad/jscodeshift-build-import-list
- Owner: codemodsquad
- License: mit
- Created: 2018-10-08T22:27:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T23:41:17.000Z (over 1 year ago)
- Last Synced: 2025-08-20T01:22:21.245Z (about 2 months ago)
- Topics: jscodeshift
- Language: JavaScript
- Homepage:
- Size: 1.54 MB
- Stars: 6
- Watchers: 1
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# jscodeshift-build-import-list
[](https://circleci.com/gh/codemodsquad/jscodeshift-build-import-list)
[](https://codecov.io/gh/codemodsquad/jscodeshift-build-import-list)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
[](https://badge.fury.io/js/jscodeshift-build-import-list)build a list of all files and dependencies transitively imported by starting file(s)
# Installation
```sh
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`](https://github.com/shannonmoeller/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, dependencies: Set}>`)
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:
```js
// @jscodeshift-build-import-list ignore
import foo from 'foo'
const bar = /* @jscodeshift-build-import-list ignore */ require(getBarPath())
```