From e4c2a6d176ccc304be0b705a1ac1fdbeb22f6a1b Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Tue, 26 Jul 2022 23:04:35 +0200 Subject: [PATCH] clean up imports --- .../webpack/loaders/next-edge-ssr-loader/index.ts | 4 +++- .../loaders/next-edge-ssr-loader/render.ts | 3 +-- .../loaders/next-serverless-loader/utils.ts | 2 +- packages/next/lib/constants.ts | 8 -------- packages/next/server/node-web-streams-helper.ts | 15 --------------- packages/next/server/router.ts | 2 +- packages/next/server/utils.ts | 2 -- .../next/server/web/spec-extension/cookies.ts | 3 ++- 8 files changed, 8 insertions(+), 31 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-edge-ssr-loader/index.ts b/packages/next/build/webpack/loaders/next-edge-ssr-loader/index.ts index 3dea58871d7e..52ec6985f443 100644 --- a/packages/next/build/webpack/loaders/next-edge-ssr-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-edge-ssr-loader/index.ts @@ -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}) diff --git a/packages/next/build/webpack/loaders/next-edge-ssr-loader/render.ts b/packages/next/build/webpack/loaders/next-edge-ssr-loader/render.ts index e8d4660e87cb..ef06de8cb46f 100644 --- a/packages/next/build/webpack/loaders/next-edge-ssr-loader/render.ts +++ b/packages/next/build/webpack/loaders/next-edge-ssr-loader/render.ts @@ -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 { diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts b/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts index 19d6c724c5b1..0763c0f423ce 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts @@ -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' @@ -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' diff --git a/packages/next/lib/constants.ts b/packages/next/lib/constants.ts index b7cc3197ee9b..6571d0fc6254 100644 --- a/packages/next/lib/constants.ts +++ b/packages/next/lib/constants.ts @@ -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(?:\/|$)/ diff --git a/packages/next/server/node-web-streams-helper.ts b/packages/next/server/node-web-streams-helper.ts index 07e162daf9cd..0da387cbeffd 100644 --- a/packages/next/server/node-web-streams-helper.ts +++ b/packages/next/server/node-web-streams-helper.ts @@ -222,21 +222,6 @@ export function createSuffixStream( }) } -export function createPrefixStream( - prefix: string -): TransformStream { - 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 , // but wait for the major chunks to be enqueued. export function createDeferredSuffixStream( diff --git a/packages/next/server/router.ts b/packages/next/server/router.ts index e472e7d05dd3..237188c8ca5e 100644 --- a/packages/next/server/router.ts +++ b/packages/next/server/router.ts @@ -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' diff --git a/packages/next/server/utils.ts b/packages/next/server/utils.ts index dcf4de4ea570..856f5f703262 100644 --- a/packages/next/server/utils.ts +++ b/packages/next/server/utils.ts @@ -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 diff --git a/packages/next/server/web/spec-extension/cookies.ts b/packages/next/server/web/spec-extension/cookies.ts index b167fd034f41..d29c8a0576db 100644 --- a/packages/next/server/web/spec-extension/cookies.ts +++ b/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