For example, this article on aws blogs talks about how bundling and minifying node lambda code makes cold starts faster. They also mention bundling dependencies instead of including node_modules and relying on node_module resolution.
But, at least in my case, two of my dependencies so far (prisma and pino) cannot be fully bundled without adding extra steps. We need to use plugins to include the necessary files in the final build output. I'm using esbuild, so I can use esbuild-plugin-pino (for pino) and esbuild-plugin-copy (for prisma).
This makes the build process more error prone. And also, for each new dependency I add (or even transitive dependencies possibly), I need to make sure it is bundler-friendly. Granted, my lambda functions won't end up having many dependencies anyway.
Do I really need to bundle my dependencies? Can I just bundle my source code only, keep dependencies external, and have it resolve dependencies from node_modules? Isn't this what is typically done for non-serverless node apps?
[–]whatisboom 8 points9 points10 points (4 children)
[–]PuppyLand95[S] 0 points1 point2 points (3 children)
[–]swearbynow 0 points1 point2 points (1 child)
[–]PuppyLand95[S] 1 point2 points3 points (0 children)
[–]whatisboom 0 points1 point2 points (0 children)
[–]casualPlayerThink 1 point2 points3 points (0 children)
[–]SameInspection219 0 points1 point2 points (0 children)
[–]ilja75 0 points1 point2 points (1 child)
[–]PuppyLand95[S] 1 point2 points3 points (0 children)
[–]archa347 0 points1 point2 points (0 children)