Skip to content

Commit

Permalink
Integration with deploy package function (#130)
Browse files Browse the repository at this point in the history
* Deploy  package function

* Listen pipe and reject pipe errors

* using once instead of on

* Fix babel example

* - Adding babel-multiple-statically-entries example
- Renaming multiple-entries-example to multiple-statically-entries

* Exposing entries to lib

*  Adding babel-dynamically-entries examples

* - Updating examples dependencies
- Adding yarn to examples
- Fix typescript example

*  Adding tests

* Removed yarn lock file. yarn should use package-lock.json

* Allow handlers in arbitrary paths. Use lodash and SLS functions.

* Adapted unit tests

* Mention new entry resolution in README

* Bundle names now contain the js ending. Fixed output in examples.
  • Loading branch information
franciscocpg authored and HyperBrain committed Jul 26, 2017
1 parent b87f028 commit 22a460d
Show file tree
Hide file tree
Showing 39 changed files with 16,510 additions and 109 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
dist
.webpack
.serverless
coverage

.idea

.idea
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ module.exports = {
};
```

You can also let the plugin determine the correct handler entry points at build time.
Then you do not have to care anymore when you add or remove functions from your service:

```js
// webpack.config.js
const slsw = require('serverless-webpack');
module.exports = {
...
entry: slsw.lib.entries,
...
};
```

Note that, if the `output` configuration is not set, it will automatically be
generated to write bundles in the `.webpack` directory. If you set your own `output`
configuration make sure to add a [`libraryTarget`][link-webpack-libtarget]
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/babel-dynamically-entries/first.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (!global._babelPolyfill) {
require('babel-polyfill');
}

export const hello = (event, context, cb) => {
const p = new Promise((resolve, reject) => {
resolve('success');
});
p
.then(r => cb(null, {
message: 'Go Serverless Webpack (Babel) v1.0! First module!',
event,
}))
.catch(e => cb(e));
};
19 changes: 19 additions & 0 deletions examples/babel-dynamically-entries/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "serverless-webpack-babel-example",
"version": "1.0.0",
"description": "Serverless webpack example using Babel",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Nicola Peduzzi <[email protected]> (http://nikso.net)",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.0",
"serverless-webpack": "file:../../",
"webpack": "^3.3.0"
}
}
15 changes: 15 additions & 0 deletions examples/babel-dynamically-entries/second.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (!global._babelPolyfill) {
require('babel-polyfill');
}

export const hello = (event, context, cb) => {
const p = new Promise((resolve, reject) => {
resolve('success');
});
p
.then(r => cb(null, {
message: 'Go Serverless Webpack (Babel) v1.0! Second module!',
event,
}))
.catch(e => cb(e));
};
25 changes: 25 additions & 0 deletions examples/babel-dynamically-entries/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
service: babel-dynamically-entries-example

# Add the serverless-webpack plugin
plugins:
- serverless-webpack

provider:
name: aws
runtime: nodejs4.3

functions:
first:
handler: first.hello
events:
- http:
method: get
path: first
integration: lambda
second:
handler: second.hello
events:
- http:
method: get
path: second
integration: lambda
20 changes: 20 additions & 0 deletions examples/babel-dynamically-entries/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require('path');
const slsw = require('serverless-webpack');

module.exports = {
entry: slsw.lib.entries,
target: 'node',
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
include: __dirname,
exclude: /node_modules/,
}]
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name]'
}
};
Loading

0 comments on commit 22a460d

Please sign in to comment.