lib/deploy/bundle-lambdas-step.js
function bundleLambda(lambda, exclude, environment, bundlePath, sourceMapPath) {
    environment = environment || {};
    exclude = exclude || [];

    return new Promise(function(resolve, reject) {
        const bundler = new Browserify(lambda.path, {
            basedir: path.dirname(lambda.path),
            standalone: lambda.name,
            browserField: false,
            builtins: false,
            commondir: false,
            ignoreMissing: true,
            detectGlobals: true,
            debug: !!sourceMapPath,
            insertGlobalVars: {
                process: function() {}
            }
        });

        // AWS SDK should always be excluded
        bundler.exclude('aws-sdk');

        // Further things to exclude
        [].concat(exclude).forEach(function(module) {
            bundler.exclude(module);
        });

        // Envify (doesn't purge, as there are valid values
        // that can be used in Lambda functions)
        if (environment) {
            bundler.transform(envify(environment), {
                global: true
            });
        }

        let stream = bundler.bundle();
        if (sourceMapPath) {
            stream = stream.pipe(exorcist(sourceMapPath));
        }

        stream.pipe(fs.createWriteStream(bundlePath));

        stream.on('error', function(err) {
            reject(err);
        }).on('end', function() {
            resolve();
        });
    });
}
function bundleLambda(lambda, exclude, environment, bundlePath, sourceMapPath) {
    environment = environment || {};
    exclude = exclude || [];

    return new Promise(function(resolve, reject) {
        const bundler = new Browserify(lambda.path, {
            basedir: path.dirname(lambda.path),
            standalone: lambda.name,
            browserField: false,
            builtins: false,
            commondir: false,
            ignoreMissing: true,
            detectGlobals: true,
            debug: !!sourceMapPath,
            insertGlobalVars: {
                process: function() {}
            }
        });

        // AWS SDK should always be excluded
        bundler.exclude('aws-sdk');

        // Further things to exclude
        [].concat(exclude).forEach(function(module) {
            bundler.exclude(module);
        });

        // Envify (doesn't purge, as there are valid values
        // that can be used in Lambda functions)
        if (environment) {
            bundler.transform(envify(environment), {
                global: true
            });
        }

        let stream = bundler.bundle();
        if (sourceMapPath) {
            stream = stream.pipe(exorcist(sourceMapPath));
        }

        stream.pipe(fs.createWriteStream(bundlePath));

        stream.on('error', function(err) {
            reject(err);
        }).on('end', function() {
            resolve();
        });
    });
}
function bundleLambda ( lambda , exclude , environment , bundlePath , sourceMapPath ) { environment = environment || { } ; exclude = exclude || [ ] ; return new Promise ( function ( resolve , reject ) { const bundler = new Browserify ( lambda . path , { basedir : path . dirname ( lambda . path ) , standalone : lambda . name , browserField : false , builtins : false , commondir : false , ignoreMissing : true , detectGlobals : true , debug : ! ! sourceMapPath , insertGlobalVars : { process : function ( ) { } } } ) ; // AWS SDK should always be excluded bundler . exclude ( 'aws-sdk' ) ; // Further things to exclude [ ] . concat ( exclude ) . forEach ( function ( module ) { bundler . exclude ( module ) ; } ) ; // Envify (doesn't purge, as there are valid values // that can be used in Lambda functions) if ( environment ) { bundler . transform ( envify ( environment ) , { global : true } ) ; } let stream = bundler . bundle ( ) ; if ( sourceMapPath ) { stream = stream . pipe ( exorcist ( sourceMapPath ) ) ; } stream . pipe ( fs . createWriteStream ( bundlePath ) ) ; stream . on ( 'error' , function ( err ) { reject ( err ) ; } ) . on ( 'end' , function ( ) { resolve ( ) ; } ) ; } ) ; }
Processing pipeline, all functions should return a promise
 
Bundles the lambda code, returning the bundled code

@param lambda Lambda function to bundle, should at minimum have a path property
with the entry point
@param exclude Array of packages to exclude from the bundle, defaults to aws-sdk
@param environment Env variables to envify
@param bundlePath Path to save the bundled code to
@param sourceMapPath Path to save the source maps to

@returns Promise that bundles the code and writes it to a file
Processing pipeline all functions should return a promise Bundles the lambda code returning the bundled code