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 🙏

© 2024 – Pkg Stats / Ryan Hefner

steal-serviceworker

v1.0.0

Published

A steal-tool plugin for creating a serviceworker

Downloads

4

Readme

steal-serviceworker

Join the chat at https://gitter.im/canjs/canjs License: MIT npm version Coverage Status Travis build status Greenkeeper badge

steal-serviceworker helps you to create a service worker for your app that’s built with steal-tools.

Usage

build.js

const stealTools = require("steal-tools");
const precache = require("steal-serviceworker");


stealTools.build({
    config: __dirname + "/basics/package.json!npm"
}).then(function(buildResult){
    
   precache(buildResult);
   
});

index.html

<script src="/dist/steal.production.js"></script>

It's that easy?

API

precache(bundleResult, [options]) => Promise

precache does two things for you:

  • Generates a service worker that contains all the files that steal-tools bundles into the dest folder
  • Creates a basic service worker registration. precache can put this code into its own file or prepend the code into steal.production.js for you.

buildResult

The BuildResult obtained from calling stealTools.build.

options

An optional object for specifying additional options. They are:

bundleRegistration [boolean]

Write the service worker registration template into steal.production.js or not. If false the registration code gets written into a file named service-worker-registration.js into the dest folder. You have to include the registration script yourself <script src="/dist/service-worker-registration.js"></script>

Default: false

cacheRegistration [boolean]

Defines if the service worker registration code is cached by the service worker as well. This option only make sense if bundleRegistration is false.

filename [string]

The name of the service worker file.

Default: service-worker.js

registrationTemplate [string]

You can use your own registration for the service worker. E.g. you can handle the state of the service worker and can implement your own custom behaviors if the content of the cache changed.

Default: path.join(__dirname, "service-worker-registration.tmpl")

all options provided by Google’s sw-precache

like

precache(buildResult, {
    staticFileGlobs: [
        path.join(__dirname, "dist", '**', '*.*'),
        path.join(__dirname, "src", "styles.css")
    ],
    runtimeCaching: [{
        urlPattern: "/",
        handler: "networkFirst"
    }]
});

Changelog

See the latest releases on GitHub.

License

MIT