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

resolve-unpkg

v2.0.2

Published

<p align="center"> <img src="https://image.ibb.co/nR99Wy/svg_resolveunpkg_github.png"/> </p>

Readme

Build Status semantic-release

The Resolve-Unpkg library helps you to keep your unpkg links up to date by patching the unpkg URLs with the package version installed in your environment. The Resolve-Unpkg may be used in command line and as a webloader.

TL;DR;

In CLI:

   npm i --save-dev resolve-unpkg
   resolve-unpkg path-to-optional-config.json

Webloader:

   import scripts from '!resolve-unpkg?unpkgPrefix=unpkg.com&versionPlaceholder=a.b.c&onlyByVersionPlaceholder=true!scripts.json';

Import

To add Resolve-Unpkg to the project, cd to the project root folder and run:

npm i --save-dev resolve-unpkg

This will add Resolve-Unpkg as a dependency to package.json enabling you to run the resolve-unpkg command manually and use resolve-unpkg as a webpack loader to resolve versions in unpkg URLs when they are imported from the JSON file.

Configuration

By default, Resolve-Unpkg processes URLs with unpkg.com prefix in the index.html file and replaces the x.x.x version placeholders with the actual version of the packages that are installed in your local environment.

To customize the default configuration, use the following options:

| Property | Type | Required | Description | CLI | Loader | | ---------------- | ---------- | :------: | ---------------------------------------- | :-: | :----: | | unpkgPrefix | string | No | The prefix of the unpkg URLs. Default: 'unpkg.com' | Yes | Yes | | versionPlaceholder| string | No | A version number placeholder to be replaced when occurs in the position of package version. Default: 'x.x.x' | Yes | Yes | | onlyByVersionPlaceholder | boolean | No | A flag that may limit the update to those URLs that contain the versionPlaceholder (e.g. x.x.x); when set to true, the exact package version numbers, like 1.9.1, are ignored. Default: true | Yes | Yes | | files | string[] | No | Path to file(s) to update/resolve URLs in. Default: ['index.html'] | Yes | No | | dist | string | No | Folder where the updated file(s) should be saved. Default: overwrite original | Yes | No |

Usage in CLI

With Resolve-Unpkg, you can automatically update the package versions that are mentioned in the unpkg URLs in some of your project files.

The package versions used are those installed in your local environment.

Before you begin, prepare the resolve-unpkg configuration file to override the default options if necessary. For example:

Sample Resolve-Unpkg configuration file

{
  "unpkgPrefix": "unpkg",
  "files": ["index.vm, index.ejs"],
  "dist": "dist/"
}

To update the unpkg links, run:

resolve-unpkg [optional-config.json]

As a result, the unpkg URLs in the provided files will be updated.

As an illustration to this process, let's consider the following file (index.html) :

<html>
    <head>
        <link rel="stylesheet" href="https://unpkg.com/[email protected]/spectrum.css">
    </head>
    <body>
        <script src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>
    </body>
</html>

If the version of the jquery installed in the local environment is '2.21', and spectrum-colorpicker is '1.6.1', and we run the resolve-unpkg with default configuration parameters, the original index.html file will be overwritten with this one:

<html>
    <head>
        <link rel="stylesheet" href="https://unpkg.com/[email protected]/spectrum.css">
    </head>
    <body>
        <script src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>
    </body>
</html>

Note that as the onlyByVersionPlaceholder is true by default, the older version for spectrum-colorpicker was not modified.

Usage in JS

For the unpkg links that are imported into your JS code from the JSON file, use resolve-unpkg loader to inject the updated versions into the URLs. To do so, update the import and provide the necessary values as parameters:

...
import scripts from '!resolve-unpkg?unpkgPrefix=unpkg.com&versionPlaceholder=a.b.c&onlyByVersionPlaceholder=true!scripts.json';
...

Testing

Make sure to test the new version since every time your links are updated you are getting code that has not yet run through your tests. So if for example you use resolve-unpkg in your build phase, you should have your code tested afterwards (e.g. in E2E tests).