Skip to content

Commit

Permalink
fix serverless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Mar 29, 2022
1 parent 814a361 commit 911ba59
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 28 deletions.
5 changes: 2 additions & 3 deletions packages/next/build/entries.ts
Expand Up @@ -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
Expand Down
Expand Up @@ -18,6 +18,7 @@ export type ServerlessLoaderQuery = {
distDir: string
absolutePagePath: string
absoluteAppPath: string
absoluteAppServerPath: string
absoluteDocumentPath: string
absoluteErrorPath: string
absolute404Path: string
Expand Down
Expand Up @@ -65,7 +65,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) {
_params?: any
) {
let Component
let App
let AppMod
let config
let Document
let Error
Expand All @@ -78,7 +78,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) {
getServerSideProps,
getStaticPaths,
Component,
App,
AppMod,
config,
{ default: Document },
{ default: Error },
Expand All @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions packages/next/client/index.tsx
Expand Up @@ -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<{
Expand Down Expand Up @@ -289,7 +288,6 @@ export async function hydrate(opts?: { beforeRender?: () => Promise<void> }) {

const { component: app, exports: mod } = appEntrypoint
CachedApp = app as AppComponent
isAppRSC = !!mod.__next_rsc__
const exportedReportWebVitals = mod && mod.reportWebVitals
onPerfEntry = ({
id,
Expand Down
6 changes: 0 additions & 6 deletions packages/next/pages/_app.server.tsx

This file was deleted.

15 changes: 1 addition & 14 deletions packages/next/taskfile.js
Expand Up @@ -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')
Expand All @@ -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
)
}
Expand Down

0 comments on commit 911ba59

Please sign in to comment.