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

@prefer-jsr/sync-jsr-json

v0.1.3

Published

Sync jsr.json versions with package.json versions

Downloads

21

Readme

@prefer-jsr/sync-jsr-json

Sync jsr.json versions with package.json versions in packages publishing to both JSR and NPM.

Overview

This package provides a utility function to automatically synchronize version numbers between package.json and jsr.json files in a package. It's particularly useful in release workflows to ensure that JSR package import versions stay in sync with npm registry package dependency versions.

Features

  • ✅ Syncs main package version from package.json to jsr.json
  • ✅ Syncs JSR dependency import versions in jsr.json to match local package versions
  • ✅ Supports dry-run mode for testing
  • ✅ Provides detailed sync results
  • ✅ Handles missing files gracefully

Installation

pnpm i jsr:@prefer-jsr/sync-jsr-json
yarn add jsr:@prefer-jsr/sync-jsr-json
npx jsr add @prefer-jsr/sync-jsr-json
npm install @prefer-jsr/sync-jsr-json

Usage

Basic Usage

import { syncJsrJson } from '@prefer-jsr/sync-jsr-json';

// Sync all packages in the default packages directory
const result = await syncJsrJson();

console.log(`Synced ${result.syncedCount} packages`);

With Options

import { syncJsrJson } from '@prefer-jsr/sync-jsr-json';

const result = await syncJsrJson({
  packagesDir: './my-packages', // Custom packages directory
  dryRun: true, // Test without writing changes
  log: (msg) => console.log(msg), // Custom logger
});

// Check what would be synced
result.syncedPackages.forEach((pkg) => {
  console.log(`Package: ${pkg.packageName}`);
  pkg.changes.forEach((change) => {
    console.log(`  - ${change}`);
  });
});

In Release Scripts

import { syncJsrJson } from '@prefer-jsr/sync-jsr-json';

// Before creating a release
const result = await syncJsrJson({ dryRun: false });

if (result.syncedCount > 0) {
  console.log('JSR versions synced successfully!');
  // Continue with release process...
}

API

syncJsrJson(options?: SyncJsrJsonOptions): Promise<SyncResult>

Syncs jsr.json versions to match package.json versions using async file operations for optimal performance.

Options

interface SyncJsrJsonOptions {
  /**
   * The directory containing the packages to sync
   * @default process.cwd() + '/packages'
   */
  packagesDir?: string;

  /**
   * Whether to run in dry-run mode (don't write files)
   * @default false
   */
  dryRun?: boolean;

  /**
   * Custom logger function for output
   * @default console.log
   */
  log?: (message: string) => void;
}

Returns

interface SyncResult {
  /**
   * Number of packages that were synced
   */
  syncedCount: number;

  /**
   * Details of packages that were synced
   */
  syncedPackages: Array<{
    packageName: string;
    changes: string[];
  }>;
}

How It Works

The function:

  1. Scans all directories in the packagesDir
  2. For each directory with both package.json and jsr.json:
    • Syncs the main version field
    • Syncs any jsr: imports to use the latest local package versions (if the package exists locally)
  3. Returns a summary of all changes made

Example Sync

Given:

// packages/my-pkg/package.json
{
  "name": "@my-org/my-pkg",
  "version": "2.0.0"
}

// packages/my-pkg/jsr.json
{
  "name": "@my-org/my-pkg",
  "version": "1.0.0",
  "imports": {
    "dep": "jsr:@my-org/dep@^1.0.0"
  }
}

// packages/dep/package.json
{
  "name": "@my-org/dep",
  "version": "2.0.0"
}

After running syncJsrJson():

// packages/my-pkg/jsr.json
{
  "name": "@my-org/my-pkg",
  "version": "2.0.0", // ✅ Updated
  "imports": {
    "dep": "jsr:@my-org/dep@^2.0.0" // ✅ Updated
  }
}

License

MIT

Building

Run nx build sync-jsr-json to build the library.

Running unit tests

Run nx test sync-jsr-json to execute the unit tests via Vitest.