Hello all, I’ve written a simple lambda that creates a user record in DynamoDB. It runs as expected when I invoke it locally. However, when I deploy the function and view it in the console it appears to be concatenated into a massive amount of what appears to be webpack source code.
I’ve included a snippet here. Does anyone have any suggestions as to how I’d resolve this?
(The ellipsis indicate where I’ve truncated the extra code.)
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
...
// My code here
function create(event, context, callback) {
const data = JSON.parse(event.body);
const params = {
TableName: process.env.tableName,
// dynamically references the table as each environment will be connected to a distinct instance of dynamo
Item: {
userId: event.requestContext.identity.cognitoIdentityId,
customer: data.customer,
first_name: data.firstName,
last_name: data.lastName,
email: data.email
}
};
dynamo.put(params, (error, data) => {
const headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
};
if (error) {
console.log({
error
});
const response = {
statusCode: 500,
headers: headers,
body: error
};
callback(null, response);
return;
}
const response = {
statusCode: 200,
headers: headers,
body: JSON.stringify(params.Item)
};
callback(null, response);
});
}
;
// and then what appears to be more webpack source
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(7).install();
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var SourceMapConsumer = __webpack_require__(8).SourceMapConsumer;
var path = __webpack_require__(15);
var fs;
try {
fs = __webpack_require__(16);
if (!fs.existsSync || !fs.readFileSync) {
// fs doesn't have all methods we need
fs = null;
}
} catch (err) {
/* nop */
}
// Only install once if called multiple times
var errorFormatterInstalled = false;
var uncaughtShimInstalled = false;
// If true, the caches are reset before a stack trace formatting operation
var emptyCacheBetweenOperations = false;
// Supports {browser, node, auto}
var environment = "auto";
// Maps a file path to a string containing the file contents
var fileContentsCache = {};
// Maps a file path to a source map for that file
var sourceMapCache = {};
// Regex for detecting source maps
var reSourceMap = /^data:application\/json[^,]+base64,/;
// Priority list of retrieve handlers
var retrieveFileHandlers = [];
var retrieveMapHandlers = [];
function isInBrowser() {
if (environment === "browser")
return true;
if (environment === "node")
return false;
return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer"));
}
function hasGlobalProcessEventEmitter() {
return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
}
function handlerExec(list) {
return function(arg) {
for (var i = 0; i < list.length; i++) {
var ret = list[i](arg);
if (ret) {
return ret;
}
}
return null;
};
}
var retrieveFile = handlerExec(retrieveFileHandlers);
...