Serverless ES6/ES7 Service

Hey guys, just a follow-up to our Serverless Stack Tutorial (http://serverless-stack.com) that I posted about recently. We noticed that some folks were using our demo repos to get started on their projects. So we created a simple Serverless service (https://github.com/AnomalyInnovations/serverless-es7) that automatically adds support for ES7 async/await. It also uses sourcemaps to print out accurate error messages.

We also wrote about it in more detail here - http://serverless-stack.com/chapters/serverless-es7-service.html

2 Likes

Thanks Frank! Being a newcomer to webpack and serverless myself, I have already started playing around with this template you created. I also upgraded babel-preset-es2015 to babel-preset-env and set { modules: false } to improve tree shaking.

If we get collection of template projects, maybe someone can start a page like so: http://andrewhfarmer.com/starter-project/

Great to hear @jeff-k-lee! Let me know if you find some issues.

Hi thanx for serverless with es7 support demo.
I am getting import error, any idea if this is known issue or not supported ?

import { graphql } from ‘graphql’;

Syntax error in module ‘handler’: SyntaxError
import { graphql } from ‘graphql’;
^^^^^^
SyntaxError: Unexpected token import

after some troubleshooting i found out that I get import error when I do "serverless deploy function -f functionName"
if i just do serverless deploy it works fine.

Hi @vinodhum,

Deploying single functions currently does not work due to an outstanding issue with the serverless-webpack plugin it uses to transpile the code.

In the meanwhile, you could give the suggested patch a try. I know this is frustrating since deploying the entire project is a much lengthier process.

Feel free to let us know here if you run into further issues.

may be if we can have an option of offline development that could help
I tried offline plugin and when I tried to start offline
it give me error
any I idea how can I add offline to es7 template ?

I see that sls webpack serve is working for local development but when I try to pass data on body using post method I don’t see it on event,body
when when I was working with offline pluing i was able to read it using event.body

offline plugin does not work as the plugin does not transpile ES7 code and it will throw syntax errors. It is very unfortunate because the plugin does a really good job at mocking API Gateway with very realistic event object.

And you are right, sls webpack serve does not seem to set event.body properly. I opened a ticket here.

Ideally it would be nice to get offline plugin to work with babel. I haven’t used offline plugin too much, and wonder how they handle identity when using IAM and User Pool authorizers.