(files, opts)
| 37 | }; |
| 38 | |
| 39 | function Browserify (files, opts) { |
| 40 | var self = this; |
| 41 | if (!(this instanceof Browserify)) return new Browserify(files, opts); |
| 42 | if (!opts) opts = {}; |
| 43 | |
| 44 | if (typeof files === 'string' || isArray(files) || isStream(files)) { |
| 45 | opts = xtend(opts, { entries: [].concat(opts.entries || [], files) }); |
| 46 | } |
| 47 | else opts = xtend(files, opts); |
| 48 | |
| 49 | if (opts.node) { |
| 50 | opts.bare = true; |
| 51 | opts.browserField = false; |
| 52 | } |
| 53 | if (opts.bare) { |
| 54 | opts.builtins = false; |
| 55 | opts.commondir = false; |
| 56 | if (opts.insertGlobalVars === undefined) { |
| 57 | opts.insertGlobalVars = {} |
| 58 | Object.keys(insertGlobals.vars).forEach(function (name) { |
| 59 | if (name !== '__dirname' && name !== '__filename') { |
| 60 | opts.insertGlobalVars[name] = undefined; |
| 61 | } |
| 62 | }) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | self._options = opts; |
| 67 | if (opts.noparse) opts.noParse = opts.noparse; |
| 68 | |
| 69 | if (opts.basedir !== undefined && typeof opts.basedir !== 'string') { |
| 70 | throw new Error('opts.basedir must be either undefined or a string.'); |
| 71 | } |
| 72 | |
| 73 | opts.dedupe = opts.dedupe === false ? false : true; |
| 74 | |
| 75 | self._external = []; |
| 76 | self._exclude = []; |
| 77 | self._ignore = []; |
| 78 | self._expose = {}; |
| 79 | self._hashes = {}; |
| 80 | self._pending = 0; |
| 81 | self._transformOrder = 0; |
| 82 | self._transformPending = 0; |
| 83 | self._transforms = []; |
| 84 | self._entryOrder = 0; |
| 85 | self._ticked = false; |
| 86 | |
| 87 | var browserField = opts.browserField |
| 88 | self._bresolve = browserField === false |
| 89 | ? function (id, opts, cb) { |
| 90 | if (!opts.basedir) opts.basedir = path.dirname(opts.filename) |
| 91 | resolve(id, opts, cb) |
| 92 | } |
| 93 | : typeof browserField === 'string' |
| 94 | ? function (id, opts, cb) { |
| 95 | opts.browser = browserField |
| 96 | bresolve(id, opts, cb) |
nothing calls this directly
no test coverage detected
searching dependent graphs…