Closed rauchg closed 5 years ago
The approach outlined in the initial issue evolved into the serverless
target, we recommend you use that.
@timneutkens serverless
target doesn't and can not solve problems with custom server, which uses dynamic routes. #5927 Is not a solution for a lot of real world business applications like in my case, where we have to use dynamically generated pages, assets prefix, custom _app, _document and _err: basically everything stated in TODO list.
next-server
gives us partial solution to deploy to production without weird development only dependencies, like webpack and babel. This can be done however with some hacks and woodoo dancing, that we are discussing here.
I was under impression that you understand this difference and was hoping to see more robust solution someday to the initial issue as it is described by @rauchg
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
The problem: when optimizing for a production build, invoking
next start
or usingrequire('next')
within a customserver.js
involves bringing the entire set ofnext
dependencies, including the ones related exclusively to development, such aswebpack
.Not only is this problematic from a build image standpoint and download time performance when generating production builds, but it also likely hurts bootup time. Note: This is lessened by the fact that we carefully lazily load heavy dependencies such as
webpack
in dev mode.For the performance conscious and those sensitive to cold start times (see for example: https://twitter.com/rauchg/status/990667331205447680), we can introduce a
next-server
package.It would have the same capabilities as
require('next')
minus all development-time settings, plus a very smallnext-server
CLI that can open a port and perform graceful shutdown.What we want to optimize for:
next-server
has to be as small as possibleFurthermore, we should provide an example in
examples/
of how to usenext-server
in combination withpkg
to export your Next.js application as a self-contained ELF binary.