diff --git a/README.md b/README.md index 51eb814..1ab5943 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.js b/index.js index e5a6269..aef6db0 100644 --- a/index.js +++ b/index.js @@ -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,