# @microsoft/webpack-stats-differ

> A library for generating a diff object between two sets of webpack bundle stat files.

Latest version **2.3.2** (published 2025-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @microsoft/webpack-stats-differ
pnpm add @microsoft/webpack-stats-differ
yarn add @microsoft/webpack-stats-differ
bun add @microsoft/webpack-stats-differ
```

## Health

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

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.3.2 |
| Published | 2025-09-29 |
| First published | 2021-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 32.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | vincentbailly, bweggersen, microsoft1es, kenotron_msft |

## Links

- npm: https://www.npmjs.com/package/@microsoft/webpack-stats-differ
- Repository: https://github.com/microsoft/ardiffact
- Homepage: https://github.com/microsoft/ardiffact#readme
- Issues: https://github.com/microsoft/ardiffact/issues
- npm.io page: https://npm.io/package/@microsoft/webpack-stats-differ

## Dependencies (8)

- [globby](https://npm.io/package/globby.md) ^11.0.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [matcher](https://npm.io/package/matcher.md) ^3.0.0
- [multimatch](https://npm.io/package/multimatch.md) ^5.0.0
- [stream-json](https://npm.io/package/stream-json.md) ^1.7.5
- [stream-chain](https://npm.io/package/stream-chain.md) ^2.2.5
- [@mixer/webpack-bundle-compare](https://npm.io/package/@mixer/webpack-bundle-compare.md) ^0.1.0
- [@microsoft/azure-artifact-storage](https://npm.io/package/@microsoft/azure-artifact-storage.md) *

## Recent versions

- 2.3.2 (latest) — 2025-09-29
- 2.3.1 — 2025-09-26
- 2.3.0 — 2025-07-23
- 2.2.0 — 2025-07-17
- 2.0.0 — 2025-05-21
- 1.3.7 — 2025-04-30
- 1.3.6 — 2025-03-20
- 1.3.5 — 2024-06-26
- 1.3.4 — 2024-06-26
- 1.3.3 — 2024-06-26
- 1.3.2 — 2024-04-08
- 1.3.1 — 2023-12-12
- 1.3.0 — 2023-10-03
- 1.2.0 — 2023-08-03
- 1.1.0 — 2023-07-05
- … 4 more at https://npm.io/package/@microsoft/webpack-stats-differ/versions

## README

# webpack-stats-differ
A library for generating a diff object between two sets of webpack bundle stat files.

## Installation
Using npm:
```sh
npm install @microsoft/webpack-stats-differ
```
Using Yarn:
```sh
yarn add @microsoft/webpack-stats-differ
```

## Usage
```typescript
import { diff, getFriendlyAssetName } from "@microsoft/webpack-stats-differ";
import * as path from "path";
import * as fs from "fs";

const baselineDir = path.resolve('/baseline');
const candidateDir = path.resolve('/candidate');
// Read the contents of your webpack-generated JSON file containing statistics about the compiled modules
const webPackStatsFile = fs.readFileSync('bundle-stats.json');

const diffResult = await diff(baselineDirUnzipped,candidateDir);
const name = getFriendlyAssetName(webPackStatsFile.asset);
```

# API

## diff() function

Calculates the diff between two sets of bundle stats.

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  baselineDir | string | Directory containing webpack stat files of the baseline |
|  candidateDir | string | Directory containing webpack stat files of the candidate |
|  fileFilter | string \| string\[\] | Optionally pass filter to omit certain files using [globby](https://github.com/sindresorhus/globby#usage) syntax |
|  filter | string \| string\[\] | Filter out certain assets for the bundle size calculation |
|  remoteArtifactManifests | { baseline: string \| [RemoteArtifact](https://github.com/microsoft/ardiffact/blob/68e27505a9f7f97334592676bbd43b827f53c552/docs/azure-artifact-storage.remoteartifact.md)<!-- -->\[\]; candidate: string \| [RemoteArtifact](https://github.com/microsoft/ardiffact/blob/68e27505a9f7f97334592676bbd43b827f53c552/docs/azure-artifact-storage.remoteartifact.md)<!-- -->\[\]; hostUrl: string; } | Either a path on disk to the serialized JSON manifest or the [RemoteArtifact](https://github.com/microsoft/ardiffact/blob/68e27505a9f7f97334592676bbd43b827f53c552/docs/azure-artifact-storage.remoteartifact.md) list manifest object itself |

<b>Returns:</b>

Promise&lt;[FileDiffResults](https://github.com/microsoft/ardiffact/blob/68e27505a9f7f97334592676bbd43b827f53c552/docs/webpack-stats-differ.filediffresults.md)<!-- -->&gt;

The diff object.

## getFriendlyAssetName() function

Returns a readable name of the asset.

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  asset | Pick&lt;Asset, "name" \| "chunkNames" \| "chunks"&gt; | webpack stats asset |

<b>Returns:</b>

string

# Contributing

This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

# License

MIT

---
_Source: https://npm.io/package/@microsoft/webpack-stats-differ · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
