Skip to content

headnote/serverless-babel-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Babel Plugin

The simplest way to start using ES2017+ in Lambda.

This fork of serverless-babel-plugin has been updated in a few ways now that serverless/serverless-babel-plugin is unmaintained.

Setup

  1. npm install headnote/serverless-babel-plugin --saveDev or yarn add -D headnote/serverless-babel-plugin

  2. Add plugin to serverless.yml

plugins:
  ...
  - serverless-babel-plugin
  ...
  1. Create a .babelrc file (example below).

  2. Test it with serverless package

Targeting AWS Lambda

Thanks to babel-preset-env it is now very easy to target older versions of Node. As of writing this, the latest version of Node supported by Lambda is 6.10. Example .babelrc:

{
  "presets": [
    ["env", {
      "targets": {
        "node": "6.10"
      }
    }]
  ]
}

Options

To log the stdout output from the Babel process (basically a list of all the files it processed), simply add this to serverless.yml. stderr will always be logged.

custom:
  serverlessBabel:
    stdout: true

Changes in this fork

  • Incorporates all bugs fixed on other forks (at the time of writing this)
  • Now uses babel-preset-env instead of deprecated babel-preset-latest. This allows you to easily use targeting.
  • Now uses a standard .babelrc file in your project root instead of limited babel configuration living in serverless.yml
  • Less verbose and prettier output by default.
  • Now preserves *nix file permissions but is no longer compatible with Windows (PRs welcome).

About

A Serverless plugin to compile your JavaScript code with Babel before deployment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%