From cbef294320db605191ceafa4bf21d1d1f70697d3 Mon Sep 17 00:00:00 2001 From: Peter Bevan Date: Thu, 16 Jun 2016 15:31:47 +0100 Subject: [PATCH 1/3] Use fully qualified path for the handler entry, otherwise tmp file is created in local function folder and if handler is nested in any directories the handler import fails and the package is not compiled correctlt --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index aef6db0..64a8537 100644 --- a/index.js +++ b/index.js @@ -75,15 +75,16 @@ 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}`; + const handlerEntryPath = path.join(pathDist, handlerFileName); // override entry and output webpackConfig.context = path.dirname(func.getFilePath()); if (Array.isArray(webpackConfig.entry)) { - webpackConfig.entry.push(handlerEntryPath); + webpackConfig.entry.push(path.join(pathDist, handlerEntryPath)); } else { - webpackConfig.entry = handlerEntryPath; + webpackConfig.entry = path.join(pathDist,handlerEntryPath); } + webpackConfig.output = { libraryTarget: 'commonjs', path: optimizedPath, From ecd790a82a14161af62ba9007586cd43b61cca22 Mon Sep 17 00:00:00 2001 From: Peter Bevan Date: Thu, 16 Jun 2016 15:34:36 +0100 Subject: [PATCH 2/3] remove the old path.join calls you idiot! ;) --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 64a8537..61befce 100644 --- a/index.js +++ b/index.js @@ -80,9 +80,9 @@ module.exports = function getPlugin(S) { // override entry and output webpackConfig.context = path.dirname(func.getFilePath()); if (Array.isArray(webpackConfig.entry)) { - webpackConfig.entry.push(path.join(pathDist, handlerEntryPath)); + webpackConfig.entry.push(handlerEntryPath); } else { - webpackConfig.entry = path.join(pathDist,handlerEntryPath); + webpackConfig.entry = handlerEntryPath; } webpackConfig.output = { From b365dc63842c60fe87b947c4a4d14949a66ed1c3 Mon Sep 17 00:00:00 2001 From: Peter Bevan Date: Thu, 16 Jun 2016 15:35:29 +0100 Subject: [PATCH 3/3] tidy --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 61befce..535744e 100644 --- a/index.js +++ b/index.js @@ -84,7 +84,6 @@ module.exports = function getPlugin(S) { } else { webpackConfig.entry = handlerEntryPath; } - webpackConfig.output = { libraryTarget: 'commonjs', path: optimizedPath,