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

watchify-server

v1.0.2

Published

a bare-bones development server for watchify

Downloads

22

Readme

watchify-server

stable

This is a bare-bones development server for watchify. For a more feature-rich development server built on the same underlying modules, see budo.

Features at a glance:

  • serves a default HTML index
  • browserifies your entry file with incremental rebuilding
  • serves your static files on port 9966 or the next available port
  • suspends server response until the build is finished, so you are never served a stale or empty bundle
  • logs build timing to stdout with ndjson
  • build errors will be printed to the browser console by default

Install

npm install watchify-server [-g|--save]

Example

Example with CLI:

watchify-server index.js --port 8000 --dir public/

It might look like this with npm scripts and garnish for pretty-printing:

  "devDependencies": {
    "watchify-server": "^1.0.0",
    "garnish": "^2.3.0"
  },
  "scripts": {
    "start": "watchify-server src/app.js --port 8000 --dir public | garnish"
  }

Usage

NPM

Typically this module is used via a CLI, but it also exposes a simple JavaScript API.

CLI

Usage:
  watchify-server entry.js [options] -- [browserify]

Options:
  --port, -p          port to listen on, default 9966
  --host, -h          host to listen on, default localhost
  --dir, -d           directory for static content, default process.cwd()
  --no-debug          turns off source maps
  --no-error-handler  turns off syntax error handling
  --index             optional file path to override default index.html
  --title             title of HTML index
  --css, -s           optional style sheet href, relative to --dir

Browserify options are passed after the -- full stop.

The --title and --css arguments are only applicable to the default index.html handler.

API

Note: The API does not set any default config on the browserify instance, so it is up to the developer to set debug, packageCache, and cache.

server = watchifyServer(browserify, opt, [cb])

Creates a new watchify server that wraps the specified browserify instance. Options:

  • entry (required) the path to the entry file to browserify
  • silent set to true to disable logs

Other options are passed to watchify-middleware and serves, but defaults port to 9966 and errorHandler to true.

The returned server emits 'update' events from watchify-middleware.

The callback takes the form callback(err, ev) with the following event parameters when the server starts listening:

{
  url: String  // 'http://localhost:8080/' 
  port: Number // 8080 
  host: String // 'localhost' 
}

server = watchifyServer.fromArgs(browserifyArgs, [opt], [cb])

Creates a new watchify server from the given command-line browserify args array, with optional opt overrides and a callback.

The entry is resolved by browserify arg parsing, so opt is optional and cb can be passed as the second parameter.

See Also

  • budo - a more feature-rich development server (live reload, browser launching, better error reporting, etc)
  • watchify-middleware - the underlying middleware for pending server requests
  • serves - the underlying server utility for this tool
  • simple-html-index - the default HTML index used in this tool
  • inject-lr-script - may be useful for injecting LiveReload into the index handler

License

MIT, see LICENSE.md for details.