# @11ty/dependency-tree-esm

> Finds all JavaScript ES Module dependencies from a filename.

Latest version **2.0.4** (published 2025-12-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @11ty/dependency-tree-esm
pnpm add @11ty/dependency-tree-esm
yarn add @11ty/dependency-tree-esm
bun add @11ty/dependency-tree-esm
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: no vulnerabilities; has provenance.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2025-12-19 |
| First published | 2023-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Author | Zach Leatherman |
| Maintainers | zachleat, fortawesome-admin |

## Links

- npm: https://www.npmjs.com/package/@11ty/dependency-tree-esm
- Repository: https://github.com/11ty/eleventy-utils
- Homepage: https://github.com/11ty/eleventy-utils#readme
- Issues: https://github.com/11ty/eleventy-utils/issues
- npm.io page: https://npm.io/package/@11ty/dependency-tree-esm

## Dependencies (4)

- [acorn](https://npm.io/package/acorn.md) ^8.15.0
- [normalize-path](https://npm.io/package/normalize-path.md) ^3.0.0
- [dependency-graph](https://npm.io/package/dependency-graph.md) ^1.0.0
- [@11ty/eleventy-utils](https://npm.io/package/@11ty/eleventy-utils.md) ^2.0.7

## Recent versions

- 2.0.4 (latest) — 2025-12-19
- 2.0.3 — 2025-12-02
- 2.0.2 — 2025-10-30
- 2.0.1 — 2025-10-30
- 2.0.0 — 2025-03-03
- 1.0.2 — 2025-01-09
- 1.0.1 — 2024-12-06
- 1.0.0 — 2023-08-25

## README

# `dependency-tree-esm`

Returns an unordered array of local paths to dependencies of a Node ES module JavaScript file.

* See also: [`dependency-tree`](https://github.com/11ty/eleventy-dependency-tree) for the CommonJS version.

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-esm
```

## Features

* Ignores bare specifiers (e.g. `import "my-package"`)
* Ignores Node’s built-ins (e.g. `import "path"`)
* Handles circular dependencies
* Returns an empty set if the file does not exist.

## Usage

```js
// my-file.js

// if my-local-dependency.js has dependencies, it will include those too
import "./my-local-dependency.js";


// ignored, is a built-in
import path from "path";
```

```js
import { find } from "@11ty/dependency-tree-esm";
// CommonJS is fine too
// const { find } = require("@11ty/dependency-tree-esm");

await find("./my-file.js");
// returns ["./my-local-dependency.js"]
```

Return a [dependency-graph](https://github.com/jriecken/dependency-graph) instance:

```js
import { findGraph } from "@11ty/dependency-tree-esm";
// CommonJS is fine too
// const { find } = require("@11ty/dependency-tree-esm");

(await findGraph("./my-file.js")).overallOrder();
// returns ["./my-local-dependency.js", "./my-file.js"]
```

---
_Source: https://npm.io/package/@11ty/dependency-tree-esm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
