# resolve-dependencies

> resolve-dependencies

Latest version **6.0.9** (published 2023-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install resolve-dependencies
pnpm add resolve-dependencies
yarn add resolve-dependencies
bun add resolve-dependencies
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.9 |
| Published | 2023-04-06 |
| First published | 2018-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 45.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Maintainers | calebboyd |

## Links

- npm: https://www.npmjs.com/package/resolve-dependencies
- Repository: https://github.com/nexe/resolve-dependencies
- Homepage: https://github.com/nexe/resolve-dependencies#readme
- Issues: https://github.com/nexe/resolve-dependencies/issues
- npm.io page: https://npm.io/package/resolve-dependencies

## Dependencies (3)

- [meriyah](https://npm.io/package/meriyah.md) ^4.3.5
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.12
- [enhanced-resolve](https://npm.io/package/enhanced-resolve.md) ^5.12.0

## Recent versions

- 6.0.9 (latest) — 2023-04-06
- 4.2.4 (four) — 2020-06-26
- 6.0.8 — 2022-05-17
- 6.0.7 — 2021-07-16
- 6.0.6 — 2021-02-26
- 6.0.5 — 2021-02-24
- 6.0.4 — 2021-01-03
- 6.0.3 — 2020-11-21
- 6.0.2 — 2020-07-07
- 6.0.1 — 2020-07-06
- 6.0.0 — 2020-07-06
- 5.1.3 — 2020-07-01
- 4.2.5 — 2020-06-30
- 5.1.2 — 2020-06-30
- 5.1.1 — 2020-06-29
- … 40 more at https://npm.io/package/resolve-dependencies/versions

## README

<h2 align="center">resolve-dependencies</h2>

---

<p align="center"><code>npm i resolve-dependencies</code></p>

`resolve-dependencies` is the very originally named bundler for [nexe](https://github.com/nexe/nexe). It wasn't our intention to build a bundler but that is kind of what this is.

## Exports


### `default: resolveSync(options: Options, ...opts: Options[]): Promise<Result>`
  
  - `Options`: _Object | string_ -- the entry to start from (if string)
    - `entries`: _string[]_ -- a list of entrypoints to traverse, resolved against cwd
    - `cwd`: _string_ -- the base directory that the resolution occurs from
    - `loadContent`: _boolean_ -- indicates that the content should be included int he FileMap (this may be unreasonable for large dependency trees)
    - `files`: _({ [key: string]: File | null })[]_ -- a cache of already resolved files
    - `expand`: _'all' | 'none' | 'variable'_ -- how module contexts should be expanded to include extra files

All options are deeply merged, string options are added as `entries`

Result returns a Promise of a result object:
  - `Result`: _Object_
    - `entries`: _{ [key: entry]: File }_ - all the entries as provided to the `resolve` method and the tree of connected `files`
    - `files`: _{ [key: absPath]: File }_ - all resolved files keyed by their absolute path
    - `warnings`: _string[]_ - an array warnings generated while processing the `files`

A `File` has the following shape
  - `File`: _Object_ -- An object representing a file
    - `size`: _number_ -- file size of the link or file
    - `absPath`: _string_ -- absolute path to the file
    - `moduleRoot`: _string | undefined_ -- Directory containing a modules package.json
    - `package`: _any | undefined_
    - `deps`: _{ [key: request]: File | null }_ -- Dependencies identified in the file, keyed by request
    - `belongsTo`: _File | undefined_ -- The main file of the owning module
    - `realSize`: _number | undefined_ -- set to the realfile size if the absPath is a symlink
    - `realPath`: _string | undefined_ -- set to the realpath if the absPath is a symlink
    - `contents`: _string | null_
    - `contextExpanded`: _boolean_
    - `variableImports`: _boolean_


## Example:

```javascript
import resolveDependencies from 'resolve-dependencies'

const { entries, files } = resolveDependencies('./entry-file.js')
console.log(entries['./entry-file.js'])

// {
//   absPath: "/path/to/entry-file.js",
//   contents: "console.log('hello world')",
//   realSize: 26,
//   realPath: "/path/to/entry/lib/file.js"
//   size: 12
//   variableImports: false,
//   deps: {
//     "./dependency": {
//       absPath: "/path/to/dependency.js"
//       ...
//     },
//     path: null, //node builtin does not resolve
//     mkdirp: {
//       absPath: "/path/to/node_modules/mkdirp/index.js",
//       modulePath: "/path/to/node_modules/mkdirp",
//       package: {
//         name: "mkdirp"
//         ...
//       }
//     }
//   }
// }
//  `files` is a similar structure to entries, but 
//   is flat and keyed by the file's absolute path.
```

---
_Source: https://npm.io/package/resolve-dependencies · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
