The ability to use CommonJS style modules in your browser code is a great. It allows you to cleanly create modules, require them in to your code as needed, and have all of your app in one file for the browser to use. With the use of the “–debug” command line option, you can also get source maps for easy debugging. But what about re-bundling files during development? It gets to be tedious and annoying when you have to constantly switch back to the command line and re-run the browserify command line.
Fortunately, browserify has with a simple solution to this problem: watchify.
The watchify command line takes the same basic parameters as the browserify command line. But in addition to bundling your code once, it will watch for file system changes and re-bundle your code automatically. In this episode, you'll see how to use watchify with browserify, to automate the bundle step for your development environment, reducing the amount of manual effort that it takes to get your application ready for your browser.