Skip to content

Commit

Permalink
Upgrading to serverless-webpack 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jayair committed Sep 10, 2017
1 parent c8e46c1 commit b851f57
Show file tree
Hide file tree
Showing 4 changed files with 1,774 additions and 576 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This uses the [serverless-webpack](https://github.com/elastic-coders/serverless-

- **ES7 syntax in your handler functions**
- Use async/await
- The spread operator
- And much more!
- **Sourcemaps for proper error messages**
- Error message show the correct line numbers
Expand All @@ -20,7 +19,7 @@ If you'd like to learn how to setup your existing Serverless project to support

### Demo

A demo version of this service is hosted on AWS - [`https://ndgmy14knc.execute-api.us-east-1.amazonaws.com/dev/hello`](https://ndgmy14knc.execute-api.us-east-1.amazonaws.com/dev/hello)
A demo version of this service is hosted on AWS - [`https://ndgmy14knc.execute-api.us-east-1.amazonaws.com/dev/hello`](https://2njfspcvna.execute-api.us-east-1.amazonaws.com/dev/hello)

And here is the ES7 source behind it

Expand Down Expand Up @@ -74,22 +73,28 @@ $ npm install
To run a function on your local

``` bash
$ serverless webpack invoke --function hello
$ serverless invoke local --function hello
```

And to deploy
Deploy your project

``` bash
$ serverless deploy
```

Deploy a single function

``` bash
$ serverless deploy function --function hello
```

To add another function as a new file to your project, simply add the new file and add the reference to `serverless.yml`. The `webpack.config.js` automatically handles functions in different files.

### How It Works

To ensure that you get all the ES7 capabilities while showing proper error messages and seamlessly integrating with the rest of your project, we do the following:

- The `webpack.config.js` loads all your handlers from the `serverless.yml` and transpiles them using Babel. This means that you don't have to edit the `webpack.config.js` when you add a new handler file.
- The `webpack.config.js` loads all your handlers using the `slsw.lib.entries` from the serverless-webpack plugin. This means that you don't have to edit the `webpack.config.js` when you add a new handler file.
- Generate the sourcemaps for all the transpiled files and load the sourcemaps in each of the handler files.
- Catch and log any unhandled exceptions to ensure that async functions can log errors.

Expand Down
Loading

0 comments on commit b851f57

Please sign in to comment.