Skip to content

Commit 1b15b11

Browse files
committed
docs: add documentation on minimizing lambda bundle
1 parent 274d446 commit 1b15b11

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,25 @@ await build({
633633

634634
This feature is currently **experimental** and needs to be opted into. It can significantly decrease the server function's cold start time. Once it is thoroughly tested and its stability is confirmed, it will be enabled by default.
635635

636+
#### Reducing Bundle Size
637+
638+
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!
639+
640+
Add this to your next.config.js to help minimize the lambda bundle size:
641+
642+
```typescript
643+
outputFileTracingExcludes: {
644+
'*': [
645+
'**@swc/core**',
646+
'**esbuild**',
647+
'**webpack**',
648+
'**uglify**',
649+
],
650+
},
651+
```
652+
653+
NOTE: NextJS currently doesn't expose an environmental variable to set this so `open-next` cannot programmatically set this like it does for `mode` and `outputFileTracingRoot`
654+
636655
#### Reusing same bucket for asset and cache
637656

638657
Typically, asset files are uploaded to the root of the bucket. However, you might want to store them in a subfolder of the bucket, for instance, when:

0 commit comments

Comments
 (0)