Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Clean up imports and unused code #39044

Merged
merged 2 commits into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -47,11 +47,13 @@ export default async function edgeSSRLoader(this: any) {
: null

const transformed = `
import { adapter } from 'next/dist/server/web/adapter'
import { adapter, enhanceGlobals } from 'next/dist/server/web/adapter'
import { getRender } from 'next/dist/build/webpack/loaders/next-edge-ssr-loader/render'

import Document from ${stringifiedDocumentPath}

enhanceGlobals()

const appMod = require(${stringifiedAppPath})
const pageMod = require(${stringifiedPagePath})
const errorMod = require(${stringifiedErrorPath})
Expand Down
Expand Up @@ -2,8 +2,7 @@ import type { NextConfig } from '../../../../server/config-shared'
import type { DocumentType, AppType } from '../../../../shared/lib/utils'
import type { BuildManifest } from '../../../../server/get-page-files'
import type { ReactLoadableManifest } from '../../../../server/load-components'

import { NextRequest } from '../../../../server/web/spec-extension/request'
import type { NextRequest } from '../../../../server/web/spec-extension/request'

import WebServer from '../../../../server/web-server'
import {
Expand Down
Expand Up @@ -9,6 +9,7 @@ import type {
GetStaticProps,
} from '../../../../types'
import type { BaseNextRequest } from '../../../../server/base-http'
import type { __ApiPreviewProps } from '../../../../server/api-utils'

import { format as formatUrl, UrlWithParsedQuery, parse as parseUrl } from 'url'
import { parse as parseQs, ParsedUrlQuery } from 'querystring'
Expand All @@ -20,7 +21,6 @@ import {
matchHas,
prepareDestination,
} from '../../../../shared/lib/router/utils/prepare-destination'
import { __ApiPreviewProps } from '../../../../server/api-utils'
import { acceptLanguage } from '../../../../server/accept-header'
import { detectLocaleCookie } from '../../../../shared/lib/i18n/detect-locale-cookie'
import { detectDomainLocale } from '../../../../shared/lib/i18n/detect-domain-locale'
Expand Down
8 changes: 0 additions & 8 deletions packages/next/lib/constants.ts
Expand Up @@ -3,18 +3,10 @@ import { join } from '../shared/lib/isomorphic/path'

export const NEXT_PROJECT_ROOT = join(__dirname, '..', '..')
export const NEXT_PROJECT_ROOT_DIST = join(NEXT_PROJECT_ROOT, 'dist')
export const NEXT_PROJECT_ROOT_NODE_MODULES = join(
NEXT_PROJECT_ROOT,
'node_modules'
)
export const NEXT_PROJECT_ROOT_DIST_CLIENT = join(
NEXT_PROJECT_ROOT_DIST,
'client'
)
export const NEXT_PROJECT_ROOT_DIST_SERVER = join(
NEXT_PROJECT_ROOT_DIST,
'server'
)

// Regex for API routes
export const API_ROUTE = /^\/api(?:\/|$)/
Expand Down
15 changes: 0 additions & 15 deletions packages/next/server/node-web-streams-helper.ts
Expand Up @@ -222,21 +222,6 @@ export function createSuffixStream(
})
}

export function createPrefixStream(
prefix: string
): TransformStream<Uint8Array, Uint8Array> {
let prefixFlushed = false
return new TransformStream({
transform(chunk, controller) {
if (!prefixFlushed) {
controller.enqueue(encodeText(prefix))
prefixFlushed = true
}
controller.enqueue(chunk)
},
})
}

// Suffix after main body content - scripts before </body>,
// but wait for the major chunks to be enqueued.
export function createDeferredSuffixStream(
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/router.ts
Expand Up @@ -5,12 +5,12 @@ import type {
RouteMatch,
Params,
} from '../shared/lib/router/utils/route-matcher'
import type { RouteHas } from '../lib/load-custom-routes'

import { getNextInternalQuery, NextUrlWithParsedQuery } from './request-meta'
import { getPathMatch } from '../shared/lib/router/utils/path-match'
import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-slash'
import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path'
import { RouteHas } from '../lib/load-custom-routes'
import { matchHas } from '../shared/lib/router/utils/prepare-destination'
import { removePathPrefix } from '../shared/lib/router/utils/remove-path-prefix'
import { getRequestMeta } from './request-meta'
Expand Down
2 changes: 0 additions & 2 deletions packages/next/server/utils.ts
Expand Up @@ -40,8 +40,6 @@ export function stripInternalQueries(query: NextParsedUrlQuery) {
delete query.__props__
// routing
delete query.__flight_router_state_tree__

return query
}

// When react version is >= 18 opt-in using reactRoot
Expand Down
3 changes: 2 additions & 1 deletion packages/next/server/web/spec-extension/cookies.ts
@@ -1,5 +1,6 @@
import type { CookieSerializeOptions } from '../types'

import cookie from 'next/dist/compiled/cookie'
import { CookieSerializeOptions } from '../types'

type GetWithOptionsOutput = {
value: string | undefined
Expand Down