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

@uppercut-labs/app-shell-service-worker

v1.0.0

Published

Generate an app-shell service worker script from options: precache list, navigation fallback, cache versioning and update behavior. Function and CLI.

Readme

@uppercut-labs/app-shell-service-worker

Generates the source of a service worker that precaches an app shell. The worker removes old caches when it activates, serves a cached page when a navigation cannot reach the network, caches other same-origin files, and leaves cross-origin, non-GET and bypassed requests to the browser. Use it as a function in a build script or as a command.

npm install --save-dev @uppercut-labs/app-shell-service-worker
import { writeFileSync } from 'node:fs';
import { generateServiceWorker } from '@uppercut-labs/app-shell-service-worker';

writeFileSync(
  'dist/sw.js',
  generateServiceWorker({
    cacheName: 'my-app',
    version: '12',
    precache: ['/', '/app.js', '/styles.css', '/manifest.webmanifest'],
    bypassPrefixes: ['/api/'],
    skipWaiting: 'message',
  }),
);

Command line:

npx app-shell-service-worker --cache-name my-app --version 12 \
  --precache /,/app.js,/styles.css --bypass-prefix /api/ --out dist/sw.js

The worker must be served from the origin root (or the scope you register it with), so write it into your public output folder.

generateServiceWorker(options)

Returns the script as a string. Throws ShellServiceWorkerError when an option is invalid.

| Option | Default | Meaning | | --- | --- | --- | | cacheName | required | Base name of the cache | | version | none | Appended as name-version; change it to ship a fresh shell | | precache | [] | URLs stored at install. If one fails, the install fails and the old worker stays | | navigationFallback | / | Cached page served when a navigation cannot reach the network | | navigationStrategy | network-first | network-first returns whatever the network answers, even a 404, and uses the cache only on a network error. cache-first serves the cached page first | | assetStrategy | cache-first | For other same-origin GET requests: cache-first, or network-first with cache fallback | | bypassPrefixes | [] | Paths starting with these are left to the browser, such as /api/ | | bypassAuthorized | true | Leave requests with an Authorization header to the browser | | navigationAllowlist | none | When set, only navigations to exactly these paths are handled | | ignoreSearch | true | Match cached responses without the query string | | runtimeCache | true | Store successful responses fetched at runtime | | runtimeDestinations | none | When set, store runtime responses only for these request destinations, such as script, style, image, font | | cleanup | prefix | On activate, delete other caches whose name starts with cleanupPrefix (prefix), or every other cache (all) | | cleanupPrefix | cacheName | Prefix used by cleanup: 'prefix' | | skipWaiting | immediate | immediate: take over as soon as installed. message: wait for the page to post { type: 'SKIP_WAITING' } |

When the network fails and nothing is cached, the worker answers 503 with the text Offline.

Command line

app-shell-service-worker [options] prints the script to standard output, or to --out <file>. Options can come from a JSON file with --config <file> using the same names as the function; flags override the file.

| Flag | Option | | --- | --- | | --cache-name, --version | cacheName, version | | --precache <url>[,<url>...] | precache (repeatable) | | --navigation-fallback, --navigation-strategy, --asset-strategy | the options of the same name | | --bypass-prefix <path> | bypassPrefixes (repeatable) | | --allow-navigation <path> | navigationAllowlist (repeatable) | | --runtime-destination <kind> | runtimeDestinations (repeatable) | | --cleanup, --cleanup-prefix, --skip-waiting | the options of the same name | | --no-ignore-search, --no-runtime-cache, --no-bypass-authorized | set that option to false |

Exit codes: 0 success, 1 invalid options or an unreadable config file, 2 unknown flag or missing value.

License

MIT