My serverless project has the following structure:
src/
handlers/
handler.js
otherhandler.js
lib/
get-something.js
serverless.yml
package.json
Any one of my handlers may look like this:
const getSomething = require("../lib/get-something");
module.exports.getSomething = async () => {
return getSomething();
};
I do this because I dislike having all my code in one big Lambda function.
Whenever I deploy, each Lambda function that is created contains the entire project. The entire node_modules
and src
folder is published along with an auto-generated file called s_getSomething.js
.
Is this the intended behavior? I assume that anything other than this would webpack-like functionality of detecting dependencies, tree-shaking and so on.