Skip to content

Commit 54a150b

Browse files
committed
update docs
1 parent 6efbc25 commit 54a150b

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

Diff for: docs/pages/common_issues.mdx

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ If you are using sentry, API routes returns empty body. You could try configurin
1414

1515
#### My ISR page has this cache-control header `s-maxage=2, stale-while-revalidate=2592000`
1616

17-
Given how ISR works, while waiting for the revalidation to happen, the page will be served using this cache control header. This prevent your server from being overloaded by a lot of requests while the revalidation is done. You can read more about it [here](/inner_workings/isr).
17+
Given how ISR works, while waiting for the revalidation to happen, the page will be served using this cache control header. This prevent your server from being overloaded by a lot of requests while the revalidation is done. You can read more about it [here](/inner_workings/isr).
18+
19+
#### Unzipped size must be smaller than 262144000 bytes
20+
21+
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.
22+
For example, `pdfjs` has `canvas` optional dependency which takes up 180MB. For more details, [read me](/common_issues/bundle_size)

Diff for: docs/pages/common_issues/bundle_size.mdx

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {Callout} from 'nextra/components'
2+
3+
4+
#### Reducing Bundle Size
5+
6+
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!
7+
8+
Add this to your next.config.js to help minimize the lambda bundle size:
9+
10+
```typescript
11+
outputFileTracingExcludes: {
12+
'*': [
13+
'@swc/core',
14+
'esbuild',
15+
'uglify-js',
16+
'watchpack',
17+
'webassemblyjs'
18+
],
19+
},
20+
```
21+
22+
<Callout type="warning" emoji="⚠️">
23+
NextJS currently doesn't expose `outputFileTracingExcludes` as an environmental variable so `open-next`cannot programmatically set this like it does for`output`and`outputFileTracingRoot`.
24+
Currently, next uses `webpack` to trace server actions, so you shouldn't add `webpack` to the excludes list, otherwise it will break server actions.
25+
</Callout>
26+
27+
#### Unzipped size must be smaller than 262144000 bytes
28+
29+
To identify the module that's taking up too much space (and isn't serverless friendly):
30+
31+
```bash
32+
du -hs .open-next/server-function/node_modules/* | sort -rh
33+
```
34+
35+
If your app requires the offending library, then consider moving your business logic of the `api` to its own lambda, eg: `/api/v2` => `Api Lambda`
36+
37+
<Callout type="info" emoji="ℹ️">
38+
There is a [PR](https://github.com/sst/open-next/pull/242) to remove some dev dependency from the output node_modules but that requires more testing before it can merge.
39+
</Callout>

0 commit comments

Comments
 (0)