diff --git a/packages/next/build/babel/plugins/next-page-config.ts b/packages/next/build/babel/plugins/next-page-config.ts index 6ba8bef1a5a3e..481e046d7bdb3 100644 --- a/packages/next/build/babel/plugins/next-page-config.ts +++ b/packages/next/build/babel/plugins/next-page-config.ts @@ -110,6 +110,19 @@ export default function nextPageConfig({ t.returnStatement(t.stringLiteral(inlineGipIdentifier)), ]) }, + // handles class { static async getInitialProps() {} } + ClassMethod(path, state: ConfigState) { + if (!state.setupInlining) return + if ( + (path.node.key && (path.node.key as BabelTypes.Identifier).name) !== + 'getInitialProps' + ) + return + + path.node.body = t.blockStatement([ + t.returnStatement(t.stringLiteral(inlineGipIdentifier)), + ]) + }, }, } } diff --git a/packages/next/export/index.js b/packages/next/export/index.js index 58ec0e62568ad..4f51627dbbb17 100644 --- a/packages/next/export/index.js +++ b/packages/next/export/index.js @@ -105,7 +105,8 @@ export default async function (dir, options, configuration) { dev: false, staticMarkup: false, hotReloader: null, - canonicalBase: (nextConfig.amp && nextConfig.amp.canonicalBase) || '' + canonicalBase: (nextConfig.amp && nextConfig.amp.canonicalBase) || '', + isModern: nextConfig.modern } const { serverRuntimeConfig, publicRuntimeConfig } = nextConfig diff --git a/packages/next/export/worker.js b/packages/next/export/worker.js index f089e8607ed22..256890cb8a4bb 100644 --- a/packages/next/export/worker.js +++ b/packages/next/export/worker.js @@ -119,7 +119,8 @@ process.on( 'static', buildId, 'pages', - (path === '/' ? 'index' : path) + '.js' + (path === '/' ? 'index' : path) + + `${renderOpts.isModern ? '.es6' : ''}.js` ) const bundleContent = await readFileP(bundlePath, 'utf8')