sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.
MIT License
169 stars 19 forks source link

feat: add nextProject option to handle monorepo #38

Closed plevavas closed 1 year ago

sladg commented 1 year ago

How does standalone output work with monorepo? I was experiencing problems with Next not properly bundling dependencies for standalone output (aka. .next/standalone/node_modules folder was mostly empty). Do you have any monorepo example I might test on? :)

plevavas commented 1 year ago

How does standalone output work with monorepo? I was experiencing problems with Next not properly bundling dependencies for standalone output (aka. .next/standalone/node_modules folder was mostly empty). Do you have any monorepo example I might test on? :)

After some tests, it works correctly. .next/standalone/node_modules is correctly filled. You can test with this repository : https://github.com/plevavas/monorepo

sladg commented 1 year ago

Hey! I went through your examples and tested it out.

To make it work, we need indeed outputFileTracing option, however, we also need hoistingLimits: workspace set as yarn option. See: https://github.com/vercel/next.js/issues/36386#issuecomment-1137665939

With that being said, I figured that we might ditch the option of nextPath and instead do it automatically (aka. search in output for server.js and make it work out of the box without adding parameters.

I will look at it during the day and try to make it work correctly for your usecase :)

sladg commented 1 year ago

Updated README with monorepo notes :) Tested on your repo, all works fine now. No need for additional flag, lookup for nested output is automatic now.

Thank you for kicking this off! Appreciated 💙

plevavas commented 1 year ago

Thanks a lot for your reactivity 👍