AWS Lambda - Upload
By default, ZIPing the project directory will included all of your
devDependencies. slowing your upload speed to a crawl as you upload an enormous bundle containing 80% useless code (unless you're testing in production™ )
You only need your production dependencies when deploying, but need you
devDependencies for development. But you have to deploy from the same directory, and it must be named
node_modules. How can slim down the ol' deploy bundle?
Here's a horrible but effective hack that accomplishes this:
- We'll create an additional directory called
node_modules__prod for storing production dependencies.
- When we deploy we swap the names of the dev and production
node_modules directories 😱, so the deploy tool stupidly uploads what it thinks is our full
node_modules but actually is our production-only modules directory.
- When deploy is done (or fails) we swap the directory names again, restoring us back to developme