'use strict';

var join = require( 'path' ).join;
var writeFile = require( 'fs' ).writeFileSync;
var mkdirp = require( 'mkdirp' ).sync;
var collapse = require( 'bundle-collapser/plugin' );
var uglify = require( 'uglify-js' );
var bundle = require( './../../lib' );

var names = [
	'@stdlib/math/base/special/erf',
	'@stdlib/math/base/special/gamma'
];

var bopts = {
	'namespace': 'flat',
	'exportName': '@stdlib',
	'plugins': [
		collapse // convert bundle paths to IDs
	]
};

var dir = join( __dirname, 'build' );
bundle( names, bopts, onBundle );

function onBundle( error, bundle ) {
	var fpath;
	if ( error ) {
		throw error;
	}
	mkdirp( dir );
	fpath = join( dir, 'bundle.js' );
	writeFile( fpath, bundle );

	bundle = uglify.minify( bundle.toString() ).code;
	fpath = join( dir, 'bundle.min.js' );
	writeFile( fpath, bundle );
}

'use strict';

var join = require( 'path' ).join;
var writeFile = require( 'fs' ).writeFileSync;
var mkdirp = require( 'mkdirp' ).sync;
var uglify = require( 'uglify-js' );
var bundle = require( './../../lib' );

var names = [
	'@stdlib/math/base/special/erf',
	'@stdlib/math/base/special/gamma'
];

var bopts = {
	'namespace': 'flat',
	'exportName': '@stdlib'
};

var dir = join( __dirname, 'build' );
bundle( names, bopts, onBundle );

function onBundle( error, bundle ) {
	var fpath;
	if ( error ) {
		throw error;
	}
	mkdirp( dir );
	fpath = join( dir, 'bundle.js' );
	writeFile( fpath, bundle );

	bundle = uglify.minify( bundle.toString() ).code;
	fpath = join( dir, 'bundle.min.js' );
	writeFile( fpath, bundle );
}

--- 
+++ 
@@ -3,7 +3,6 @@
 var join = require( 'path' ).join;
 var writeFile = require( 'fs' ).writeFileSync;
 var mkdirp = require( 'mkdirp' ).sync;
-var collapse = require( 'bundle-collapser/plugin' );
 var uglify = require( 'uglify-js' );
 var bundle = require( './../../lib' );
 
@@ -14,10 +13,7 @@
 
 var bopts = {
 	'namespace': 'flat',
-	'exportName': '@stdlib',
-	'plugins': [
-		collapse // convert bundle paths to IDs
-	]
+	'exportName': '@stdlib'
 };
 
 var dir = join( __dirname, 'build' );
Use browserify plugin to collapse require ids
