How to use the browserify/lib/builtins.js.dgram 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 feross / chrome-net / test / helper.js View on Github external
var once = require('once')
var path = require('path')

var CHROME
if (process.env.CHROME) {
  CHROME = process.env.CHROME
} else if (process.platform === 'win32') {
  CHROME = '"%ProgramFiles(x86)%\\Google\\Chrome\\Application\\chrome.exe"'
} else {
  CHROME = '/Applications/Google\\ Chrome\\ Canary.app/Contents/MacOS/Google\\ Chrome\\ Canary'
}

var BUNDLE_PATH = path.join(__dirname, 'chrome-app/bundle.js')

builtins.net = require.resolve('../')
builtins.dgram = require.resolve('chrome-dgram')
builtins['function-bind'] = require.resolve('./function-bind.js')

exports.browserify = function (filename, env, cb) {
  if (!env) env = {}
  if (!cb) cb = function () {}
  cb = once(cb)

  var b = browserify()
  b.add(path.join(__dirname, 'client', filename))
  b.transform(envify(env))

  b.bundle()
    .pipe(fs.createWriteStream(BUNDLE_PATH))
    .on('close', cb)
    .on('error', cb)
}