How to use the browserify.bundle function in browserify

To help you get started, we’ve selected a few browserify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vespakoen / extendscriptkit-boilerplate / scripts / actions.js View on Github external
function bundleJs() {
  // start the build process for index.js (for ES6/7 support in CEF)
  require('browserify')(jsEntry, {
    debug: false,
    plugin: [
      [require('prependify'), 'nodeRequire = require;']
    ]
  })
  .bundle(function (err, bundle) {
    if (err) {
      console.error(err.stack)
      return
    }
    fs.writeFileSync(jsBundle, bundle)
    const result = uglifyJS.minify([jsBundle])
    fs.writeFileSync(jsBundle, result.code)
  })
}
github browserify / browserify / test / modules.js View on Github external
exports.precedence = function () {
    var src = browserify.bundle({
        base : __dirname + '/modules/precedence',
        require : [ 'hashish', 'traverse' ],
    });
    
    var c = { console : console };
    vm.runInNewContext(src, c);
    assert.ok(c.require.modules['hashish/package.json']);
    assert.deepEqual(
        c.require.modules['hashish/index.js']().map(
            { a : 1, b :2 }, function (x) { return x * 100 }
        ),
        { a : 100, b : 200 }
    );
    assert.ok(c.require.modules['./node_modules/hashish/index.js']);
    assert.notEqual(
        c.require.modules['hashish/index.js'](),
github browserify / browserify / test / walk.js View on Github external
exports.walk = function () {
    var src = browserify.bundle(__dirname + '/walk');
    var context = {};
    
    vm.runInNewContext(src, context);
    
    var a_ = context.require('a');
    var b_ = context.require('b');
    var c_ = context.require('c');
    
    assert.throws(function () {
        context.require('d');
    });
    
    assert.throws(function () {
        context.require('e');
    });
github browserify / browserify / test / single_file.js View on Github external
exports.single_file = function () {
    var src = browserify.bundle({
        require : 'jade/lib/lexer.js'
    });
    assert.ok(typeof src === 'string');
    assert.ok(src.length > 0);
    
    var c = {};
    vm.runInNewContext(src, c);
    var lex = vm.runInNewContext(
        'var Lexer = require("jade/lib/lexer"); Lexer', c
    );
    assert.eql(
        Object.keys(Lexer),
        Object.keys(lex)
    );
};
github browserify / browserify / test / modules.js View on Github external
exports.modules = function () {
    var src = browserify.bundle({
        base : {
            'foomoduletest' : __dirname + '/modules/foomoduletest'
        },
    });
    
    assert.ok(typeof src === 'string');
    assert.ok(src.length > 0);
    
    var c = {};
    vm.runInNewContext(src, c);
    assert.eql(c.require('foomoduletest').bar, 55)
};
github browserify / browserify / test / names.js View on Github external
exports.named = function () {
    var src = browserify.bundle({
        base : { names : __dirname + '/names' }
    });
    
    var c = {};
    vm.runInNewContext(src, c);
    
    assert.eql(c.require('names').names, {
        __dirname : 'names',
        __filename : 'names/index.js',
    });
};
github browserify / browserify / test / base.js View on Github external
exports.stringBase = function () {
    var src = browserify.bundle(__dirname + '/base/string');
    
    var c = { console : console };
    vm.runInNewContext(src, c);
    assert.equal(c.require('./')(3), 13000);
};
github browserify / browserify / test / req.js View on Github external
exports.objectRequire = function () {
    var src = browserify.bundle({
        require : { 'doom' : 'hashish' },
    });
    
    var c = {};
    vm.runInNewContext(src, c);
    verifyHashish(c.require('doom'))
    assert.ok(c.require.modules['doom/package.json']);
    assert.ok(!c.require.modules['hashish/package.json']);
};