serverless/serverless-runtime-babel

Not clear how to install babel presets

Closed this issue · 2 comments

From the readme it is not clear how would I go to install es2015 and stage-0 Babel presets.

Save as dependency, dev dependency or what? also inside the function or on the main project?

(I haven't tried this at all but I was just expecting it on the readme)

Cheers!

Hi @thenikso,

es2015 preset is already included in serverless-runtime-babel so you need to install babel-preset-stage-0 only. The kind of dependency depends on your project specifics. I guess the normal dependency (with the --save flag) would be fine but --save-dev would work too.

Then update the function config:

{
  /*s-function.json*/
  /*...*/
  "runtime": "babel",
  "custom": {
    "runtime": {
      "babel": { 
        "presets": ["es2015", "stage-0"]
      }
    }
  },
  /*...*/
}

BTW, you can use Serverless templates to share the runtime config across different functions.

🎉