Skip to content

Commit

Permalink
Merge pull request #21 from xolvio/master
Browse files Browse the repository at this point in the history
Allow to include other modules before the lamda function gets loaded
  • Loading branch information
asprouse committed May 2, 2016
2 parents e19f8f9 + d25c568 commit 5209f08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ for an easy way to externalize all node modules.

### Source Maps
Yes using `devtool: 'source-map'` works, include `require('source-map-support').install();` you'll have pretty stacktraces.

### Loading additional modules before the lambda function module
If you need to load modules before your lambda function module is loaded,
you can specify those modules with entry option in your webpack config.
For example if you need to load the babel-polyfill, you can do that
by adding `entry: ['babel-polyfill']` to your webpack config.
This will first load the babel-polyfill module and then your lambda function module.

### Improving deploy performance

Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ module.exports = function getPlugin(S) {
const webpackConfig = Object.assign({}, config.webpackConfig);
const handlerName = func.getHandler().split('.')[0];
const handlerFileName = `${handlerName}.${config.handlerExt}`;
const handlerEntryPath = `./${handlerFileName}`;

// override entry and output
webpackConfig.context = path.dirname(func.getFilePath());
webpackConfig.entry = `./${handlerFileName}`;
if (Array.isArray(webpackConfig.entry)) {
webpackConfig.entry.push(handlerEntryPath);
} else {
webpackConfig.entry = handlerEntryPath;
}
webpackConfig.output = {
libraryTarget: 'commonjs',
path: optimizedPath,
Expand Down

0 comments on commit 5209f08

Please sign in to comment.