{"id":18178,"library":"browserify-dev-bundler","title":"browserify-dev-bundler","description":"On-demand browserify bundler middleware for development with watchify support. Version 2.0.0 is the latest stable release, with low release cadence (last release in 2016). It dynamically bundles CommonJS modules via HTTP requests, caching bundles with watchify for fast responses during development. Unlike manual watchify tasks or file-based bundling, it integrates directly as Express middleware, intercepting *.js requests and bundling on the fly. Not suitable for production—use browserify build process instead. Works with Node.js and Express.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/selfcontained/browserify-dev-bundler","tags":["javascript","browserify","watchify","bundler","middleware","on demand","development"],"install":[{"cmd":"npm install browserify-dev-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add browserify-dev-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add browserify-dev-bundler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core bundler dependency for transforming CommonJS modules into browser-compatible bundles","package":"browserify","optional":false},{"reason":"Required for caching and automatic re-bundling on file changes during development","package":"watchify","optional":false}],"imports":[{"note":"CJS-only package; no ESM exports. Default export is the constructor.","wrong":"import DevBundler from 'browserify-dev-bundler';","symbol":"DevBundler","correct":"const DevBundler = require('browserify-dev-bundler');"},{"note":"middleware() returns a function; must be called on a DevBundler instance.","wrong":"app.use(DevBundler.middleware);","symbol":"middleware","correct":"app.use(bundler.middleware());"},{"note":"Uses Node.js EventEmitter pattern; .on() not addEventListener.","wrong":"bundler.addEventListener('pre-bundle', ...);","symbol":"events","correct":"bundler.on('pre-bundle', (bundle, modName, modPath) => {});"}],"quickstart":{"code":"const express = require('express');\nconst DevBundler = require('browserify-dev-bundler');\nconst path = require('path');\n\nconst app = express();\nconst bundler = DevBundler({\n  root: path.join(__dirname, 'public', 'js'),\n  watchify: true,\n  debug: true,\n  transforms: []\n});\n\napp.use(bundler.middleware());\napp.listen(3000, () => console.log('Dev server on 3000'));\n\n// Request GET /app.js => bundles public/js/app.js","lang":"javascript","description":"Sets up an Express server with on-demand browserify bundling using the middleware."},"warnings":[{"fix":"Use a regex pattern to restrict which URLs are bundled: e.g., bundler.middleware(/^\\/js\\/(.+)\\.js$/).","message":"Middleware matches all *.js files by default; may unintentionally bundle non-module JS files or cause conflicts with static file serving.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set watchify: false if you don't need auto-rebundling, or manually manage watchify instances.","message":"watchify is enabled by default, which may cause high memory usage in large projects or when many files change.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Update regex patterns if you relied on older defaults; use bundler.middleware(/^\\/js\\/(.+)\\.js$/) to restrict paths.","message":"Version 2.0.0 changed the default middleware behavior to intercept all *.js; previous versions used a different default pattern.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure addFile function uses bundle.require() with expose option for modules that need to be requireable by other bundles.","message":"addFile option overrides default bundle.add(); using bundle.require() without expose can cause double bundling or missing dependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always attach a listener to 'bundle-error' event: bundler.on('bundle-error', err => console.error(err)).","message":"bundle-error event does not prevent crashes; unhandled errors may crash the server.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install browserify watchify --save-dev","cause":"Missing peer dependency browserify; not automatically installed with npm install.","error":"Cannot find module 'browserify'"},{"fix":"Use: const bundler = new DevBundler(options); or simply DevBundler(options) (works without new due to internal check).","cause":"Forgetting to instantiate DevBundler with new; calling DevBundler() without new returns a constructor, not an instance.","error":"bundler.middleware is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}