Socket
Socket
Sign inDemoInstall

browserify

Package Overview
Dependencies
Maintainers
0
Versions
484
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify

Browser-side require() for js directories and npm modules


Version published
Weekly downloads
1.5M
increased by3.79%
Maintainers
0
Weekly downloads
 
Created

What is browserify?

Browserify is a tool for Node.js that enables developers to use the require() function from Node in the browser. It bundles up all of your JavaScript files and dependencies into a single file that can be served to the browser. It allows for modular code in the client-side environment by leveraging the CommonJS module pattern.

What are browserify's main functionalities?

Bundle modules for the browser

This feature allows you to bundle all your JavaScript files and dependencies into a single file. The code sample demonstrates how to create a bundle starting with 'main.js' and output it to 'bundle.js'.

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

let b = browserify();
b.add('main.js');
b.bundle().pipe(fs.createWriteStream('bundle.js'));

Transformations

Browserify can apply transformations to the files as they are added to the bundle. This is useful for tasks like compiling ES6 syntax to ES5 using Babel, as shown in the code sample.

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

browserify('./src/app.js')
  .transform(babelify, { presets: ['@babel/preset-env'] })
  .bundle()
  .pipe(process.stdout);

Plugins

Browserify can be extended with plugins that can add additional functionality. In the code sample, the watchify plugin is used to automatically re-bundle the file whenever changes are detected.

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

const b = browserify('./src/app.js', { plugin: [watchify] });
b.on('update', bundle);
function bundle() {
  b.bundle().pipe(fs.createWriteStream('bundle.js'));
}

Other packages similar to browserify

Keywords

FAQs

Package last updated on 22 Jun 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc