From a569f7e65b934b71fb2290bb87f8fcda9be48d1b Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 2 Aug 2024 23:35:49 +0200 Subject: [PATCH] Import from internal modules in `next/server` This entrypoint relied on public `next/*` entrypoints. We want to get rid of public `next/dist/*` entrypoints eventually, so we should start using internal modules. --- packages/next/server.d.ts | 20 ++++++++++---------- packages/next/server.js | 16 +++++++--------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/next/server.d.ts b/packages/next/server.d.ts index 872bbc3899ff1..e74697330d377 100644 --- a/packages/next/server.d.ts +++ b/packages/next/server.d.ts @@ -4,13 +4,13 @@ declare global { var AsyncLocalStorage: typeof NodeAsyncLocalStorage } -export { NextFetchEvent } from 'next/dist/server/web/spec-extension/fetch-event' -export { NextRequest } from 'next/dist/server/web/spec-extension/request' -export { NextResponse } from 'next/dist/server/web/spec-extension/response' -export { NextMiddleware, MiddlewareConfig } from 'next/dist/server/web/types' -export { userAgentFromString } from 'next/dist/server/web/spec-extension/user-agent' -export { userAgent } from 'next/dist/server/web/spec-extension/user-agent' -export { URLPattern } from 'next/dist/compiled/@edge-runtime/primitives/url' -export { ImageResponse } from 'next/dist/server/web/spec-extension/image-response' -export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og/types' -export { unstable_after } from 'next/dist/server/after' +export { NextFetchEvent } from './dist/server/web/spec-extension/fetch-event' +export { NextRequest } from './dist/server/web/spec-extension/request' +export { NextResponse } from './dist/server/web/spec-extension/response' +export { NextMiddleware, MiddlewareConfig } from './dist/server/web/types' +export { userAgentFromString } from './dist/server/web/spec-extension/user-agent' +export { userAgent } from './dist/server/web/spec-extension/user-agent' +export { URLPattern } from './dist/compiled/@edge-runtime/primitives/url' +export { ImageResponse } from './dist/server/web/spec-extension/image-response' +export type { ImageResponseOptions } from './dist/compiled/@vercel/og/types' +export { unstable_after } from './dist/server/after' diff --git a/packages/next/server.js b/packages/next/server.js index 589a789dfe66b..0c14fa093c4e2 100644 --- a/packages/next/server.js +++ b/packages/next/server.js @@ -1,17 +1,15 @@ const serverExports = { - NextRequest: require('next/dist/server/web/spec-extension/request') - .NextRequest, - NextResponse: require('next/dist/server/web/spec-extension/response') + NextRequest: require('./dist/server/web/spec-extension/request').NextRequest, + NextResponse: require('./dist/server/web/spec-extension/response') .NextResponse, - ImageResponse: require('next/dist/server/web/spec-extension/image-response') + ImageResponse: require('./dist/server/web/spec-extension/image-response') .ImageResponse, - userAgentFromString: require('next/dist/server/web/spec-extension/user-agent') + userAgentFromString: require('./dist/server/web/spec-extension/user-agent') .userAgentFromString, - userAgent: require('next/dist/server/web/spec-extension/user-agent') - .userAgent, - URLPattern: require('next/dist/server/web/spec-extension/url-pattern') + userAgent: require('./dist/server/web/spec-extension/user-agent').userAgent, + URLPattern: require('./dist/server/web/spec-extension/url-pattern') .URLPattern, - unstable_after: require('next/dist/server/after').unstable_after, + unstable_after: require('./dist/server/after').unstable_after, } // https://nodejs.org/api/esm.html#commonjs-namespaces