Skip to content

Commit

Permalink
Eliminate path and utils from base server (#39622)
Browse files Browse the repository at this point in the history
`_isLikeServerless` is only needed by the Node.js server.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
  • Loading branch information
shuding committed Aug 15, 2022
1 parent f743aa1 commit 059fba2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 0 additions & 15 deletions packages/next/server/base-server.ts
Expand Up @@ -28,14 +28,11 @@ import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plug
import type { BaseNextRequest, BaseNextResponse } from './base-http'
import type { PayloadOptions } from './send-payload'

import { join } from '../shared/lib/isomorphic/path'
import { parse as parseQs } from 'querystring'
import { format as formatUrl, parse as parseUrl } from 'url'
import { getRedirectStatus } from '../lib/redirect-status'
import {
NEXT_BUILTIN_DOCUMENT,
SERVERLESS_DIRECTORY,
SERVER_DIRECTORY,
STATIC_STATUS_PAGES,
TEMPORARY_REDIRECT_STATUS,
} from '../shared/lib/constants'
Expand All @@ -46,7 +43,6 @@ import {
checkIsManualRevalidate,
} from './api-utils'
import * as envConfig from '../shared/lib/runtime-config'
import { isTargetLikeServerless } from './utils'
import Router from './router'
import { getPathMatch } from '../shared/lib/router/utils/path-match'
import { setRevalidateHeaders } from './send-payload/revalidate-headers'
Expand Down Expand Up @@ -2124,17 +2120,6 @@ export default abstract class Server<ServerOptions extends Options = Options> {
res.statusCode = 404
return this.renderError(null, req, res, pathname!, query, setHeaders)
}

protected get _isLikeServerless(): boolean {
return isTargetLikeServerless(this.nextConfig.target)
}

protected get serverDistDir() {
return join(
this.distDir,
this._isLikeServerless ? SERVERLESS_DIRECTORY : SERVER_DIRECTORY
)
}
}

export { stringifyQuery } from './server-route-utils'
15 changes: 14 additions & 1 deletion packages/next/server/next-server.ts
Expand Up @@ -39,6 +39,8 @@ import {
CLIENT_PUBLIC_FILES_PATH,
APP_PATHS_MANIFEST,
FLIGHT_SERVER_CSS_MANIFEST,
SERVERLESS_DIRECTORY,
SERVER_DIRECTORY,
} from '../shared/lib/constants'
import { recursiveReadDirSync } from './lib/recursive-readdir-sync'
import { format as formatUrl, UrlWithParsedQuery } from 'url'
Expand Down Expand Up @@ -84,7 +86,7 @@ import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-
import { getNextPathnameInfo } from '../shared/lib/router/utils/get-next-pathname-info'
import { bodyStreamToNodeStream, getClonableBody } from './body-streams'
import { checkIsManualRevalidate } from './api-utils'
import { shouldUseReactRoot } from './utils'
import { shouldUseReactRoot, isTargetLikeServerless } from './utils'
import ResponseCache from './response-cache'
import { IncrementalCache } from './lib/incremental-cache'
import { getSortedRoutes } from '../shared/lib/router/utils/sorted-routes'
Expand Down Expand Up @@ -1710,4 +1712,15 @@ export default class NextNodeServer extends BaseServer {

return result
}

protected get _isLikeServerless(): boolean {
return isTargetLikeServerless(this.nextConfig.target)
}

protected get serverDistDir() {
return join(
this.distDir,
this._isLikeServerless ? SERVERLESS_DIRECTORY : SERVER_DIRECTORY
)
}
}

0 comments on commit 059fba2

Please sign in to comment.