# @rushstack/package-deps-hash

> The `package-deps-hash` library generates a JSON object containing the git hashes of all files used to produce a given package. This is useful for scenarios where you want to define a "change receipt" file to be published with a package. The [Rush](http

Latest version **4.8.0** (published 2026-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rushstack/package-deps-hash
pnpm add @rushstack/package-deps-hash
yarn add @rushstack/package-deps-hash
bun add @rushstack/package-deps-hash
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.8.0 |
| Published | 2026-10-06 |
| First published | 2020-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.9.0 |
| Dependencies | 1 |
| Unpacked size | 966.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | rushstack-admin, odspnpm, octogonz, microsoft1es |

## Links

- npm: https://www.npmjs.com/package/@rushstack/package-deps-hash
- Repository: https://github.com/microsoft/rushstack
- Homepage: https://github.com/microsoft/rushstack#readme
- Issues: https://github.com/microsoft/rushstack/issues
- npm.io page: https://npm.io/package/@rushstack/package-deps-hash

## Dependencies (1)

- [@rushstack/node-core-library](https://npm.io/package/@rushstack/node-core-library.md) 5.25.1

## Recent versions

- 4.8.0 (latest) — 2026-10-06
- 4.6.4 (pr5496) — 2026-01-12
- 4.7.31 — 2026-09-28
- 4.7.30 — 2026-09-22
- 4.7.29 — 2026-09-14
- 4.7.28 — 2026-09-09
- 4.7.27 — 2026-08-21
- 4.7.26 — 2026-08-20
- 4.7.25 — 2026-08-14
- 4.7.24 — 2026-07-21
- 4.7.23 — 2026-07-17
- 4.7.22 — 2026-07-16
- 4.7.21 — 2026-06-15
- 4.7.20 — 2026-06-13
- 4.7.19 — 2026-06-08
- … 470 more at https://npm.io/package/@rushstack/package-deps-hash/versions

## README

# @rushstack/package-deps-hash

The `package-deps-hash` library generates a JSON object containing the git hashes of all files used to produce
a given package.  This is useful for scenarios where you want to define a "change receipt" file to be published
with a package.  The [Rush](https://rushjs.io/) tool uses this library to implement incremental build detection.

Only files in a git repo that are not in .gitignore will be considered in building the hash.  The file content and
the current state of the package can be compared then to determine whether the package needs to be rebuilt.

Internally it uses the GIT hashes to derive the hashes for package content. This allows the process to leverage Git's
hash optimizations, as opposed to creating a more elaborate diffing scheme.

NOTE: Git is required to be accessible in the command line path.

## Usage

```ts
let _ = require('lodash');
let { getPackageDeps } = require('@rushstack/package-deps-hash');

// Gets the current deps object for the current working directory
let deps = getPackageDeps();
let existingDeps = JSON.parse(fs.readFileSync('package-deps.json'));

if (_.isEqual(deps, existingDeps)) {
  // Skip re-building package.
} else {
  // Rebuild package.
}
```

A long-lived process that reads the state of the same repository repeatedly can use a `RepoStateCache` (beta).
It returns the same result as `getDetailedRepoStateAsync()`, but keeps a private copy of the Git index and the
hashes of files that haven't changed between calls, and returns the same object while nothing changes:

```ts
import { RepoStateCache } from '@rushstack/package-deps-hash';

const cache = new RepoStateCache({ rootDirectory: '/path/to/repo' });
const state = await cache.getDetailedRepoStateAsync();
// ...
cache.dispose();
```

## Links

- [CHANGELOG.md](
  https://github.com/microsoft/rushstack/blob/main/libraries/package-deps-hash/CHANGELOG.md) - Find
  out what's new in the latest version
- [API Reference](https://api.rushstack.io/pages/package-deps-hash/)

`@rushstack/package-deps-hash` is part of the [Rush Stack](https://rushstack.io/) family of projects.

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