How to use the browserify/node_modules/insert-module-globals.vars 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 aws / aws-sdk-js / dist-tools / strategies / default.js View on Github external
DefaultStrategy.prototype.getCore = function(callback) {
  var img = require('browserify/node_modules/insert-module-globals');
  img.vars.process = function() { return '{browser:true}'; };

  var browserify = require('browserify');
  var opts = { basedir: this.libPath };
  browserify(opts).add('./lib/browser').
      ignore('domain').bundle(function (err, data) {
    if (err) return callback(err);

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

    code = this.license + code;
    if (this.isCached) {
      fs.writeFileSync(this.builder.cachePath('_core'), code);
    }