New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@rushstack/package-deps-hash

Package Overview
Dependencies
Maintainers
4
Versions
487
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@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
Source
npmnpm
Version
4.8.2
Version published
Weekly downloads
757K
53.15%
Maintainers
4
Weekly downloads
 
Created
Source

@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 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

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:

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

const cache = new RepoStateCache({ rootDirectory: '/path/to/repo' });
const state = await cache.getDetailedRepoStateAsync();
// ...
cache.dispose();
  • CHANGELOG.md - Find out what's new in the latest version
  • API Reference

@rushstack/package-deps-hash is part of the Rush Stack family of projects.

FAQs

Package last updated on 30 Oct 2026

Related posts