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 🙏

© 2025 – Pkg Stats / Ryan Hefner

git-json-resolver-semver

v1.0.0

Published

Plugin for git-json-resolver that applies semver-based merge strategies (max, min, secure, override) to resolve version conflicts in package.json and similar files.

Readme

git-json-resolver-semver

test Maintainability codecov Version Downloads npm bundle size

Semver-aware plugin for git-json-resolver — resolve JSON version conflicts (e.g., package.json) via semantic-version strategies.

Strategies (this release):

  • semver-max → pick the higher version
  • semver-min → pick the lower version
  • semver-ours → prefer ours if valid, else (optionally) prefer valid theirs
  • semver-theirs → prefer theirs if valid, else (optionally) prefer valid ours

✨ Features

  • Avoid manual conflict resolution in package.json
  • Small & tree-shakable (0 runtime dependencies)
  • Works with direct import or dynamic plugin loading
  • TypeScript types included

Star the repo if it saved your merge. And and also share it with your friends.

📦 Install

pnpm add git-json-resolver-semver

or

npm install git-json-resolver-semver

or

yarn add git-json-resolver-semver

Peer dependencies:

pnpm install git-json-resolver

🚀 Usage

1. Direct Import

import createSemverPlugin, { semverMax } from "git-json-resolver-semver";
import { resolveConflicts } from "git-json-resolver";

// Option 1: Use factory function with custom config
const plugin = createSemverPlugin({
  strict: false,
  fallback: "ours",
});

await resolveConflicts({
  customStrategies: plugin.strategies,
  rules: {
    "dependencies.react": ["semver-max"],
    "devDependencies.vitest": ["semver-min"],
  },
});

// Option 2: Use individual strategy exports - not scoped @see migration guide for more details
await resolveConflicts({
  customStrategies: {
    "semver-max": semverMax,
  },
  rules: {
    "dependencies.react": ["semver-max"],
    "devDependencies.vitest": ["semver-min"],
  },
});

2. Dynamic Loading

{
  "plugins": ["git-json-resolver-semver"],
  "rules": {
    "dependencies.react": ["semver-max"],
    "devDependencies.vitest": ["semver-min"]
  }
}

or TypeScript Config

// git-json-resolver.config.ts
import type { Config } from "git-json-resolver";

const config: Config = {
  plugins: ["git-json-resolver-semver"],
  rules: {
    "dependencies.react": ["semver-max"],
    "devDependencies.vitest": ["semver-min"],
  },
};

export default config;

⚙️ Configuration

Factory Pattern (Recommended)

import createSemverPlugin from "git-json-resolver-semver";

const plugin = createSemverPlugin({
  strict: true, // Use validateStrict for exact semver only
  preferValid: true, // Prefer valid semver when only one side is valid
  fallback: "continue", // Behavior when both sides invalid
  preferRange: false, // Future: merge into semver ranges
  workspacePattern: "", // Pattern for workspace rules
});

Global Configuration

import { init } from "git-json-resolver-semver";

init({
  strict: false, // Allow prereleases and ranges
  fallback: "ours",
});

Behavior Notes

  • strict mode uses validateStrict - only accepts x.y.z format
  • preferValid returns the valid side when the other is invalid
  • fallback controls behavior when neither side is valid
  • Version prefixes like ^1.2.3 are automatically handled

⚙️ Strategies

| Strategy | Behavior | Example (ours vs theirs) | Result | | --------------- | --------------------------------------------------------------------- | ---------------------------- | ------- | | semver-max | Picks the higher valid semver | 1.2.3 vs 1.3.0 | 1.3.0 | | semver-min | Picks the lower valid semver | 2.0.0 vs 2.1.0 | 2.0.0 | | semver-ours | Picks ours if valid semver, else apply preferValid / fallback | 1.2.3 vs banana | 1.2.3 | | semver-theirs | Picks theirs if valid semver, else apply preferValid / fallback | foo vs 2.0.0 | 2.0.0 |

🙏 Acknowledgments

License

This library is licensed under the MPL-2.0 open-source license.

Please enroll in our courses or sponsor our work.