Socket
Book a DemoInstallSign in
Socket

@jaridwade/serverless-rollup-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jaridwade/serverless-rollup-plugin

Serverless Rollup Plugin - reduces Lambda file size through via bundling and tree-shaking

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Serverless Rollup Plugin

Forked from serverless-optimizer-plugin this plugin uses Rollup to optimize your Serverless Node.js Functions on deployment.

Reducing the file size of your AWS Lambda Functions allows AWS to provision them more quickly, speeding up the response time of your Lambdas. Smaller Lambda sizes also helps you develop faster because you can upload them faster.
This Severless Plugin is absolutely recommended for every project including Lambdas with Node.js.

Note: Requires Serverless v0.5.0.

Setup

  • Install the plugin and rollup in the root of your Serverless Project:
npm install serverless-rollup-plugin rollup --save-dev
  • Add the plugin to the plugins array in your Serverless Project's s-project.json, like this:
plugins: [
    "serverless-rollup-plugin"
]
  • In the custom property of your s-project.json add a rollup property.
{
  "custom": {
    "rollup": {
      "config": "path/relative/to/project-path"
    }
  }
}

** You can optimize all your Node.js functions by configuring your s-project.json:

{
  "custom": {
    "rollup": {
      "config": "path/relative/to/project-path",
      "global": true
    }
  }
}

** Or only optimize certain functions by configuring their s-function.json:

{
  "custom": {
    "rollup": true
  }
}

Rollup config

You can completely customize how your code is transformed and optimized by specifying your own rollup config. Heres a sample rollup.config.js:

Note: Remember to install any rollup plugins you plan to use.

var rollup = require('rollup');
var nodeResolve = require('rollup-plugin-node-resolve');
var commonjs = require('rollup-plugin-commonjs');
var inject = require('rollup-plugin-inject');
var babel = require('rollup-plugin-babel');
var uglify = require('rollup-plugin-uglify');

module.exports = {
  // entry: provided by serverless
  plugins: [
    nodeResolve({
      jsnext: true,
      main: true,
      extensions: [ '.js', '.jsx' ],
      preferBuiltins: true
    }),
    commonjs(),
    inject({
      Promise: 'es6-promise'
    }),
    babel(),
    uglify()
  ]
};

Keywords

serverless rollup plugin

FAQs

Package last updated on 22 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts