diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index 806a178e255335..bfa98f095fa101 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -98,15 +98,14 @@ export function createPagesMapping( pages['/_error'] = `${PAGES_DIR_ALIAS}/_error` pages['/_document'] = `${PAGES_DIR_ALIAS}/_document` if (hasServerComponents) { - pages['/_app.server'] = `${PAGES_DIR_ALIAS}/_app.server` + pages['/_app.server'] = `${PAGES_DIR_ALIAS}/_app.server` || pages['/_app'] } } else { pages['/_app'] = pages['/_app'] || 'next/dist/pages/_app' pages['/_error'] = pages['/_error'] || 'next/dist/pages/_error' pages['/_document'] = pages['/_document'] || `next/dist/pages/_document` if (hasServerComponents) { - pages['/_app.server'] = - pages['/_app.server'] || 'next/dist/pages/_app.server' + pages['/_app.server'] = pages['/_app.server'] || pages['/_app'] // 'next/dist/pages/_app.server' } } return pages diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/index.ts b/packages/next/build/webpack/loaders/next-serverless-loader/index.ts index 08e517fabed880..dfcf7e26c58ea9 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/index.ts @@ -18,6 +18,7 @@ export type ServerlessLoaderQuery = { distDir: string absolutePagePath: string absoluteAppPath: string + absoluteAppServerPath: string absoluteDocumentPath: string absoluteErrorPath: string absolute404Path: string diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts b/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts index 8331054269a580..206968d162f665 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts @@ -65,7 +65,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) { _params?: any ) { let Component - let App + let AppMod let config let Document let Error @@ -78,7 +78,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) { getServerSideProps, getStaticPaths, Component, - App, + AppMod, config, { default: Document }, { default: Error }, @@ -103,7 +103,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) { setLazyProp({ req: req as any }, 'cookies', getCookieParser(req.headers)) const options = { - App, + AppMod, Document, buildManifest, getStaticProps, diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx index bda46566a74731..8e99aca67b7fa1 100644 --- a/packages/next/client/index.tsx +++ b/packages/next/client/index.tsx @@ -87,7 +87,6 @@ let webpackHMR: any let CachedApp: AppComponent, onPerfEntry: (metric: any) => void let CachedComponent: React.ComponentType -let isAppRSC: boolean let isRSCPage: boolean class Container extends React.Component<{ @@ -289,7 +288,6 @@ export async function hydrate(opts?: { beforeRender?: () => Promise }) { const { component: app, exports: mod } = appEntrypoint CachedApp = app as AppComponent - isAppRSC = !!mod.__next_rsc__ const exportedReportWebVitals = mod && mod.reportWebVitals onPerfEntry = ({ id, diff --git a/packages/next/pages/_app.server.tsx b/packages/next/pages/_app.server.tsx deleted file mode 100644 index 993aef49d48d71..00000000000000 --- a/packages/next/pages/_app.server.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react' - -export type AppProps = { children: React.ReactNode } -export default function AppServer({ children }: AppProps) { - return children -} diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 8d0ddaa7c19d3b..f90ee195447f79 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1829,13 +1829,6 @@ export async function pages_app(task, opts) { .target('dist/pages') } -export async function pages_app_server(task, opts) { - await task - .source('pages/_app.server.tsx') - .swc('client', { dev: opts.dev, keepImportAssertions: true }) - .target('dist/pages') -} - export async function pages_error(task, opts) { await task .source('pages/_error.tsx') @@ -1859,13 +1852,7 @@ export async function pages_document_server(task, opts) { export async function pages(task, opts) { await task.parallel( - [ - 'pages_app', - 'pages_app_server', - 'pages_error', - 'pages_document', - 'pages_document_server', - ], + ['pages_app', 'pages_error', 'pages_document', 'pages_document_server'], opts ) }