How to use insert-module-globals - 10 common examples

To help you get started, we’ve selected a few insert-module-globals 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 browserify / browserify / bin / args.js View on Github external
.filter(Boolean).map(function (entry) {
        if (entry === '-') {
            var s = process.stdin;
            if (typeof s.read === 'function') return s;
            // only needed for 0.8, remove at some point later:
            var rs = Readable().wrap(s);
            s.resume();
            return rs;
        }
        return entry;
    });

    if (argv.igv) {
        var insertGlobalVars = {};
        var wantedGlobalVars = argv.igv.split(',');
        Object.keys(insertGlobals.vars).forEach(function (x) {
            if (wantedGlobalVars.indexOf(x) === -1) {
                insertGlobalVars[x] = undefined;
            }
        });
    }
    
    var ignoreTransform = argv['ignore-transform'] || argv.it;
    var b = browserify(xtend({
        node: argv.node,
        bare: argv.bare,
        noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse],
        extensions: [].concat(argv.extension).filter(Boolean).map(function (extension) {
            if (extension.charAt(0) != '.') { 
                return '.' + extension;
            } else {
                return extension
github nexe / nexe / lib / bundle.js View on Github external
function bundle(input, nc, options, complete) {
  const bundlePath = path.join(nc, "lib", "nexe.js");
  const mapfile    = options.output+'.map';
  let ws           = fs.createWriteStream(bundlePath);


  const igv = '__filename,__dirname,_process';
  let insertGlobalVars = {},
      wantedGlobalVars = igv.split(',');

  // parse insertGlobalVars.
  Object.keys(insertGlobals.vars).forEach(function (x) {
    if (wantedGlobalVars.indexOf(x) === -1) {
      insertGlobalVars[x] = undefined;
    }
  });

  let paths = [path.join(nc, 'lib')];

  if(options.browserifyPaths) {
    paths = paths.concat(options.browserifyPaths);
  }


  _log('executing browserify via API');
  let bproc = browserify([input], {
    debug: options.debug,
    commondir: false,
github hellojixian / node-compiler / lib / bundle.js View on Github external
function bundle(input, nc, options, complete) {
  const bundlePath = path.join(nc, "lib", "compiled.js");
  const mapfile    = options.output+'.map';
  let ws           = fs.createWriteStream(bundlePath);


  const igv = '__filename,__dirname,_process';
  let insertGlobalVars = {},
      wantedGlobalVars = igv.split(',');

  // parse insertGlobalVars.
  Object.keys(insertGlobals.vars).forEach(function (x) {
    if (wantedGlobalVars.indexOf(x) === -1) {
      insertGlobalVars[x] = undefined;
    }
  });

  let paths = [path.join(nc, 'lib')];

  if(options.browserifyPaths) {
    paths = paths.concat(options.browserifyPaths);
  }


  _log('executing browserify via API');
  let bproc = browserify([input], {
    debug: options.debug,
    commondir: false,
github aredotna / ervell / node_modules / browserify / bin / args.js View on Github external
if (argv.node) {
        argv.bare = true;
        argv.browserField = false;
    }
    if (argv.bare) {
        argv.builtins = false;
        argv.commondir = false;
        if (argv.igv === undefined) {
            argv.igv = '__filename,__dirname';
        }
    }
    
    if (argv.igv) {
        var insertGlobalVars = {};
        var wantedGlobalVars = argv.igv.split(',');
        Object.keys(insertGlobals.vars).forEach(function (x) {
            if (wantedGlobalVars.indexOf(x) === -1) {
                insertGlobalVars[x] = undefined;
            }
        });
    }
    
    var ignoreTransform = argv['ignore-transform'] || argv.it;
    var b = browserify(xtend({
        noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse],
        extensions: [].concat(argv.extension).filter(Boolean).map(function (extension) {
            if (extension.charAt(0) != '.') { 
                return '.' + extension;
            } else {
                return extension
            }
        }),
github oceanofthelost / InteractiveBOM / GUI / node_modules / browserify / index.js View on Github external
if (typeof files === 'string' || isArray(files) || isStream(files)) {
        opts = xtend(opts, { entries: [].concat(opts.entries || [], files) });
    }
    else opts = xtend(files, opts);

    if (opts.node) {
        opts.bare = true;
        opts.browserField = false;
    }
    if (opts.bare) {
        opts.builtins = false;
        opts.commondir = false;
        if (opts.insertGlobalVars === undefined) {
            opts.insertGlobalVars = {}
            Object.keys(insertGlobals.vars).forEach(function (name) {
                if (name !== '__dirname' && name !== '__filename') {
                    opts.insertGlobalVars[name] = undefined;
                }
            })
        }
    }
    
    self._options = opts;
    if (opts.noparse) opts.noParse = opts.noparse;
    
    if (opts.basedir !== undefined && typeof opts.basedir !== 'string') {
        throw new Error('opts.basedir must be either undefined or a string.');
    }

    opts.dedupe = opts.dedupe === false ? false : true;
github aws / aws-sdk-js / dist-tools / browser-builder.js View on Github external
function build(options, callback) {
  if (arguments.length === 1) {
    callback = options;
    options = {};
  }

  var img = require('insert-module-globals');
  img.vars.process = function() { return '{browser:true}'; };

  if (options.services) process.env.AWS_SERVICES = options.services;

  var browserify = require('browserify');
  var brOpts = { basedir: path.resolve(__dirname, '..') };
  browserify(brOpts).add('./').ignore('domain').bundle(function(err, data) {
    if (err) return callback(err);

    var code = (data || '').toString();
    if (options.minify) code = minify(code);

    code = license + code;
    callback(null, code);
  });
}
github awslabs / aws-api-gateway-developer-portal / lambdas / backend / meteringservice-preview-sdk-js-06-23-2016 / dist-tools / browser-builder.js View on Github external
function build(options, callback) {
  if (arguments.length === 1) {
    callback = options;
    options = {};
  }

  var img = require('insert-module-globals');
  img.vars.process = function() { return '{browser:true}'; };

  if (options.services) process.env.AWS_SERVICES = options.services;

  var browserify = require('browserify');
  var brOpts = { basedir: path.resolve(__dirname, '..') };
  browserify(brOpts).add('./').ignore('domain').bundle(function(err, data) {
    if (err) return callback(err);

    var code = (data || '').toString();
    if (options.minify) code = minify(code);
    else code = stripComments(code);

    code = license + code;
    callback(null, code);
  });
}
github splunk / splunk-sdk-javascript / node_modules / browserify / index.js View on Github external
if (typeof files === 'string' || isArray(files) || isStream(files)) {
        opts = xtend(opts, { entries: [].concat(opts.entries || [], files) });
    }
    else opts = xtend(files, opts);

    if (opts.node) {
        opts.bare = true;
        opts.browserField = false;
    }
    if (opts.bare) {
        opts.builtins = false;
        opts.commondir = false;
        if (opts.insertGlobalVars === undefined) {
            opts.insertGlobalVars = {}
            Object.keys(insertGlobals.vars).forEach(function (name) {
                if (name !== '__dirname' && name !== '__filename') {
                    opts.insertGlobalVars[name] = undefined;
                }
            })
        }
    }
    
    self._options = opts;
    if (opts.noparse) opts.noParse = opts.noparse;
    
    if (opts.basedir !== undefined && typeof opts.basedir !== 'string') {
        throw new Error('opts.basedir must be either undefined or a string.');
    }

    opts.dedupe = opts.dedupe === false ? false : true;
github browserify / browserify / index.js View on Github external
if (typeof files === 'string' || isArray(files) || isStream(files)) {
        opts = xtend(opts, { entries: [].concat(opts.entries || [], files) });
    }
    else opts = xtend(files, opts);

    if (opts.node) {
        opts.bare = true;
        opts.browserField = false;
    }
    if (opts.bare) {
        opts.builtins = false;
        opts.commondir = false;
        if (opts.insertGlobalVars === undefined) {
            opts.insertGlobalVars = {}
            Object.keys(insertGlobals.vars).forEach(function (name) {
                if (name !== '__dirname' && name !== '__filename') {
                    opts.insertGlobalVars[name] = undefined;
                }
            })
        }
    }
    
    self._options = opts;
    if (opts.noparse) opts.noParse = opts.noparse;
    
    if (opts.basedir !== undefined && typeof opts.basedir !== 'string') {
        throw new Error('opts.basedir must be either undefined or a string.');
    }

    opts.dedupe = opts.dedupe === false ? false : true;
github publiclab / leaflet-environmental-layers / node_modules / browserify / index.js View on Github external
if (typeof files === 'string' || isArray(files) || isStream(files)) {
        opts = xtend(opts, { entries: [].concat(opts.entries || [], files) });
    }
    else opts = xtend(files, opts);

    if (opts.node) {
        opts.bare = true;
        opts.browserField = false;
    }
    if (opts.bare) {
        opts.builtins = false;
        opts.commondir = false;
        if (opts.insertGlobalVars === undefined) {
            opts.insertGlobalVars = {}
            Object.keys(insertGlobals.vars).forEach(function (name) {
                if (name !== '__dirname' && name !== '__filename') {
                    opts.insertGlobalVars[name] = undefined;
                }
            })
        }
    }
    
    self._options = opts;
    if (opts.noparse) opts.noParse = opts.noparse;
    
    if (opts.basedir !== undefined && typeof opts.basedir !== 'string') {
        throw new Error('opts.basedir must be either undefined or a string.');
    }

    opts.dedupe = opts.dedupe === false ? false : true;

insert-module-globals

insert implicit module globals into a module-deps stream

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis

Popular insert-module-globals functions