This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Browserify JavaScript Bundler Cheat Sheet

An archival reference guide for Browserify, the classic CommonJS bundler for client-side JavaScript: CLI options, transforms, and programmatic usage.

· Published

[!NOTE] Browserify is an archival JavaScript module bundler that brought Node.js require() and CommonJS syntax to the browser. Modern web applications typically use Vite, esbuild, Rollup, or webpack.

CLI Usage

# Basic bundle compilation
browserify input.js -o output.js

# Apply transforms
browserify input.js -o bundle.js -t babelify

# Generate source maps for debugging
browserify input.js -o bundle.js --debug

# Generate standalone UMD bundle
browserify input.js -s MyLibrary -o bundle.js

# Exclude, ignore, or mark modules as external
browserify input.js -u react     # --exclude: omit file
browserify input.js -x react     # --external: reference from another bundle
browserify input.js -i react     # --ignore: stub file with empty module

Programmatic API

const browserify = require('browserify');
const fs = require('fs');

const b = browserify('src/main.js', { debug: true });

b.transform('babelify', { presets: ['@babel/preset-env'] });

b.bundle().pipe(fs.createWriteStream('dist/bundle.js'));

  • babelify: Transpiles modern ES6+ and JSX to browser-compatible ES5.
  • envify: Replaces process.env.NODE_ENV with string literals for dead-code elimination.
  • brfs: Inlines fs.readFileSync calls with static file contents at build time.
  • watchify: Incremental build watcher for high-speed rebuilds during development.

Related topics