Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about how node_modules are included in lambda bundles #4

Open
ajhool opened this issue Aug 21, 2018 · 1 comment
Open

Question about how node_modules are included in lambda bundles #4

ajhool opened this issue Aug 21, 2018 · 1 comment

Comments

@ajhool
Copy link

ajhool commented Aug 21, 2018

First, thanks for putting this repo together! All the examples are very useful and this is the best collection that I've seen so far.

My understanding of Lerna and Workspaces is that it hoists each project's dependencies into shared node_modules that exist above the project's directory. This allows projects to share dependencies easily. However, when you need to deploy a zip file to lambda, it is actually less convenient for dependencies to be stored in multiple places -- it would be nice if you could simply zip the build directory and the node_modules directory.

I can't see in your code how node_modules is built and included in your deploy packages. Also, is it possible for your sample-google package to depend on your sample-graphql package in such a way that sample-graphql can be included in the deploy bundle for sample-google?

@wyvern8
Copy link
Collaborator

wyvern8 commented Dec 20, 2019

Sorry, @ajhool , just came across this. Somehow missed it when raised. I imagine you already have your answer by now. In case that is not the case:

This approach uses the serverless webpack plugin, that automatically includes any referenced dependencies in the bundle that is build and deployed. This means that it is self contained, and all modules not referenced are not pulled into the bundle so it remains relatively small. It also means that you are not tying yourself to platform specific approaches such as Lambda layers.

If you wanted to include resources from other bundles, you could either release the bundle as an npm package to be added as a dependency. (lerna can publish each package and auto- wire dependencies.). Or you could move shared utils into its own package and include that or reference the files directly. For example if you had utils to abstract DynamoDB, you could maintain this in a separate package/dir and just import it into consuming packages.

Hope that helps, and again apologies for the lack of response earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants