dependency-tree
Returns an unordered array of local paths to dependencies of a node JavaScript file (everything it or any of its dependencies require
s).
Reduced feature (faster) alternative to the dependency-tree
package that only works with stock node JS. This is used by Eleventy to find dependencies of a JavaScript file to watch for changes to re-run Eleventy’s build.
Installation
npm install --save-dev @11ty/dependency-tree
Features
- Ignores
node_modules
- Ignores Node’s built-ins (e.g.
path
) - Handles circular dependencies (Node does this too)
Usage
// my-file.js // if my-local-dependency.js has dependencies, it will include those tooconst test = ; // ignored, is a built-inconst path = ;
const DependencyTree = ; ;// returns ["./my-local-dependency.js"]
allowNotFound
const DependencyTree = ; ; // throws an error ;// returns []