|
| 1 | +# Function compiled with Babel |
| 2 | + |
| 3 | +This example demonstrates how to compile your JavaScript code with Babel. In order to do so the `serverless-babel-plugin` is leveraged. |
| 4 | + |
| 5 | +## Use Cases |
| 6 | + |
| 7 | +- Using the latest JavaScript language features without waiting for AWS to provide new Node environments. |
| 8 | + |
| 9 | +## Setup |
| 10 | + |
| 11 | +```bash |
| 12 | +npm install |
| 13 | +``` |
| 14 | + |
| 15 | +## Deploy |
| 16 | + |
| 17 | +```bash |
| 18 | +serverless deploy |
| 19 | +``` |
| 20 | + |
| 21 | +```bash |
| 22 | +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. |
| 23 | +Serverless: Packaging service… |
| 24 | +Serverless: Babel compilation: |
| 25 | +tmpBabelDirectory/createResponse.js -> tmpBabelDirectory/createResponse.js |
| 26 | +tmpBabelDirectory/handler.js -> tmpBabelDirectory/handler.js |
| 27 | + |
| 28 | +Serverless: Packaging service with compiled files... |
| 29 | +Serverless: Uploading CloudFormation file to S3… |
| 30 | +Serverless: Uploading service .zip file to S3… |
| 31 | +Serverless: Updating Stack… |
| 32 | +Serverless: Checking Stack update progress… |
| 33 | +............ |
| 34 | +Serverless: Stack update finished… |
| 35 | + |
| 36 | +Service Information |
| 37 | +service: function-compiled-with-babel |
| 38 | +stage: dev |
| 39 | +region: us-east-1 |
| 40 | +api keys: |
| 41 | + None |
| 42 | +endpoints: |
| 43 | + None |
| 44 | +functions: |
| 45 | + function-compiled-with-babel-dev-hello: arn:aws:lambda:us-east-1:377024778620:function:function-compiled-with-babel-dev-hello |
| 46 | +``` |
| 47 | + |
| 48 | +## Usage |
| 49 | + |
| 50 | +You can now invoke the Lambda directly and even see the resulting log via |
| 51 | + |
| 52 | +```bash |
| 53 | +serverless invoke --function hello --log |
| 54 | +``` |
| 55 | + |
| 56 | +The expected result should be similar to: |
| 57 | + |
| 58 | +```bash |
| 59 | +{ |
| 60 | + "statusCode": 200, |
| 61 | + "body": { |
| 62 | + "message": "Success!" |
| 63 | + } |
| 64 | +} |
| 65 | +-------------------------------------------------------------------- |
| 66 | +START RequestId: 4388ee49-affe-11e6-9e69-1bde31ed2e43 Version: $LATEST |
| 67 | +2016-11-21 16:22:07.748 (+01:00) 4388ee49-affe-11e6-9e69-1bde31ed2e43 { response: { statusCode: 200, body: { message: 'Success!' } } } |
| 68 | +END RequestId: 4388ee49-affe-11e6-9e69-1bde31ed2e43 |
| 69 | +REPORT RequestId: 4388ee49-affe-11e6-9e69-1bde31ed2e43 Duration: 23.13 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 17 MB |
| 70 | +``` |
0 commit comments