npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pm-dedup-core

v2.3.0

Published

package manager utils

Readme

Install

npm install --save pm-dedup-core

Usage

The package-manager-agnostic core behind bun-dedup, pnpm-dedup and yarn-berry-deduplicate: everything about finding duplicates, deciding what can be merged and rendering the result lives here. The per-manager packages only parse their lockfile into the shapes below and write the result back.

It is published so those packages can depend on it, not as a general-purpose library: this is internal API and it changes with them. There is no default export — import the named ones.

import {
  buildLockstepClusters,
  createPackageFilter,
  findProjectRoot,
  identifyResolutionFixes,
} from "pm-dedup-core";

const projectDir = findProjectRoot({ lockfileName: "bun.lock" }); // null when there is none
const filter = createPackageFilter({
  includeScopes: ["@babel"],
  exclude: ["@babel/runtime"],
});

filter.selects("@babel/core"); // true
filter.rejectionReason("lodash"); // why it is left alone, for the report

What a package manager has to supply

The core never touches the filesystem for you and never guesses a lockfile path. A caller reads its own lockfile and hands over:

  • a resolutions list — one entry per resolved copy of a package (ResolutionEntry, whose package is npm or another protocol).
  • a dependents map — for each package name, who requires it and with which range (ResolutionDependentsMap). This is where the managers differ most: see the peer-dependency notes in each package's README.
  • for the cluster pass, a lockstep graph (LockstepGraph), the dependency edges between resolved copies.

Areas

| Area | Exports | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | | Project root | findProjectRoot, resolveProjectDir | | CLI grammar | parseBinArgs, packageFilterParseArgsOptions, packageFilterUsage, whyDuplicateParseArgsOptions, whyDuplicateUsage, toWhyDuplicateRequest | | Package filtering | createPackageFilter, selectPackages, selectClusterFixes, describeSkippedClusterFix, selectExplainedPackages | | Names and ranges | PackageDescriptorNameUtils, PackageDependencyDescriptorUtils, isNpmProtocol, isSemverComparable, createCandidateVersionComparator | | Fix identification | identifyResolutionFixes, buildLockstepClusters, identifyLockstepClusterFixes, buildIdentifiedFixesMap, clusterLabel | | Applying | planClusterApply, applyWorkspaceRangeEdit, nextSelector, partitionUnconditionalOverrides, captureFiles, restoreFiles | | Measuring a run | buildVersionsSnapshot, diffVersionsSnapshots, countDuplicatedPackages, diffDuplicates | | Rendering | renderDuplicatesReport, renderApplyPlan, renderDedupeSummary, createColorize, shouldColorize, stylePackageName, stylePackageReference |

Two of these carry most of the behaviour:

  • identifyResolutionFixes finds the merges reachable one package at a time: a copy whose dependents' ranges all accept a version already in the lockfile. This is what the lockfile pass applies.
  • identifyLockstepClusterFixes finds the rest. buildLockstepClusters groups packages that are always published at the same version, and a duplicate inside such a family only goes away when the whole family moves — which needs a real resolution, hence the separate cluster pass.

resolveProjectDir is the bin-facing half of findProjectRoot: it prints the reason and sets process.exitCode when there is no lockfile, and returns null, so callers guard with if (projectDir === null) return;. The notice naming the lockfile goes to stderr and only when the root is not the working directory, keeping a redirected report parseable.

Colors

shouldColorize(stream) follows the terminal: NO_COLOR and a piped stream turn colors off, FORCE_COLOR turns them on. Every renderer takes the resulting Colorize, so a report piped to a file is plain text.

Runtime

Node only (>=22.18.0), so the pnpm and yarn tools can depend on it: no Bun.*, no bun imports. Tests run under bun test like the rest of the monorepo.