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

uber-watchify

v3.6.0

Published

watchify, with some bonus features. [email protected]

Downloads

297

Readme

uber-watchify

watchify, with some bonus features.

watchify does some great stuff. uber-watchify takes it one step further. For big bundles, with lots of transforms, the bundling takes a long time (with jQuery and tranforms we are talking around 30 seconds). If you have incorporated watchify into your build system, and have it run on every start up, this can be costly. Watchify already uses browserify's internal cache, but it only does so in memory. uber-watchify attempts to solve this problem by persisting the cache to disk.

additions

  1. Load/Write a cache file

accept a new option to load/write a pre-existing cache file, namely, cacheFile. Therefore, first builds run off the cache, as well as subsequent ones. Provide a method w.write(), which at the user's discretion, will write out the cache to disk.

  1. Add an explicit watch option

original watchify always watches. If you don't want to write a separate task, and also use uber-watchify for just regular build commands, you can turn off the watching so the process exits.

  1. If nothing changed, do nothing.

If you start a build, kill the process, and restart it while nothing in browserify has changed, don't do anything. w.bundle() will now check all the modification times of the files you are bundling. If nothing has changed, w.bundle() will simply return null.

example

var cacheFile = path.resolve(__dirname, 'browserify/benbria.cache.json');
var w = watchify(browserify({
    cache: watchify.getCache(cacheFile),
    packageCache: {},
    fullPaths: true,
    entries: [path.resolve(__dirname, 'browserify/benbria.coffee')],
    extensions: ['.js']
}), {
    cacheFile: cacheFile
});

then to watch:

var bundle = function() {
    var stream = w.bundle();
    if (!stream) {
        return;
    }
    stream
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('browserify'))
    .on('end', function() {
        w.write();
    });
};
w.on('update', bundle);
bundle();

new api changes

option cacheFile

A full path to the cache file you wish to save to. It will be created if it doesn't exist

option watch

Whether to setup watch listeners. Defaults to true

method watchify.getCache(file)

convenience method to load a json cache file, and if it doesn't exist will give you a blank object. Pass this to browserify's cache option.

method w.write()

write out the cache to the specified cacheFile. Generally you do this once your transform stream gets its end event.

api w.bundle([cb])

same as before, but will now return null if the cache is still valid. (a new cache is invalid)

new cli options

--cache-file or -cf

A full path to the cache file you wish to save to. It will be created if it doesn't exist

--no-watch or -n

Whether to setup watch listeners. Defaults to true

example

>uber-watchify main.js --no-watch --cache-file main.browserify.cache.json -o bundle.js

license

MIT