-
Notifications
You must be signed in to change notification settings - Fork 143
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
docs: add documentation on minimizing lambda bundle #167
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Do we want to merge this @khuezy? |
Yes, I added a note on server actions. Feel free to edit and merge. |
FYI im using the following list:
|
Thanks @JanStevens , I'll put up a PR to remove those at buildtime. Since this isn't a blocker though, I'll defer this until after the other PRs. Actually this is the PR... I'll update it later. |
@conico974 PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, i've added some comments, but they're not strictly necessary.
It's only webpack that we need for server actions right ?
'esbuild', | ||
'uglify-js', | ||
'watchpack', | ||
'webassemblyjs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably add sharp here, people might have installed but it's not needed outside of the image optimization function.
We should probably add a comment to explain it
|
||
#### Reducing Bundle Size | ||
|
||
Next will incorrectly trace dev dependencies to be included in the output `node_modules`, which will significantly increase the lambda bundle. For example, the @swc/core-\* binary is ~33MB! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 13.5.1+ they probably will not even end up in node_modules
, a big part is now bundled by next and may end up in one of the bundle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I built w/ 13.5.4 and the core-darwin-arm64
binary was still there unfortunately
#### Unzipped size must be smaller than 262144000 bytes | ||
|
||
AWS Lambda has an unzipped size limit of 250MB. If your app is over this limit, then it is most likely using a node_module library that is too large for serverless or there is a large dev dependency getting bundled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add that what's important is the .open-next/server-function
folder, and the rest are mostly irrelevant.
We could also add that a big bundle size will increase cold start a lot
As far as I know but it's been awhile since I tested (13.3 I think). |
fixes: #166
Edit: one of the changes breaks server actions 😢
We might be better off removing the dev modules inside
build.ts
...