serverless-next.js
serverless-next.js copied to clipboard
🚧 feat: add `build.outputStandalone` option
This is an experimental Work-In-Progress PR for adding support for the new experimental.outputStandalone setting introduced in Next.js 12 https://github.com/vercel/next.js/pull/31003
There's a new minimal next-handler Lambda that currently doesn't support any of the existing serverless-nextjs features.
The build process is also very simple:
- build Next.js with
experimental.outputStandalone: true - copy entire
.next/standaloneas thedefault-lambda - remove the included
.next/standalone/server.js - emit new handler, which creates a Next.js
NextServerand handles the lambda request
What do you think @dphang ? How should we integrate this into the existing stack? Should we make a completely new lambda, or maybe a setting into the default-handler that uses this new file instead of importing pages and using their render method?
Handler Size Report
No changes to handler sizes.
Base Handler Sizes (kB) (commit e31d928e5ceaf093b3eea74420fce49b4cb816d7)
{
"Lambda": {
"Default Lambda": {
"Standard": 1524,
"Minified": 668
},
"Image Lambda": {
"Standard": 1488,
"Minified": 800
}
},
"Lambda@Edge": {
"Default Lambda": {
"Standard": 1534,
"Minified": 673
},
"Default Lambda V2": {
"Standard": 1526,
"Minified": 670
},
"API Lambda": {
"Standard": 634,
"Minified": 318
},
"Image Lambda": {
"Standard": 1496,
"Minified": 805
},
"Regeneration Lambda": {
"Standard": 1187,
"Minified": 546
},
"Regeneration Lambda V2": {
"Standard": 1253,
"Minified": 573
}
}
}
New Handler Sizes (kB) (commit 76f9b532b262c30bd981425650293d462c2ba3f8)
{
"Lambda": {
"Default Lambda": {
"Standard": 1524,
"Minified": 668
},
"Image Lambda": {
"Standard": 1488,
"Minified": 800
}
},
"Lambda@Edge": {
"Default Lambda": {
"Standard": 1534,
"Minified": 673
},
"Default Lambda V2": {
"Standard": 1526,
"Minified": 670
},
"API Lambda": {
"Standard": 634,
"Minified": 318
},
"Image Lambda": {
"Standard": 1496,
"Minified": 805
},
"Regeneration Lambda": {
"Standard": 1187,
"Minified": 546
},
"Regeneration Lambda V2": {
"Standard": 1253,
"Minified": 573
}
}
}
Codecov Report
Merging #2333 (76f9b53) into master (d009f46) will decrease coverage by
0.40%. The diff coverage is66.00%.
@@ Coverage Diff @@
## master #2333 +/- ##
==========================================
- Coverage 83.55% 83.14% -0.41%
==========================================
Files 102 103 +1
Lines 3679 3709 +30
Branches 1176 1186 +10
==========================================
+ Hits 3074 3084 +10
- Misses 593 613 +20
Partials 12 12
| Impacted Files | Coverage Δ | |
|---|---|---|
| packages/libs/lambda-at-edge/src/next-handler.ts | 0.00% <0.00%> (ø) |
|
| ...rless-components/nextjs-component/src/component.ts | 86.15% <75.00%> (-0.21%) |
:arrow_down: |
| packages/libs/lambda-at-edge/src/build.ts | 92.67% <81.08%> (-3.41%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update d009f46...76f9b53. Read the comment docs.
This is an experimental Work-In-Progress PR for adding support for the new
experimental.outputStandalonesetting introduced in Next.js 12 vercel/next.js#31003There's a new minimal
next-handlerLambda that currently doesn't support any of the existingserverless-nextjsfeatures.The build process is also very simple:
- build Next.js with
experimental.outputStandalone: true- copy entire
.next/standaloneas thedefault-lambda- remove the included
.next/standalone/server.js- emit new handler, which creates a Next.js
NextServerand handles the lambda requestWhat do you think @dphang ? How should we integrate this into the existing stack? Should we make a completely new lambda, or maybe a setting into the
default-handlerthat uses this new file instead of importing pages and using theirrendermethod?
Maybe it can be a new lambda if it’s different? Not too familiar with the new handler yet, haven’t kept up with all new features unfortunately…
Looking forward to this feature, thanks to @iiroj works!
For now, Tim is removing target: 'serverless' in nextJS, so it's better we have another way deploying it!
Looking forward to this feature, thanks to @iiroj works! For now, Tim is removing
target: 'serverless'in nextJS, so it's better we have another way deploying it!
Hi! Using the code provided here you managed to deploy the NextJS app using standalone output?
HI @iiroj ! Are you using this solution right now? Or you found a way to deploy Next 12/13 in other way? Thanks.
Hello @nike1v , we have abandoned this effort and went with Vercel... would look into OpenNext maybe: https://open-next.js.org/