From af42599a15106f18a12bbc016e26ede0a9744698 Mon Sep 17 00:00:00 2001 From: Jared Allard Date: Wed, 19 Aug 2015 15:59:26 -0700 Subject: [PATCH] use browserify cli to do this... --- lib/bundle.js | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/bundle.js b/lib/bundle.js index a48af46..ba09a05 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -23,8 +23,8 @@ * **/ var mdeps = require("module-deps"), -insertGlobals = require('insert-module-globals'), path = require("path"), +spawn = require('child_process').spawn, fs = require("fs"), through = require("through"), async = require("async"), @@ -40,30 +40,15 @@ _log = require("./log"); * @param {function} complete - next function to call (async) **/ function bundle (input, nc, complete) { - var igv = '__filename,__dirname'; - insertGlobalVars = igv.split(',').reduce(function (vars, x) { // borrowed from browserify - vars[x] = insertGlobals.vars[x]; - return vars; - }, {}); - - var b = browserify(input, { - builtins: false, - commondir:false, - detectGlobals: false, - insertGlobals: '__filename,__dirname', - insertGlobalVars: insertGlobalVars, - browserField: false - }); var bundlePath = path.join(nc, "lib", "nexe.js"); var ws = fs.createWriteStream(bundlePath); + var proc = spawn('node', ['node_modules/browserify/bin/cmd.js', '--node', input ]); - /*if(fs.existsSync(bundlePath)) { - fs.unlinkSync(bundlePath); - }*/ + proc.stdout.pipe(ws); - var bfs = b.bundle(); // open the bundle stream. - - bfs.pipe(ws); // pipe it to the write stream we created earlier + proc.on('close', function(code) { + console.log("browserify finished") + }) ws.on('error', function(err) { console.log(err); @@ -75,7 +60,7 @@ function bundle (input, nc, complete) { fs.writeFileSync(bundlePath, source, 'utf8'); complete(); - }) + }); } module.exports = bundle;