File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,23 @@ const makeHandler =
7
7
( ) =>
8
8
// We return a function and then call `toString()` on it to serialise it as the launcher function
9
9
( conf , app ) => {
10
- let nextServerPath
11
-
10
+ let NextServer
12
11
try {
13
12
// next >= 11.0.1. Yay breaking changes in patch releases!
14
- nextServerPath = require . resolve ( 'next/dist/server/next-server' )
13
+ NextServer = require ( 'next/dist/server/next-server' ) . default
15
14
} catch {
16
- // next < 11.0.1
17
- // eslint-disable-next-line node/no-missing-require
18
- nextServerPath = require . resolve ( 'next/dist/next-server/server/next-server' )
15
+ // Probably an old version of next
16
+ }
17
+
18
+ if ( ! NextServer ) {
19
+ try {
20
+ // next < 11.0.1
21
+ // eslint-disable-next-line node/no-missing-require, import/no-unresolved
22
+ NextServer = require ( 'next/dist/next-server/server/next-server' ) . default
23
+ } catch {
24
+ throw new Error ( 'Could not find Next.js server' )
25
+ }
19
26
}
20
- // eslint-disable-next-line import/no-dynamic-require
21
- const { default : NextServer } = require ( nextServerPath )
22
27
23
28
const nextServer = new NextServer ( {
24
29
conf,
You can’t perform that action at this time.
0 commit comments