Code Monkey home page Code Monkey logo

serverless-plugin-include-dependencies's Introduction

NOTE: This plugin could cause a maximum call stack size exceeded error (see serverless/serverless#3349 for fix in Serverless)

serverless-plugin-include-dependencies

This is a Serverless plugin that should make your deployed functions smaller.

It does this by enabling you to add your node_modules folder to the exclude list, then it individually adds each module that your handler depends on.

Usage Example

serverless.yml

service: sample

package:
  exclude:
    - node_modules/** # no need to add this yourself, this plugin does it for you

plugins:
  - serverless-plugin-include-dependencies

functions:
  foo:
    handler: src/handler/foo.handler
  bar:
    handler: src/handler/bar.handler

For even smaller function packages, you can also set:

package:
  individually: true

But be warned: Smaller individual functions can still mean a larger overall deployment. (10 functions that are 3 MB each is more net data tranfer and storage than 1 function that is 6 MB)

New In 2.0 - Exclusion Support

Rather than including module folders (e.g. node_modules/foo/**, it now includes a list of actual files (e.g. node_modules/foo/package.json, node_modules/foo/index.js) and uses the serverless package exclude to filter these files. Excludes must start with node_modules to be considered by this plugin.

The following examples would filter files of your module dependencies:

  • node_modules/**/README.*
  • node_modules/**/test/**

These would not:

  • README
  • **/*.txt

Even though normal matching libraries would match these rules, this library ignores them so that there's no chance of local excludes conflicting with node_modules excludes.

Unless you know exactly where dependencies will be installed (e.g. several things could depend on aws-sdk) you probably want a rule more like node_modules/**/aws-sdk/** (which will exclude all instances of aws-sdk) and not node_modules/aws-sdk/** (which would only exclude a top-level aws-sdk)

serverless-plugin-include-dependencies's People

Contributors

dougmoscrop avatar ecstasy2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.