All Projects → FidelLimited → Serverless Plugin Optimize

FidelLimited / Serverless Plugin Optimize

Licence: mit
Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Serverless Plugin Optimize

Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+2051.64%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Retinal
🏙 Retinal is a Serverless AWS Lambda service for resizing images on-demand or event-triggered
Stars: ✭ 208 (+70.49%)
Mutual labels:  serverless, aws-lambda, serverless-functions
List Lambdas
Enumerate Lambda functions across all regions with useful metadata 💡💵⚙
Stars: ✭ 156 (+27.87%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Serverless Plugin Select
Select which functions are to be deployed based on region and stage.
Stars: ✭ 25 (-79.51%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Aws Node Elasticache Vpc
Serverless function using elasticache (redis) within VPC
Stars: ✭ 22 (-81.97%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Serverless Plugin Typescript
Serverless plugin for zero-config Typescript support
Stars: ✭ 611 (+400.82%)
Mutual labels:  serverless, aws-lambda, babel
Awesome Layers
λ A curated list of awesome AWS Lambda Layers. Sponsored by https://cloudash.dev
Stars: ✭ 1,655 (+1256.56%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Lyo
📦 Node.js to browser - The easy way
Stars: ✭ 624 (+411.48%)
Mutual labels:  browserify, minify, babel
Epsagon Go
Automated tracing library for Go 1.x ⚡️
Stars: ✭ 24 (-80.33%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Lambda Cost Calculator
Forecast Lambda functions costs 💰
Stars: ✭ 91 (-25.41%)
Mutual labels:  serverless, aws-lambda, serverless-functions
Serverless Sharp
Serverless image optimizer for S3, Lambda, and Cloudfront
Stars: ✭ 102 (-16.39%)
Mutual labels:  serverless, aws-lambda
Cda Locale
Showing Microsoft Cloud Developer Advocates speaking, 2017 and 2018
Stars: ✭ 101 (-17.21%)
Mutual labels:  serverless, serverless-functions
Lambdauth
A sample authentication service implemented with a server-less architecture, using AWS Lambda to host and execute the code and Amazon DynamoDB as persistent storage. This provides a cost-efficient solution that is scalable and highly available and can be used with Amazon Cognito for Developer Authenticated Identities.
Stars: ✭ 1,365 (+1018.85%)
Mutual labels:  serverless, aws-lambda
Serverless With Next5 Boilerplate
Serverless.js with Next.js 5 on AWS, powered by the Serverless Framework
Stars: ✭ 100 (-18.03%)
Mutual labels:  serverless, aws-lambda
Serverless
⚡ Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! –
Stars: ✭ 41,584 (+33985.25%)
Mutual labels:  serverless, aws-lambda
Hark Lang
Build stateful and portable serverless applications without thinking about infrastructure.
Stars: ✭ 103 (-15.57%)
Mutual labels:  serverless, aws-lambda
Reactnativeauth
Mobile user authentication flow with React Native, Expo, and AWS Amplify: Sign In, Sign Up, Confirm Sign Up, Forget Password, Reset Password.
Stars: ✭ 108 (-11.48%)
Mutual labels:  serverless, aws-lambda
Serverless Layers
Serverless.js plugin that implements AWS Lambda Layers which reduces drastically lambda size, warm-up and deployment time.
Stars: ✭ 119 (-2.46%)
Mutual labels:  serverless, aws-lambda
Serverless Chat
A serverless web chat built using AWS Lambda, AWS IoT (for WebSockets) and Amazon DynamoDB
Stars: ✭ 99 (-18.85%)
Mutual labels:  serverless, aws-lambda
Serverless static website with basic auth
Builds a serverless infrastructure in AWS for hosting a static website protected with Basic Authentication and published on a subdomain registered via Route 53
Stars: ✭ 112 (-8.2%)
Mutual labels:  serverless, aws-lambda

Serverless Optimize Plugin

serverless npm version npm downloads license

Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript.

This plugin is a child of the great serverless-optimizer-plugin. Kudos!

Requirements:

  • Serverless v1.12.x or higher.
  • AWS provider and nodejs4.3/6.10/8.10/10.x/12.x/14.x runtimes

Setup

Install via npm in the root of your Serverless service:

npm install serverless-plugin-optimize --save-dev
  • Add the plugin to the plugins array in your Serverless serverless.yml:
plugins:
  - serverless-plugin-optimize
  • Set your packages to be built individually to have smaller packages:
package:
  individually: true
  • All done! Optimize will run on SLS deploy and invoke local commands

Options

Configuration options can be set globally in custom property and inside each function in optimize property. Function options overwrite global options.

Global

  • debug (default false) - When debug is set to true it won't remove prefix folder and will generate debug output at the end of package creation.
  • exclude (default ['aws-sdk']) - Array of modules or paths that will be excluded.
  • extensions (default ['.js', '.json']) - Array of optional extra extensions modules that will be included.
  • external Array of modules to be copied into node_modules instead of being loaded into browserify bundle. Note that external modules will require that its dependencies are within its directory and this plugin will not do this for you. e.g. you should execute the following: (cd external_modules/some-module && npm i --prod)
  • externalPaths Optional object key value pair of external module name and path. If not set, external modules will look for reference path in node_modules.
  • global (default false) - When global is set to true transforms will run inside node_modules.
  • ignore - Array of modules or paths that won't be transformed with Babelify.
  • includePaths - Array of file paths that will be included in the bundle package. Read here how to call these files.
  • minify (default true) - When minify is set to false Babili preset won't be added.
  • plugins - Array of Babel plugins.
  • prefix (default _optimize) - Folder to output bundle.
  • presets (default ['env']) - Array of Babel presets.
custom:
  optimize:
    debug: true
    exclude: ['ajv']
    extensions: ['.extension']
    external: ['sharp']
    externalPaths:
      sharp: 'external_modules/sharp'
    global: true
    ignore: ['ajv']
    includePaths: ['bin/some-binary-file']
    minify: false
    prefix: 'dist'
    plugins: ['transform-decorators-legacy']
    presets: ['es2017']

Function

  • optimize (default true) - When optimize is set to false the function won't be optimized.
functions:
  hello:
    optimize: false
  • exclude - Array of modules or paths that will be excluded.
  • extensions - Array of optional extra extensions modules that will be included.
  • external Array of modules to be copied into node_modules instead of being loaded into browserify bundle. Note that external modules will require it's dependencies within it's directory. (cd external_modules/some-module && npm i --prod)
  • externalPaths Optional object key value pair of external module name and path. If not set, external modules will look for reference path in node_modules.
  • global - When global is set to true transforms will run inside node_modules.
  • ignore - Array of modules or paths that won't be transformed with Babelify.
  • includePaths - Array of file paths that will be included in the bundle package. Read here how to call these files.
  • minify - When minify is set to false Babili preset won't be added.
  • plugins - Array of Babel plugins.
  • presets - Array of Babel presets.
functions:
  hello:
    optimize:
      exclude: ['ajv']
      extensions: ['.extension']
      external: ['sharp']
      externalPaths:
        sharp: 'external_modules/sharp'
      global: false
      ignore: ['ajv']
      includePaths: ['bin/some-binary-file']
      minify: false
      plugins: ['transform-decorators-legacy']
      presets: ['es2017']

includePaths Files

There is a difference you must know between calling files locally and after optimization with includePaths.

When Optimize packages your functions, it bundles them inside /${prefix}/${functionName}/... and when your lambda function runs in AWS it will run from root /var/task/${prefix}/${functionName}/... and your CWD will be /var/task/.

Solution in #32 by @hlegendre. path.resolve(process.env.LAMBDA_TASK_ROOT, ${prefix}, process.env.AWS_LAMBDA_FUNCTION_NAME, ${includePathFile}).

Contribute

Help us making this plugin better and future proof.

  • Clone the code
  • Install the dependencies with npm install
  • Create a feature branch git checkout -b new_feature
  • Lint with standard npm run lint

License

This software is released under the MIT license. See the license file for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].