Skip to content

Commit 22a460d

Browse files
franciscocpgHyperBrain
authored andcommitted
Integration with deploy package function (#130)
* 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.
1 parent b87f028 commit 22a460d

39 files changed

+16510
-109
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules
22
dist
33
.webpack
4+
.serverless
45
coverage
5-
6-
.idea
6+
7+
.idea

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ module.exports = {
5151
};
5252
```
5353

54+
You can also let the plugin determine the correct handler entry points at build time.
55+
Then you do not have to care anymore when you add or remove functions from your service:
56+
57+
```js
58+
// webpack.config.js
59+
const slsw = require('serverless-webpack');
60+
61+
module.exports = {
62+
...
63+
entry: slsw.lib.entries,
64+
...
65+
};
66+
```
67+
5468
Note that, if the `output` configuration is not set, it will automatically be
5569
generated to write bundles in the `.webpack` directory. If you set your own `output`
5670
configuration make sure to add a [`libraryTarget`][link-webpack-libtarget]
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if (!global._babelPolyfill) {
2+
require('babel-polyfill');
3+
}
4+
5+
export const hello = (event, context, cb) => {
6+
const p = new Promise((resolve, reject) => {
7+
resolve('success');
8+
});
9+
p
10+
.then(r => cb(null, {
11+
message: 'Go Serverless Webpack (Babel) v1.0! First module!',
12+
event,
13+
}))
14+
.catch(e => cb(e));
15+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "serverless-webpack-babel-example",
3+
"version": "1.0.0",
4+
"description": "Serverless webpack example using Babel",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"author": "Nicola Peduzzi <[email protected]> (http://nikso.net)",
9+
"license": "MIT",
10+
"devDependencies": {
11+
"babel-core": "^6.25.0",
12+
"babel-loader": "^7.1.1",
13+
"babel-plugin-transform-runtime": "^6.23.0",
14+
"babel-polyfill": "^6.23.0",
15+
"babel-preset-env": "^1.6.0",
16+
"serverless-webpack": "file:../../",
17+
"webpack": "^3.3.0"
18+
}
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if (!global._babelPolyfill) {
2+
require('babel-polyfill');
3+
}
4+
5+
export const hello = (event, context, cb) => {
6+
const p = new Promise((resolve, reject) => {
7+
resolve('success');
8+
});
9+
p
10+
.then(r => cb(null, {
11+
message: 'Go Serverless Webpack (Babel) v1.0! Second module!',
12+
event,
13+
}))
14+
.catch(e => cb(e));
15+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
service: babel-dynamically-entries-example
2+
3+
# Add the serverless-webpack plugin
4+
plugins:
5+
- serverless-webpack
6+
7+
provider:
8+
name: aws
9+
runtime: nodejs4.3
10+
11+
functions:
12+
first:
13+
handler: first.hello
14+
events:
15+
- http:
16+
method: get
17+
path: first
18+
integration: lambda
19+
second:
20+
handler: second.hello
21+
events:
22+
- http:
23+
method: get
24+
path: second
25+
integration: lambda
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const path = require('path');
2+
const slsw = require('serverless-webpack');
3+
4+
module.exports = {
5+
entry: slsw.lib.entries,
6+
target: 'node',
7+
module: {
8+
loaders: [{
9+
test: /\.js$/,
10+
loaders: ['babel-loader'],
11+
include: __dirname,
12+
exclude: /node_modules/,
13+
}]
14+
},
15+
output: {
16+
libraryTarget: 'commonjs',
17+
path: path.join(__dirname, '.webpack'),
18+
filename: '[name]'
19+
}
20+
};

0 commit comments

Comments
 (0)