Giter Club home page Giter Club logo

serverless-rollup-plugin's Introduction

Welcome to serverless-rollup-plugin πŸ‘‹

Release Maintainability npm version FOSSA Status All Contributors

A plugin for the serverless framework to bundle lambda code using rollup

Install

npm install --save-dev serverless-rollup-plugin

Requires Node.js 18 and serverless 3.2.

Usage

Add the plugin to your serverless config:

plugins:
  - serverless-rollup-plugin
  - ...any other plugins

For each function that you would like to use rollup option, just define the handler option as normal. You can optionally define the dependencies property as a list of packages to be installed in the node_modules folder in your lambda.

testFunction:
  handler: src/functions/testFunction/index.handler
  dependencies:
    - aws-xray-sdk-core
  copyFiles:
    - some/glob/**/*.pattern

Config

By default, serverless-rollup-plugin will attempt to load rollup.config.js. In order to override this behavior, you can add the following to configuration options:

custom:
  rollup:
    config: ./custom-rollup.config.js

Using Yarn

By default if you specify function dependencies npm will be used. You can override this by setting the installCommand property, like this:

custom:
  rollup:
    installCommand: yarn add

Add Global Dependency

If you want to add a dependency for every lambda function (for example adding source map support), you can add them to the rollup dependencies property:

custom:
  rollup:
    dependencies:
      - some-package-name

Output Options

If you don't specify output settings in your rollup config, the following defaults will be used:

{
  "format": "cjs",
  "sourcemap": true
}

If the format is esm, the resulting package will use the mjs extension to make use of native lambda esm support.

Concurrency

By default, serverless-rollup-plugin will output rollup bundles concurrently. In systems with low memory, such as small CI instances, it may be necessary to limit the number concurrent outputs so as not to run out of memory. You can define the number of concurrent outputs by using the concurrency option:

custom:
  rollup:
    concurrency: 3

Any value other than a number will be treated as Number.POSITIVE_INFINITY.

Adding Sourcemap Support

You can easily get your lambda stack traces to show correct file/line information using the source-map-support package. To use this with the serverless-rollup-plugin, first install the package and add it to the universal dependencies:

custom:
  rollup:
    dependencies:
      - source-map-support

Then in your rollup config, set the output banner to install it:

export default {
  output: {
    format: "cjs",
    sourcemap: true,
    banner: "require('source-map-support').install();"
  }
};

If you do specify output settings, they will be used and only the file property will be overwritten.

Copying Resource Files

To copy a static file into your function deployment, use the copyFiles parameter. This parameter is an array of glob pattern strings, or objects with the following properties:

Name Required Description
glob Yes A glob pattern
srcBase No Part of the path that will be removed from the destination path
destination No Destination path within the lambda's directory structure

πŸ§‘β€πŸ’» Contributors

🀝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❀️ by readme-md-generator

serverless-rollup-plugin's People

Contributors

dependabot[bot] avatar eshikerya avatar perrin4869 avatar thebenforce avatar vinicius73 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

serverless-rollup-plugin's Issues

feature: support serverless invoke local

It would be nice if serverless invoke local would be piped through rollup, like with serverless-webpack. At the moment, it seems to be falling back to built in serverless behavior, and trying to directly invoke the source, which will probably fail due to using ES modules, not finding it (due to it being a .ts file) etc.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

[Security] Workflow release.yml is using vulnerable action actions/checkout

The workflow release.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Rollup Major Update

πŸ‘‹ hey there thanks very much for putting this plugin together. I'm about to give it a shot for some of my work projects. I'm also a member of the Rollup core team and (kind of sort of) lead on the official plugins repo for Rollup.

I was wondering if you had plans to update the Rollup version to 2.x and the plugins along with it.

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.