Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 7, 2026·3 min de lecture

Browserify — Use Node.js require() in the Browser

A tool that bundles Node.js-style modules for the browser, enabling developers to use require() and npm packages in client-side JavaScript.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Browserify Overview
Commande d'installation directe
npx -y tokrepo@latest install 7493126d-7a00-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Browserify brought Node.js-style CommonJS modules to the browser by recursively analyzing require() calls and bundling all dependencies into a single file. It was the first widely adopted JavaScript module bundler and proved that npm packages could power front-end applications.

What Browserify Does

  • Recursively resolves require() calls and bundles them into one browser-ready file
  • Shims Node.js built-in modules (path, events, stream, buffer) for browser use
  • Supports source maps for debugging bundled code
  • Applies code transforms (Babel, CoffeeScript, envify) via a plugin pipeline
  • Generates standalone UMD bundles for library distribution

Architecture Overview

Browserify starts from an entry file, parses its AST to find require() calls, recursively resolves each dependency from node_modules or relative paths, and concatenates everything into a single output file wrapped in a lightweight module loader. The transform system intercepts files before parsing, allowing transpilation and preprocessing.

Self-Hosting & Configuration

  • Install globally or as a dev dependency for CLI or API usage
  • Configure transforms and plugins in the browserify field of package.json
  • Use watchify for incremental rebuilds during development
  • Generate standalone bundles with --standalone for library distribution
  • Pair with minifiers like uglifyify (transform) or UglifyJS (post-bundle)

Key Features

  • First-class CommonJS require() support matching Node.js semantics
  • Shims for Node.js core modules enabling isomorphic code
  • Transform pipeline for preprocessing files before bundling
  • Plugin system for custom output handling and build orchestration
  • Incremental builds via watchify for fast development feedback

Comparison with Similar Tools

  • webpack — More feature-rich bundler with code splitting, loaders, and built-in optimization; became the dominant bundler after Browserify
  • Rollup — Focuses on ES modules with tree shaking for smaller library bundles
  • esbuild — Extremely fast bundler written in Go; supports both ESM and CommonJS
  • Vite — Dev server with native ESM support and Rollup-based production builds; the current default for many frameworks

FAQ

Q: Is Browserify still relevant? A: Browserify is in maintenance mode. Modern projects typically use webpack, Vite, or esbuild, but Browserify remains functional for existing projects and educational purposes.

Q: How does Browserify differ from webpack? A: Browserify focuses on CommonJS bundling with a Unix-philosophy pipeline of small transforms. webpack provides a broader feature set including code splitting, asset handling, and hot module replacement.

Q: Can Browserify handle ES modules? A: Not natively. You can use the esmify transform to convert ES module syntax to CommonJS before bundling.

Q: What is watchify? A: watchify is a companion tool that watches source files and incrementally rebuilds only changed modules, providing fast rebuild times during development.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires