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

glov-build-cache

v1.1.0

Published

Git-commit-able caching wrapper for slow build tasks

Downloads

74

Readme

Git-commit-able caching wrapper for slow glov-build tasks

Though glov-build is already highly cached and only reprocesses exactly the files needed to be reprocessed on your machine, some tasks (such as imagemin) are so slow that you do not want to have to run them even once on a new developer's machine, or on a build system (which may be unable to take advantage of a local cache between runs).

This task wrapper is for caching single-input tasks such as image minification or other image postprocessing. Tasks that output multiple outputs (such as a .wav -> .ogg + .mp3 conversion task) are also supported, as long as they are of type gb.SINGLE.

API usage:

const gbcache = require('glov-build-cache');

gb.task({
  name: 'name',
  input: '*.png',
  ...gbcache({
    key: 'cache-key',
    version: 1,
    cache_root: './.gbcache',
    do_cache_write: false,
    do_cache_rebuild: false,
  }, {
    // actual task definition here
    type: gb.SINGLE,
    func: doSomething,
  },
});

Options

  • key - required cache key
  • version - required cache version - This must be manually incremented when your task's version changes. The automatic hashing of task functions to detect version changes is unstable across Node.js version and platforms, so cannot be used lest the cache be invalid on any installation other than the one that generated it.
  • cache_root - optional root folder for caching, defaults to gb.getSourceRoot()/../.gbcache/
  • do_cache_write optional boolean to enable writing to the cache after every task run, defaults to false unless --cache-write is passed on the command line. This is generally not recommended unless you want developers to always commit and updated cache folder with each commit that changes one of the sources (which has increases the chance of meaningless merge conflicts, etc).
  • do_cache_rebuild optional boolean to enable pruning and rebuilding the cache during the first task run, defaults to false unless --cache-rebuild is passed on the command line. This should be done only periodically when the cache is significantly out of date and needs to be updated and committed to source control.

Example usage in build script:

const imagemin = require('glov-build-imagemin');
const imageminOptipng = require('imagemin-optipng');

const gbcache = require('glov-build-cache');

gb.task({
  name: 'imagemin',
  input: '*.png',
  ...gbcache({
    key: 'imagemin',
    version: 1,
  }, imagemin({
    plugins: [
      imageminOptipng(),
    ],
  })),
});

Example occasional workflow to update cache for the rest of your team or build systems, etc:

node build imagemin --cache-rebuild
git add .
git commit -m "update build cache"