Bundle

Bundle files into a single file using browserify.

Usage

var bundle = require( '@stdlib/_tools/browserify/file-list' );

bundle( files, [dest,] clbk )

Bundles files into a single file using browserify.

var files = [
    '/foo/bar.js',
    '/beep/boop.js'
];

bundle( files, clbk );

function clbk( error, bundle ) {
    if ( error ) {
        throw error;
    }
    console.log( bundle.toString() );
}

To specify an output file path, provide a dest argument.

var files = [
    '/foo/bar.js',
    '/beep/boop.js'
];

bundle( files, './bundle.js', clbk );

function clbk( error ) {
    if ( error ) {
        throw error;
    }
}

Notes

  • When generating a bundle, the function inlines environment variables and adds support for using proxyquire in browser environments.

Examples

var join = require( 'path' ).join;
var bundle = require( '@stdlib/_tools/browserify/file-list' );

var fpath = join( __dirname, 'fixtures', 'index.js' );
var files = [ fpath ];

bundle( files, onBundle );

function onBundle( error, output ) {
    if ( error ) {
        throw error;
    }
    console.log( output.toString() );
}

CLI

Usage

Usage: browserify-file-list [options] <file1> <file2> ...

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.

Examples

$ browserify-file-list ./examples/fixtures/index.js