@@ -14,18 +14,18 @@ import * as Sentry from '@sentry/nextjs';
1414import type { GetServerSideProps , GetStaticProps , NextPage as NextPageComponent } from 'next' ;
1515
1616type NextPageModule = {
17- default : { getInitialProps ?: NextPageComponent [ 'getInitialProps' ] } ;
17+ default ? : { getInitialProps ?: NextPageComponent [ 'getInitialProps' ] } ;
1818 getStaticProps ?: GetStaticProps ;
1919 getServerSideProps ?: GetServerSideProps ;
2020} ;
2121
2222const userPageModule = wrapee as NextPageModule ;
2323
24- const pageComponent = userPageModule . default ;
24+ const pageComponent = userPageModule ? userPageModule . default : undefined ;
2525
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 ;
2929
3030const getInitialPropsWrappers : Record < string , any > = {
3131 '/_app' : Sentry . wrapAppGetInitialPropsWithSentry ,
@@ -35,7 +35,7 @@ const getInitialPropsWrappers: Record<string, any> = {
3535
3636const getInitialPropsWrapper = getInitialPropsWrappers [ '__ROUTE__' ] || Sentry . wrapGetInitialPropsWithSentry ;
3737
38- if ( typeof origGetInitialProps === 'function' ) {
38+ if ( pageComponent && typeof origGetInitialProps === 'function' ) {
3939 pageComponent . getInitialProps = getInitialPropsWrapper ( origGetInitialProps ) as NextPageComponent [ 'getInitialProps' ] ;
4040}
4141
0 commit comments