@@ -14,18 +14,18 @@ import * as Sentry from '@sentry/nextjs';
14
14
import type { GetServerSideProps , GetStaticProps , NextPage as NextPageComponent } from 'next' ;
15
15
16
16
type NextPageModule = {
17
- default : { getInitialProps ?: NextPageComponent [ 'getInitialProps' ] } ;
17
+ default ? : { getInitialProps ?: NextPageComponent [ 'getInitialProps' ] } ;
18
18
getStaticProps ?: GetStaticProps ;
19
19
getServerSideProps ?: GetServerSideProps ;
20
20
} ;
21
21
22
22
const userPageModule = wrapee as NextPageModule ;
23
23
24
- const pageComponent = userPageModule . default ;
24
+ const pageComponent = userPageModule ? userPageModule . default : undefined ;
25
25
26
- const origGetInitialProps = pageComponent . getInitialProps ;
27
- const origGetStaticProps = userPageModule . getStaticProps ;
28
- const origGetServerSideProps = userPageModule . getServerSideProps ;
26
+ const origGetInitialProps = pageComponent ? pageComponent . getInitialProps : undefined ;
27
+ const origGetStaticProps = userPageModule ? userPageModule . getStaticProps : undefined ;
28
+ const origGetServerSideProps = userPageModule ? userPageModule . getServerSideProps : undefined ;
29
29
30
30
const getInitialPropsWrappers : Record < string , any > = {
31
31
'/_app' : Sentry . wrapAppGetInitialPropsWithSentry ,
@@ -35,7 +35,7 @@ const getInitialPropsWrappers: Record<string, any> = {
35
35
36
36
const getInitialPropsWrapper = getInitialPropsWrappers [ '__ROUTE__' ] || Sentry . wrapGetInitialPropsWithSentry ;
37
37
38
- if ( typeof origGetInitialProps === 'function' ) {
38
+ if ( pageComponent && typeof origGetInitialProps === 'function' ) {
39
39
pageComponent . getInitialProps = getInitialPropsWrapper ( origGetInitialProps ) as NextPageComponent [ 'getInitialProps' ] ;
40
40
}
41
41
0 commit comments