UNPKG

requisite

Version:

A cosmic javascript bundler.

60 lines (54 loc) 1.31 kB
// Generated by CoffeeScript 1.7.1 var Module, Prelude, path; path = require('path'); Module = require('./module'); Prelude = require('./wrapper').Prelude; module.exports = function(opts, cb) { var main, _ref, _ref1; if (opts == null) { opts = {}; } if (cb == null) { cb = function() {}; } if (typeof opts === 'function') { _ref = [opts, {}], cb = _ref[0], opts = _ref[1]; } main = new Module(opts.entry, { bare: opts.bare, basePath: opts.src, exclude: opts.exclude, "export": opts["export"], include: opts.include, paths: (_ref1 = opts.paths) != null ? _ref1 : [], requireAs: path.basename(opts.entry), strict: opts.strict, urlRoot: opts.urlRoot }); return main.parse(function(err) { var async, k, v, wrapper, _ref2; if (err != null) { return cb(err); } async = false; _ref2 = main.moduleCache; for (k in _ref2) { v = _ref2[k]; if (v.async) { async = true; break; } } if (!opts.bare) { wrapper = new Prelude({ async: async, globalRequire: opts.globalRequire, prelude: opts.prelude, preludeAsync: opts.preludeAsync }); main.toplevel = wrapper; } return cb(null, main); }); }; //# sourceMappingURL=bundle.map