{"id":19042449,"url":"https://github.com/serverless/serverless-runtime-babel","last_synced_at":"2025-04-23T22:28:05.266Z","repository":{"id":65982494,"uuid":"54001805","full_name":"serverless/serverless-runtime-babel","owner":"serverless","description":"Babel runtime for v.0.5 of the Serverless Framework","archived":false,"fork":false,"pushed_at":"2016-07-14T15:24:07.000Z","size":23,"stargazers_count":68,"open_issues_count":13,"forks_count":18,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-11T20:49:32.796Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.serverless.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-16T04:53:20.000Z","updated_at":"2023-09-08T17:08:10.000Z","dependencies_parsed_at":"2023-02-19T18:15:25.337Z","dependency_job_id":null,"html_url":"https://github.com/serverless/serverless-runtime-babel","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-runtime-babel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-runtime-babel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-runtime-babel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-runtime-babel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/serverless-runtime-babel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250525691,"owners_count":21445069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T22:37:42.138Z","updated_at":"2025-04-23T22:28:05.250Z","avatar_url":"https://github.com/serverless.png","language":"JavaScript","readme":"# Babel Runtime for [Serverless](http://serverless.com)\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n\n## Features \n *  **Runs locally and deploys functions written in ES2015 syntax (via [Babel](https://babeljs.io/))**\n *  *Classic* and *Modern JS Style* handlers\n *  Browserifies, minifies your functions on deployment\n\n## Install\n**Note:** Serverless v0.5.0 or higher is required.\n* Install via npm in the root of your Serverless Project: `npm install serverless-runtime-babel --save`\n* In the `plugins` array in your `s-project.json` add `\"serverless-runtime-babel\"`\n* All done!\n\n## Usage\nAll you need is to set `runtime` property of `s-function.json` to `babel`.\nYou could use the classic style handler when you need to call `context.done()` or the modern style when your functions should return a promise.\n\n### Classic Style\n```javascript\n/* handler.js */\n'use strict';\n\nmodule.exports.handler = function(event, context) {\n\n  /* Everything is the same but better */\n  let [name, age, isAdmin] = ['bob', 23, false];\n  let user = {name, age};\n\n  return context.done(null, {\n    isAdmin,\n    userName: user.name,\n    userAge: user.age\n  });\n};\n```\n\n### Modern JS Style\n```javascript\n/* event.json */\n{\n  \"repos\": [\n    \"serverless/serverless\",\n    \"serverless/serverless-runtime-babel\"\n  ]\n}\n```\n```javascript\n/* handler.js */\nimport \"babel-polyfill\"\nimport request from \"request-promise\"\n\nconst headers = {\n  'User-Agent': 'Serverless'\n};\n\nexport default ({repos}) =\u003e {\n\n  return Promise.all(repos.map(repo =\u003e {\n    let uri = `https://api.github.com/repos/${repo}`\n\n    return request({headers, uri, json: true})\n      .then(({stargazers_count}) =\u003e ({repo, stars: stargazers_count}))\n  }))\n​\n}\n```\n\n### Scaffold\nYou can use `serverless function create` as usual — it will promt you for a runtime unless you add the `-r babel` flag.\n\n### Examples\n* [GitHub stargazers example](https://github.com/serverless/serverless-runtime-babel/tree/master/examples/stars) - Returns amount of starts for a GitHub repo\n\n## Options\n\nConfiguration options can be used by setting the `custom.runtime` of `s-function.json`. The following options are available:\n\n* `babel` — An object with a [Babel configuration](https://babeljs.io/docs/usage/options/)\n\n* `minify` — When set to `true`, this will enable minification. Default: `true`.\n\n### Browserify Options\n\nBrowserify options can be included as normal configuration options to the `runtime` object. The following options are supported:\n\n* handlerExt\n* requires\n* plugins\n* transforms\n* exclude\n* ignore (defaults to `[\"aws-sdk\"]`)\n* extensions\n\nFor more information on these options, please visit the [Browserify Documentaton](https://github.com/substack/node-browserify#usage).\n\n### Example\n\nExample Babel Runtime configuration with default values:\n\n```javascript\n{\n  /*s-function.json*/\n  /*...*/\n  \"runtime\": \"babel\",\n  \"custom\": {\n    \"runtime\": {\n      \"babel\": { \n      \t\"presets\": [\"es2015\"]\n      },\n      \"handlerExt\": \"js\",\n      \"requires\": [],\n      \"plugins\": [],\n      \"transforms\": [],\n      \"exclude\": [],\n      \"ignore\": [\n        \"aws-sdk\"\n      ],\n      \"extensions\": [],\n      \"minify\": true\n    }\n  },\n  /*...*/\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-runtime-babel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fserverless-runtime-babel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-runtime-babel/lists"}