Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore cleanup gitignore definitions Feb 10, 2017 all example README files updated Oct 19, 2018
createResponse.js rename examples Nov 24, 2016
event.json rename examples Nov 24, 2016
handler.js eslint: disable no-console Feb 6, 2017
package.json Add babel-cli dependency Jan 8, 2017
serverless.yml rename examples Nov 24, 2016

Function compiled with Babel

This example demonstrates how to compile your JavaScript code with Babel. In order to do so the serverless-babel-plugin is leveraged.

Use Cases

  • Using the latest JavaScript language features without waiting for AWS to provide new Node environments.


npm install


serverless deploy
Serverless: Deprecation Notice: Starting with the next update, we will drop support for Lambda to implicitly create LogGroups. Please remove your log groups and set "provider.cfLogs: true", for CloudFormation to explicitly create them for you.
Serverless: Packaging service…
Serverless: Babel compilation:
tmpBabelDirectory/createResponse.js -> tmpBabelDirectory/createResponse.js
tmpBabelDirectory/handler.js -> tmpBabelDirectory/handler.js

Serverless: Packaging service with compiled files...
Serverless: Uploading CloudFormation file to S3…
Serverless: Uploading service .zip file to S3…
Serverless: Updating Stack…
Serverless: Checking Stack update progress…
Serverless: Stack update finished…

Service Information
service: function-compiled-with-babel
stage: dev
region: us-east-1
api keys:
  function-compiled-with-babel-dev-hello: arn:aws:lambda:us-east-1:377024778620:function:function-compiled-with-babel-dev-hello


You can now invoke the Lambda directly and even see the resulting log via

serverless invoke --function hello --log

The expected result should be similar to:

    "statusCode": 200,
    "body": {
        "message": "Success!"
START RequestId: 4388eeaffe-11e6-9e1bde31ed2e43 Version: $LATEST
2021 16:22:07.748 (+01:00)	4388eeaffe-11e6-9e1bde31ed2e43	{ response: { statusCode: 200, body: { message: 'Success!' } } }
END RequestId: 4388eeaffe-11e6-9e1bde31ed2e43
REPORT RequestId: 4388eeaffe-11e6-9e1bde31ed2e43	Duration: 23.13 ms	Billed Duration: 100 ms 	Memory Size: 1024 MB	Max Memory Used: 17 MB