Improve serverless build performance (#9155)
Improve serverless build performance (#9155)

* Improve serverless build performance

Next's serverless build uses a custom resolver, injected the via Webpack's `externals` option that delegates out to `resolve-request` to more aggressively pull node modules into the serverless bundles.

When profiling a large Next.js application, I noticed an excessive number of filesystem calls near the end of the build. I narrowed this down to the serverless compiler pass, and eventually the custom resolver function that is the subject of this PR.  As it turns out, around half of the calls to the `externals` custom resolver function are for a `request` path that is a relative import. Next doesn't have any specific logic to apply to relative imports - it only needs to special-case bare module resolution.

Adding a simple bypass for relative module resolution reduces the number of blocking filesystem-bound `resolveRequest()` calls by 50% on a certain well-known Next.js website. This also results in a 30% reduction in production build times for incremental builds.

* Explain more in the comment

flybayer/next.js,flybayer/next.js,flybayer/next.js,azukaru/next.js,zeit/next.js,azukaru/next.js,flybayer/next.js,JeromeFitz/next.js,zeit/next.js,JeromeFitz/next.js,JeromeFitz/next.js,azukaru/next.js,JeromeFitz/next.js,azukaru/next.js,zeit/next.js