From 993c7ccb7a752ed16aa85768c4aab06dc285aa44 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 30 Jun 2021 12:07:55 +0200 Subject: [PATCH] Move next-server directory files to server directory --- packages/next/build/entries.ts | 8 ++-- packages/next/build/index.ts | 12 ++--- packages/next/build/utils.ts | 8 ++-- packages/next/build/webpack-config.ts | 6 +-- packages/next/build/webpack/config/index.ts | 2 +- packages/next/build/webpack/config/utils.ts | 2 +- .../webpack/loaders/next-image-loader.js | 2 +- .../next-serverless-loader/api-handler.ts | 2 +- .../loaders/next-serverless-loader/index.ts | 6 +-- .../next-serverless-loader/page-handler.ts | 13 +++--- .../loaders/next-serverless-loader/utils.ts | 8 ++-- .../webpack/plugins/build-manifest-plugin.ts | 4 +- .../font-stylesheet-gathering-plugin.ts | 2 +- .../nextjs-require-cache-hot-reloader.ts | 4 +- .../plugins/nextjs-ssr-module-cache.ts | 2 +- .../webpack/plugins/pages-manifest-plugin.ts | 2 +- packages/next/cli/next-lint.ts | 2 +- packages/next/client/image.tsx | 2 +- packages/next/export/index.ts | 6 +-- packages/next/export/worker.ts | 12 ++--- packages/next/lib/load-custom-routes.ts | 2 +- packages/next/pages/_document.tsx | 7 +-- .../{next-server => }/server/api-utils.ts | 6 +-- .../{next-server => }/server/config-shared.ts | 2 +- .../server/config-utils-worker.ts | 9 ++-- .../{next-server => }/server/config-utils.ts | 4 +- .../next/{next-server => }/server/config.ts | 11 ++--- .../{next-server => }/server/crypto-utils.ts | 0 .../server/denormalize-page-path.ts | 0 .../next/server/{ => dev}/hot-middleware.ts | 0 .../next/server/{ => dev}/hot-reloader.ts | 35 +++++++-------- .../next/server/{ => dev}/next-dev-server.ts | 42 +++++++++--------- .../{ => dev}/on-demand-entry-handler.ts | 13 +++--- .../server/{ => dev}/static-paths-worker.ts | 8 ++-- .../{next-server => }/server/font-utils.ts | 4 +- .../server/get-page-files.ts | 0 .../server/get-route-from-entrypoint.ts | 2 +- .../{next-server => }/server/image-config.ts | 0 .../server/image-optimizer.ts | 4 +- .../server/incremental-cache.ts | 4 +- packages/next/server/lib/find-page-file.ts | 2 +- .../server/lib/recursive-readdir-sync.ts | 0 .../server/lib/squoosh/LICENSE | 0 .../server/lib/squoosh/codecs.ts | 0 .../server/lib/squoosh/emscripten-utils.ts | 0 .../server/lib/squoosh/image_data.ts | 0 .../server/lib/squoosh/impl.ts | 0 .../server/lib/squoosh/main.ts | 2 +- .../lib/squoosh/mozjpeg/mozjpeg_node_dec.js | 0 .../lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm | Bin .../lib/squoosh/mozjpeg/mozjpeg_node_enc.js | 0 .../lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm | Bin .../server/lib/squoosh/png/squoosh_oxipng.js | 0 .../lib/squoosh/png/squoosh_oxipng_bg.wasm | Bin .../server/lib/squoosh/png/squoosh_png.js | 0 .../lib/squoosh/png/squoosh_png_bg.wasm | Bin .../lib/squoosh/resize/squoosh_resize.js | 0 .../lib/squoosh/resize/squoosh_resize_bg.wasm | Bin .../server/lib/squoosh/rotate/rotate.wasm | Bin .../server/lib/squoosh/text-decoder.ts | 0 .../server/lib/squoosh/webp/webp_node_dec.js | 0 .../lib/squoosh/webp/webp_node_dec.wasm | Bin .../server/lib/squoosh/webp/webp_node_enc.js | 0 .../lib/squoosh/webp/webp_node_enc.wasm | Bin .../server/load-components.ts | 4 +- .../{next-server => }/server/next-server.ts | 42 ++++++++---------- packages/next/server/next.ts | 13 +++--- .../server/node-polyfill-fetch.js | 0 .../server/normalize-page-path.ts | 0 .../{next-server => }/server/optimize-amp.ts | 0 .../next/{next-server => }/server/render.tsx | 36 +++++++-------- .../next/{next-server => }/server/require.ts | 6 +-- .../next/{next-server => }/server/router.ts | 10 ++--- .../{next-server => }/server/send-payload.ts | 2 +- .../{next-server => }/server/serve-static.ts | 0 .../next/{next-server => }/server/utils.ts | 2 +- packages/next/shared/lib/router/router.ts | 4 +- packages/next/shared/lib/utils.ts | 4 +- packages/next/taskfile.js | 20 ++------- packages/next/telemetry/events/version.ts | 2 +- packages/next/types/index.d.ts | 2 +- 81 files changed, 184 insertions(+), 225 deletions(-) rename packages/next/{next-server => }/server/api-utils.ts (99%) rename packages/next/{next-server => }/server/config-shared.ts (97%) rename packages/next/{next-server => }/server/config-utils-worker.ts (90%) rename packages/next/{next-server => }/server/config-utils.ts (94%) rename packages/next/{next-server => }/server/config.ts (98%) rename packages/next/{next-server => }/server/crypto-utils.ts (100%) rename packages/next/{next-server => }/server/denormalize-page-path.ts (100%) rename packages/next/server/{ => dev}/hot-middleware.ts (100%) rename packages/next/server/{ => dev}/hot-reloader.ts (94%) rename packages/next/server/{ => dev}/next-dev-server.ts (94%) rename packages/next/server/{ => dev}/on-demand-entry-handler.ts (96%) rename packages/next/server/{ => dev}/static-paths-worker.ts (81%) rename packages/next/{next-server => }/server/font-utils.ts (93%) rename packages/next/{next-server => }/server/get-page-files.ts (100%) rename packages/next/{next-server => }/server/get-route-from-entrypoint.ts (88%) rename packages/next/{next-server => }/server/image-config.ts (100%) rename packages/next/{next-server => }/server/image-optimizer.ts (99%) rename packages/next/{next-server => }/server/incremental-cache.ts (98%) rename packages/next/{next-server => }/server/lib/recursive-readdir-sync.ts (100%) rename packages/next/{next-server => }/server/lib/squoosh/LICENSE (100%) rename packages/next/{next-server => }/server/lib/squoosh/codecs.ts (100%) rename packages/next/{next-server => }/server/lib/squoosh/emscripten-utils.ts (100%) rename packages/next/{next-server => }/server/lib/squoosh/image_data.ts (100%) rename packages/next/{next-server => }/server/lib/squoosh/impl.ts (100%) rename packages/next/{next-server => }/server/lib/squoosh/main.ts (97%) rename packages/next/{next-server => }/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/png/squoosh_oxipng.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/png/squoosh_oxipng_bg.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/png/squoosh_png.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/png/squoosh_png_bg.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/resize/squoosh_resize.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/resize/squoosh_resize_bg.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/rotate/rotate.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/text-decoder.ts (100%) rename packages/next/{next-server => }/server/lib/squoosh/webp/webp_node_dec.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/webp/webp_node_dec.wasm (100%) rename packages/next/{next-server => }/server/lib/squoosh/webp/webp_node_enc.js (100%) rename packages/next/{next-server => }/server/lib/squoosh/webp/webp_node_enc.wasm (100%) rename packages/next/{next-server => }/server/load-components.ts (96%) rename packages/next/{next-server => }/server/next-server.ts (98%) rename packages/next/{next-server => }/server/node-polyfill-fetch.js (100%) rename packages/next/{next-server => }/server/normalize-page-path.ts (100%) rename packages/next/{next-server => }/server/optimize-amp.ts (100%) rename packages/next/{next-server => }/server/render.tsx (97%) rename packages/next/{next-server => }/server/require.ts (90%) rename packages/next/{next-server => }/server/router.ts (96%) rename packages/next/{next-server => }/server/send-payload.ts (98%) rename packages/next/{next-server => }/server/serve-static.ts (100%) rename packages/next/{next-server => }/server/utils.ts (88%) diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index 07fa0180433cf..3ec8c606caf87 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -2,14 +2,14 @@ import chalk from 'chalk' import { posix, join } from 'path' import { stringify } from 'querystring' import { API_ROUTE, DOT_NEXT_ALIAS, PAGES_DIR_ALIAS } from '../lib/constants' -import { __ApiPreviewProps } from '../next-server/server/api-utils' -import { isTargetLikeServerless } from '../next-server/server/config' -import { normalizePagePath } from '../next-server/server/normalize-page-path' +import { __ApiPreviewProps } from '../server/api-utils' +import { isTargetLikeServerless } from '../server/config' +import { normalizePagePath } from '../server/normalize-page-path' import { warn } from './output/log' import { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-loader' import { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader' import { LoadedEnvFiles } from '@next/env' -import { NextConfig } from '../next-server/server/config' +import { NextConfig } from '../server/config' type PagesMapping = { [page: string]: string diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 9c3279e5b6170..378d9ff07f96b 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -51,15 +51,15 @@ import { getSortedRoutes, isDynamicRoute, } from '../shared/lib/router/utils' -import { __ApiPreviewProps } from '../next-server/server/api-utils' +import { __ApiPreviewProps } from '../server/api-utils' import loadConfig, { isTargetLikeServerless, NextConfig, -} from '../next-server/server/config' -import { BuildManifest } from '../next-server/server/get-page-files' -import '../next-server/server/node-polyfill-fetch' -import { normalizePagePath } from '../next-server/server/normalize-page-path' -import { getPagePath } from '../next-server/server/require' +} from '../server/config' +import { BuildManifest } from '../server/get-page-files' +import '../server/node-polyfill-fetch' +import { normalizePagePath } from '../server/normalize-page-path' +import { getPagePath } from '../server/require' import * as ciEnvironment from '../telemetry/ci-info' import { eventBuildCompleted, diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index b1260a7a71ed2..0f45e3e7d9202 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -1,4 +1,4 @@ -import '../next-server/server/node-polyfill-fetch' +import '../server/node-polyfill-fetch' import chalk from 'chalk' import getGzipSize from 'next/dist/compiled/gzip-size' import textTable from 'next/dist/compiled/text-table' @@ -24,13 +24,13 @@ import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic' import escapePathDelimiters from '../shared/lib/router/utils/escape-path-delimiters' import { findPageFile } from '../server/lib/find-page-file' import { GetStaticPaths } from 'next/types' -import { denormalizePagePath } from '../next-server/server/normalize-page-path' -import { BuildManifest } from '../next-server/server/get-page-files' +import { denormalizePagePath } from '../server/normalize-page-path' +import { BuildManifest } from '../server/get-page-files' import { removePathTrailingSlash } from '../client/normalize-trailing-slash' import { UnwrapPromise } from '../lib/coalesced-function' import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' import * as Log from './output/log' -import { loadComponents } from '../next-server/server/load-components' +import { loadComponents } from '../server/load-components' import { trace } from '../telemetry/trace' const fileGzipStats: { [k: string]: Promise | undefined } = {} diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index b1986a6defc1a..4fc297eb7b087 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -27,7 +27,7 @@ import { SERVER_DIRECTORY, } from '../shared/lib/constants' import { execOnce } from '../shared/lib/utils' -import { NextConfig } from '../next-server/server/config' +import { NextConfig } from '../server/config' import { findPageFile } from '../server/lib/find-page-file' import { WebpackEntrypoints } from './entries' import * as Log from './output/log' @@ -709,10 +709,10 @@ export default async function getBaseWebpackConfig( } if (isLocal) { - // Makes sure dist/shared and dist/next-server are not bundled + // Makes sure dist/shared and dist/server are not bundled // we need to process shared/lib/router/router so that // the DefinePlugin can inject process.env values - const isNextExternal = /next[/\\]dist[/\\](shared|next-server)[/\\](?!lib[/\\]router[/\\]router)/.test( + const isNextExternal = /next[/\\]dist[/\\](shared|server)[/\\](?!lib[/\\]router[/\\]router)/.test( res ) diff --git a/packages/next/build/webpack/config/index.ts b/packages/next/build/webpack/config/index.ts index 16ee6224fe1c8..e250bfee11c1e 100644 --- a/packages/next/build/webpack/config/index.ts +++ b/packages/next/build/webpack/config/index.ts @@ -1,5 +1,5 @@ import { webpack } from 'next/dist/compiled/webpack/webpack' -import { NextConfig } from '../../../next-server/server/config' +import { NextConfig } from '../../../server/config' import { base } from './blocks/base' import { css } from './blocks/css' import { ConfigurationContext, pipe } from './utils' diff --git a/packages/next/build/webpack/config/utils.ts b/packages/next/build/webpack/config/utils.ts index 574e3d802261e..d61df5dc73348 100644 --- a/packages/next/build/webpack/config/utils.ts +++ b/packages/next/build/webpack/config/utils.ts @@ -1,5 +1,5 @@ import { webpack } from 'next/dist/compiled/webpack/webpack' -import { NextConfig } from '../../../next-server/server/config' +import { NextConfig } from '../../../server/config' export type ConfigurationContext = { rootDirectory: string diff --git a/packages/next/build/webpack/loaders/next-image-loader.js b/packages/next/build/webpack/loaders/next-image-loader.js index 62906792ea725..49497f88cabb1 100644 --- a/packages/next/build/webpack/loaders/next-image-loader.js +++ b/packages/next/build/webpack/loaders/next-image-loader.js @@ -1,6 +1,6 @@ import loaderUtils from 'next/dist/compiled/loader-utils' import sizeOf from 'image-size' -import { processBuffer } from '../../../next-server/server/lib/squoosh/main' +import { processBuffer } from '../../../server/lib/squoosh/main' const BLUR_IMG_SIZE = 8 const BLUR_QUALITY = 70 diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/api-handler.ts b/packages/next/build/webpack/loaders/next-serverless-loader/api-handler.ts index 0578e9d7426db..71c050ba0e1ee 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/api-handler.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/api-handler.ts @@ -1,6 +1,6 @@ import { parse as parseUrl } from 'url' import { IncomingMessage, ServerResponse } from 'http' -import { apiResolver } from '../../../../next-server/server/api-utils' +import { apiResolver } from '../../../../server/api-utils' import { getUtils, vercelHeader, ServerlessHandlerCtx } from './utils' export function getApiHandler(ctx: ServerlessHandlerCtx) { diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/index.ts b/packages/next/build/webpack/loaders/next-serverless-loader/index.ts index 5a57643f59d2a..d64ece16177d6 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/index.ts @@ -5,7 +5,7 @@ import { parse } from 'querystring' import { webpack } from 'next/dist/compiled/webpack/webpack' import { API_ROUTE } from '../../../../lib/constants' import { isDynamicRoute } from '../../../../shared/lib/router/utils' -import { __ApiPreviewProps } from '../../../../next-server/server/api-utils' +import { __ApiPreviewProps } from '../../../../server/api-utils' import { BUILD_MANIFEST, ROUTES_MANIFEST, @@ -99,7 +99,7 @@ const nextServerlessLoader: webpack.loader.Loader = function () { */ runtimeConfigSetter } - import 'next/dist/next-server/server/node-polyfill-fetch' + import 'next/dist/server/node-polyfill-fetch' import routesManifest from '${routesManifest}' import { getApiHandler } from 'next/dist/build/webpack/loaders/next-serverless-loader/api-handler' @@ -127,7 +127,7 @@ const nextServerlessLoader: webpack.loader.Loader = function () { ` } else { return ` - import 'next/dist/next-server/server/node-polyfill-fetch' + import 'next/dist/server/node-polyfill-fetch' import routesManifest from '${routesManifest}' import buildManifest from '${buildManifest}' import reactLoadableManifest from '${reactLoadableManifest}' diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts b/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts index 8f9bba0f42f90..00e2f4c5ab244 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/page-handler.ts @@ -1,16 +1,13 @@ import { IncomingMessage, ServerResponse } from 'http' import { parse as parseUrl, format as formatUrl, UrlWithParsedQuery } from 'url' import { isResSent } from '../../../../shared/lib/utils' -import { sendPayload } from '../../../../next-server/server/send-payload' +import { sendPayload } from '../../../../server/send-payload' import { getUtils, vercelHeader, ServerlessHandlerCtx } from './utils' -import { renderToHTML } from '../../../../next-server/server/render' -import { tryGetPreviewData } from '../../../../next-server/server/api-utils' -import { denormalizePagePath } from '../../../../next-server/server/denormalize-page-path' -import { - setLazyProp, - getCookieParser, -} from '../../../../next-server/server/api-utils' +import { renderToHTML } from '../../../../server/render' +import { tryGetPreviewData } from '../../../../server/api-utils' +import { denormalizePagePath } from '../../../../server/denormalize-page-path' +import { setLazyProp, getCookieParser } from '../../../../server/api-utils' import { getRedirectStatus } from '../../../../lib/load-custom-routes' import getRouteNoAssetPath from '../../../../shared/lib/router/utils/get-route-from-asset-path' import { PERMANENT_REDIRECT_STATUS } from '../../../../shared/lib/constants' 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 7e5342ce071c1..f65f7265e1859 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts @@ -9,8 +9,8 @@ import { getRouteMatcher } from '../../../../shared/lib/router/utils/route-match import prepareDestination, { matchHas, } from '../../../../shared/lib/router/utils/prepare-destination' -import { __ApiPreviewProps } from '../../../../next-server/server/api-utils' -import { BuildManifest } from '../../../../next-server/server/get-page-files' +import { __ApiPreviewProps } from '../../../../server/api-utils' +import { BuildManifest } from '../../../../server/get-page-files' import { GetServerSideProps, GetStaticPaths, @@ -19,10 +19,10 @@ import { import accept from '@hapi/accept' import { detectLocaleCookie } from '../../../../shared/lib/i18n/detect-locale-cookie' import { detectDomainLocale } from '../../../../shared/lib/i18n/detect-domain-locale' -import { denormalizePagePath } from '../../../../next-server/server/denormalize-page-path' +import { denormalizePagePath } from '../../../../server/denormalize-page-path' import cookie from 'next/dist/compiled/cookie' import { TEMPORARY_REDIRECT_STATUS } from '../../../../shared/lib/constants' -import { NextConfig } from '../../../../next-server/server/config' +import { NextConfig } from '../../../../server/config' const getCustomRouteMatcher = pathMatch(true) diff --git a/packages/next/build/webpack/plugins/build-manifest-plugin.ts b/packages/next/build/webpack/plugins/build-manifest-plugin.ts index 684a15b0c7e41..2f5cb4d23f624 100644 --- a/packages/next/build/webpack/plugins/build-manifest-plugin.ts +++ b/packages/next/build/webpack/plugins/build-manifest-plugin.ts @@ -12,8 +12,8 @@ import { CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH, CLIENT_STATIC_FILES_RUNTIME_AMP, } from '../../../shared/lib/constants' -import { BuildManifest } from '../../../next-server/server/get-page-files' -import getRouteFromEntrypoint from '../../../next-server/server/get-route-from-entrypoint' +import { BuildManifest } from '../../../server/get-page-files' +import getRouteFromEntrypoint from '../../../server/get-route-from-entrypoint' import { ampFirstEntryNamesMap } from './next-drop-client-page-plugin' import { Rewrite } from '../../../lib/load-custom-routes' import { getSortedRoutes } from '../../../shared/lib/router/utils' diff --git a/packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts b/packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts index 05eaf32f32097..b23c35bf9de23 100644 --- a/packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts +++ b/packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts @@ -8,7 +8,7 @@ import { namedTypes } from 'ast-types' import { getFontDefinitionFromNetwork, FontManifest, -} from '../../../next-server/server/font-utils' +} from '../../../server/font-utils' import postcss from 'postcss' import minifier from 'cssnano-simple' import { diff --git a/packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts b/packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts index 8667e0a085c7b..4a9fab6ed3d6b 100644 --- a/packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts +++ b/packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts @@ -4,8 +4,8 @@ import { realpathSync } from 'fs' import path from 'path' const originModules = [ - require.resolve('../../../next-server/server/require'), - require.resolve('../../../next-server/server/load-components'), + require.resolve('../../../server/require'), + require.resolve('../../../server/load-components'), ] function deleteCache(filePath: string) { diff --git a/packages/next/build/webpack/plugins/nextjs-ssr-module-cache.ts b/packages/next/build/webpack/plugins/nextjs-ssr-module-cache.ts index d8993055fdbe8..455d0c1f5fb63 100644 --- a/packages/next/build/webpack/plugins/nextjs-ssr-module-cache.ts +++ b/packages/next/build/webpack/plugins/nextjs-ssr-module-cache.ts @@ -1,6 +1,6 @@ import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { join, relative, dirname } from 'path' -import getRouteFromEntrypoint from '../../../next-server/server/get-route-from-entrypoint' +import getRouteFromEntrypoint from '../../../server/get-route-from-entrypoint' const SSR_MODULE_CACHE_FILENAME = 'ssr-module-cache.js' // By default webpack keeps initialized modules per-module. diff --git a/packages/next/build/webpack/plugins/pages-manifest-plugin.ts b/packages/next/build/webpack/plugins/pages-manifest-plugin.ts index aa6a02cea7759..c443f38558d0a 100644 --- a/packages/next/build/webpack/plugins/pages-manifest-plugin.ts +++ b/packages/next/build/webpack/plugins/pages-manifest-plugin.ts @@ -4,7 +4,7 @@ import { sources, } from 'next/dist/compiled/webpack/webpack' import { PAGES_MANIFEST } from '../../../shared/lib/constants' -import getRouteFromEntrypoint from '../../../next-server/server/get-route-from-entrypoint' +import getRouteFromEntrypoint from '../../../server/get-route-from-entrypoint' export type PagesManifest = { [page: string]: string } diff --git a/packages/next/cli/next-lint.ts b/packages/next/cli/next-lint.ts index 15ce9d9c56b59..cc6c8bfbb9aac 100755 --- a/packages/next/cli/next-lint.ts +++ b/packages/next/cli/next-lint.ts @@ -9,7 +9,7 @@ import { ESLINT_DEFAULT_DIRS } from '../lib/constants' import { runLintCheck } from '../lib/eslint/runLintCheck' import { printAndExit } from '../server/lib/utils' import { Telemetry } from '../telemetry/storage' -import loadConfig from '../next-server/server/config' +import loadConfig from '../server/config' import { PHASE_PRODUCTION_BUILD } from '../shared/lib/constants' import { eventLintCheckCompleted } from '../telemetry/events' import { CompileError } from '../lib/compile-error' diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index 362b8ce40f38a..cd186ab241574 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -6,7 +6,7 @@ import { imageConfigDefault, LoaderValue, VALID_LOADERS, -} from '../next-server/server/image-config' +} from '../server/image-config' import { useIntersection } from './use-intersection' if (typeof window === 'undefined') { diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index 0ffe2f7af9acb..71538a73d6b8c 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -32,19 +32,19 @@ import { import loadConfig, { isTargetLikeServerless, NextConfig, -} from '../next-server/server/config' +} from '../server/config' import { eventCliSession } from '../telemetry/events' import { hasNextSupport } from '../telemetry/ci-info' import { Telemetry } from '../telemetry/storage' import { normalizePagePath, denormalizePagePath, -} from '../next-server/server/normalize-page-path' +} from '../server/normalize-page-path' import { loadEnvConfig } from '@next/env' import { PrerenderManifest } from '../build' import exportPage from './worker' import { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin' -import { getPagePath } from '../next-server/server/require' +import { getPagePath } from '../server/require' import { trace } from '../telemetry/trace' const exists = promisify(existsOrig) diff --git a/packages/next/export/worker.ts b/packages/next/export/worker.ts index cf8cea79065d4..005bd87582f98 100644 --- a/packages/next/export/worker.ts +++ b/packages/next/export/worker.ts @@ -1,20 +1,20 @@ import url from 'url' import { extname, join, dirname, sep } from 'path' -import { renderToHTML } from '../next-server/server/render' +import { renderToHTML } from '../server/render' import { promises } from 'fs' import AmpHtmlValidator from 'next/dist/compiled/amphtml-validator' -import { loadComponents } from '../next-server/server/load-components' +import { loadComponents } from '../server/load-components' import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic' import { getRouteMatcher } from '../shared/lib/router/utils/route-matcher' import { getRouteRegex } from '../shared/lib/router/utils/route-regex' -import { normalizePagePath } from '../next-server/server/normalize-page-path' +import { normalizePagePath } from '../server/normalize-page-path' import { SERVER_PROPS_EXPORT_ERROR } from '../lib/constants' -import 'next/dist/next-server/server/node-polyfill-fetch' +import '../server/node-polyfill-fetch' import { IncomingMessage, ServerResponse } from 'http' import { ComponentType } from 'react' import { GetStaticProps } from '../types' -import { requireFontManifest } from '../next-server/server/require' -import { FontManifest } from '../next-server/server/font-utils' +import { requireFontManifest } from '../server/require' +import { FontManifest } from '../server/font-utils' import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' import { trace } from '../telemetry/trace' import { isInAmpMode } from '../shared/lib/amp' diff --git a/packages/next/lib/load-custom-routes.ts b/packages/next/lib/load-custom-routes.ts index 09e4cee073c1a..92ccf2fd6b309 100644 --- a/packages/next/lib/load-custom-routes.ts +++ b/packages/next/lib/load-custom-routes.ts @@ -1,5 +1,5 @@ import { parse as parseUrl } from 'url' -import { NextConfig } from '../next-server/server/config' +import { NextConfig } from '../server/config' import * as pathToRegexp from 'next/dist/compiled/path-to-regexp' import escapeStringRegexp from 'next/dist/compiled/escape-string-regexp' import { diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index 168a856e89f90..5cbffec469ef2 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -11,11 +11,8 @@ import { DocumentInitialProps, DocumentProps, } from '../shared/lib/utils' -import { - BuildManifest, - getPageFiles, -} from '../next-server/server/get-page-files' -import { cleanAmpPath } from '../next-server/server/utils' +import { BuildManifest, getPageFiles } from '../server/get-page-files' +import { cleanAmpPath } from '../server/utils' import { htmlEscapeJsonString } from '../server/htmlescape' import Script, { Props as ScriptLoaderProps } from '../client/script' diff --git a/packages/next/next-server/server/api-utils.ts b/packages/next/server/api-utils.ts similarity index 99% rename from packages/next/next-server/server/api-utils.ts rename to packages/next/server/api-utils.ts index ea20b683eacc7..91640e82b7b37 100644 --- a/packages/next/next-server/server/api-utils.ts +++ b/packages/next/server/api-utils.ts @@ -4,11 +4,7 @@ import { CookieSerializeOptions } from 'next/dist/compiled/cookie' import getRawBody from 'raw-body' import { PageConfig, PreviewData } from 'next/types' import { Stream } from 'stream' -import { - isResSent, - NextApiRequest, - NextApiResponse, -} from '../../shared/lib/utils' +import { isResSent, NextApiRequest, NextApiResponse } from '../shared/lib/utils' import { decryptWithSecret, encryptWithSecret } from './crypto-utils' import { interopDefault } from './load-components' import { sendEtagResponse } from './send-payload' diff --git a/packages/next/next-server/server/config-shared.ts b/packages/next/server/config-shared.ts similarity index 97% rename from packages/next/next-server/server/config-shared.ts rename to packages/next/server/config-shared.ts index b7d2396e14d7a..4d1547a87878c 100644 --- a/packages/next/next-server/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -1,5 +1,5 @@ import os from 'os' -import { Header, Redirect, Rewrite } from '../../lib/load-custom-routes' +import { Header, Redirect, Rewrite } from '../lib/load-custom-routes' import { imageConfigDefault } from './image-config' export type DomainLocales = Array<{ diff --git a/packages/next/next-server/server/config-utils-worker.ts b/packages/next/server/config-utils-worker.ts similarity index 90% rename from packages/next/next-server/server/config-utils-worker.ts rename to packages/next/server/config-utils-worker.ts index 02d4a83d9d905..f117c173d852f 100644 --- a/packages/next/next-server/server/config-utils-worker.ts +++ b/packages/next/server/config-utils-worker.ts @@ -1,12 +1,9 @@ import { loadEnvConfig } from '@next/env' import findUp from 'next/dist/compiled/find-up' import { init as initWebpack } from 'next/dist/compiled/webpack/webpack' -import { - CONFIG_FILE, - PHASE_DEVELOPMENT_SERVER, -} from '../../shared/lib/constants' +import { CONFIG_FILE, PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' import { NextConfig, normalizeConfig } from './config-shared' -import * as Log from '../../build/output/log' +import * as Log from '../build/output/log' let installed: boolean = false @@ -20,7 +17,7 @@ export function install(useWebpack5: boolean) { // hook the Node.js require so that webpack requires are // routed to the bundled and now initialized webpack version - require('../../build/webpack/require-hook') + require('../build/webpack/require-hook') } export type CheckReasons = diff --git a/packages/next/next-server/server/config-utils.ts b/packages/next/server/config-utils.ts similarity index 94% rename from packages/next/next-server/server/config-utils.ts rename to packages/next/server/config-utils.ts index 107032394edc3..c10de887d58e6 100644 --- a/packages/next/next-server/server/config-utils.ts +++ b/packages/next/server/config-utils.ts @@ -1,9 +1,9 @@ import path from 'path' import { Worker } from 'jest-worker' -import * as Log from '../../build/output/log' +import * as Log from '../build/output/log' import { CheckReasons, CheckResult } from './config-utils-worker' import { install, shouldLoadWithWebpack5 } from './config-utils-worker' -import { PHASE_PRODUCTION_SERVER } from '../../shared/lib/constants' +import { PHASE_PRODUCTION_SERVER } from '../shared/lib/constants' export { install, shouldLoadWithWebpack5 } diff --git a/packages/next/next-server/server/config.ts b/packages/next/server/config.ts similarity index 98% rename from packages/next/next-server/server/config.ts rename to packages/next/server/config.ts index 7b49d8a6d37bd..af9c9b05a764a 100644 --- a/packages/next/next-server/server/config.ts +++ b/packages/next/server/config.ts @@ -1,13 +1,10 @@ import chalk from 'chalk' import findUp from 'next/dist/compiled/find-up' import { basename, extname } from 'path' -import * as Log from '../../build/output/log' -import { hasNextSupport } from '../../telemetry/ci-info' -import { - CONFIG_FILE, - PHASE_DEVELOPMENT_SERVER, -} from '../../shared/lib/constants' -import { execOnce } from '../../shared/lib/utils' +import * as Log from '../build/output/log' +import { hasNextSupport } from '../telemetry/ci-info' +import { CONFIG_FILE, PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' +import { execOnce } from '../shared/lib/utils' import { defaultConfig, normalizeConfig } from './config-shared' import { loadWebpackHook } from './config-utils' import { ImageConfig, imageConfigDefault, VALID_LOADERS } from './image-config' diff --git a/packages/next/next-server/server/crypto-utils.ts b/packages/next/server/crypto-utils.ts similarity index 100% rename from packages/next/next-server/server/crypto-utils.ts rename to packages/next/server/crypto-utils.ts diff --git a/packages/next/next-server/server/denormalize-page-path.ts b/packages/next/server/denormalize-page-path.ts similarity index 100% rename from packages/next/next-server/server/denormalize-page-path.ts rename to packages/next/server/denormalize-page-path.ts diff --git a/packages/next/server/hot-middleware.ts b/packages/next/server/dev/hot-middleware.ts similarity index 100% rename from packages/next/server/hot-middleware.ts rename to packages/next/server/dev/hot-middleware.ts diff --git a/packages/next/server/hot-reloader.ts b/packages/next/server/dev/hot-reloader.ts similarity index 94% rename from packages/next/server/hot-reloader.ts rename to packages/next/server/dev/hot-reloader.ts index f46875e829224..255a5d0ea8c16 100644 --- a/packages/next/server/hot-reloader.ts +++ b/packages/next/server/dev/hot-reloader.ts @@ -5,30 +5,27 @@ import { WebpackHotMiddleware } from './hot-middleware' import { join } from 'path' import { UrlObject } from 'url' import { webpack, isWebpack5 } from 'next/dist/compiled/webpack/webpack' -import { createEntrypoints, createPagesMapping } from '../build/entries' -import { watchCompilers } from '../build/output' -import getBaseWebpackConfig from '../build/webpack-config' -import { API_ROUTE } from '../lib/constants' -import { recursiveDelete } from '../lib/recursive-delete' -import { BLOCKED_PAGES } from '../shared/lib/constants' -import { __ApiPreviewProps } from '../next-server/server/api-utils' -import { route } from '../next-server/server/router' -import { findPageFile } from './lib/find-page-file' +import { createEntrypoints, createPagesMapping } from '../../build/entries' +import { watchCompilers } from '../../build/output' +import getBaseWebpackConfig from '../../build/webpack-config' +import { API_ROUTE } from '../../lib/constants' +import { recursiveDelete } from '../../lib/recursive-delete' +import { BLOCKED_PAGES } from '../../shared/lib/constants' +import { __ApiPreviewProps } from '../api-utils' +import { route } from '../router' +import { findPageFile } from '../lib/find-page-file' import onDemandEntryHandler, { entries, BUILDING, } from './on-demand-entry-handler' -import { - denormalizePagePath, - normalizePathSep, -} from '../next-server/server/normalize-page-path' -import getRouteFromEntrypoint from '../next-server/server/get-route-from-entrypoint' -import { isWriteable } from '../build/is-writeable' -import { ClientPagesLoaderOptions } from '../build/webpack/loaders/next-client-pages-loader' +import { denormalizePagePath, normalizePathSep } from '../normalize-page-path' +import getRouteFromEntrypoint from '../get-route-from-entrypoint' +import { isWriteable } from '../../build/is-writeable' +import { ClientPagesLoaderOptions } from '../../build/webpack/loaders/next-client-pages-loader' import { stringify } from 'querystring' -import { difference } from '../build/utils' -import { NextConfig } from '../next-server/server/config' -import { CustomRoutes } from '../lib/load-custom-routes' +import { difference } from '../../build/utils' +import { NextConfig } from '../config' +import { CustomRoutes } from '../../lib/load-custom-routes' export async function renderScriptError( res: ServerResponse, diff --git a/packages/next/server/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts similarity index 94% rename from packages/next/server/next-dev-server.ts rename to packages/next/server/dev/next-dev-server.ts index d395dc4f0a64f..f882ac91e968b 100644 --- a/packages/next/server/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -8,44 +8,44 @@ import { join as pathJoin, relative, resolve as pathResolve, sep } from 'path' import React from 'react' import { UrlWithParsedQuery } from 'url' import Watchpack from 'watchpack' -import { ampValidation } from '../build/output/index' -import { PUBLIC_DIR_MIDDLEWARE_CONFLICT } from '../lib/constants' -import { fileExists } from '../lib/file-exists' -import { findPagesDir } from '../lib/find-pages-dir' -import loadCustomRoutes, { CustomRoutes } from '../lib/load-custom-routes' -import { verifyTypeScriptSetup } from '../lib/verifyTypeScriptSetup' +import { ampValidation } from '../../build/output' +import { PUBLIC_DIR_MIDDLEWARE_CONFLICT } from '../../lib/constants' +import { fileExists } from '../../lib/file-exists' +import { findPagesDir } from '../../lib/find-pages-dir' +import loadCustomRoutes, { CustomRoutes } from '../../lib/load-custom-routes' +import { verifyTypeScriptSetup } from '../../lib/verifyTypeScriptSetup' import { PHASE_DEVELOPMENT_SERVER, CLIENT_STATIC_FILES_PATH, DEV_CLIENT_PAGES_MANIFEST, -} from '../shared/lib/constants' +} from '../../shared/lib/constants' import { getRouteMatcher, getRouteRegex, getSortedRoutes, isDynamicRoute, -} from '../shared/lib/router/utils' -import { __ApiPreviewProps } from '../next-server/server/api-utils' +} from '../../shared/lib/router/utils' +import { __ApiPreviewProps } from '../api-utils' import Server, { WrappedBuildError, ServerConstructor, FindComponentsResult, -} from '../next-server/server/next-server' -import { normalizePagePath } from '../next-server/server/normalize-page-path' -import Router, { Params, route } from '../next-server/server/router' -import { eventCliSession } from '../telemetry/events' -import { Telemetry } from '../telemetry/storage' -import { setGlobal } from '../telemetry/trace' +} from '../next-server' +import { normalizePagePath } from '../normalize-page-path' +import Router, { Params, route } from '../router' +import { eventCliSession } from '../../telemetry/events' +import { Telemetry } from '../../telemetry/storage' +import { setGlobal } from '../../telemetry/trace' import HotReloader from './hot-reloader' -import { findPageFile } from './lib/find-page-file' -import { getNodeOptionsWithoutInspect } from './lib/utils' -import { withCoalescedInvoke } from '../lib/coalesced-function' -import { NextConfig } from '../next-server/server/config' +import { findPageFile } from '../lib/find-page-file' +import { getNodeOptionsWithoutInspect } from '../lib/utils' +import { withCoalescedInvoke } from '../../lib/coalesced-function' +import { NextConfig } from '../config' import { ParsedUrlQuery } from 'querystring' import { LoadComponentsReturnType, loadDefaultErrorComponents, -} from '../next-server/server/load-components' +} from '../load-components' if (typeof React.Suspense === 'undefined') { throw new Error( @@ -704,7 +704,7 @@ export default class DevServer extends Server { // During development mode, files can be added while the server is running. // Checks for .next/static, .next/server, static and public. // Note that in development .next/server is available for error reporting purposes. - // see `packages/next/next-server/server/next-server.ts` for more details. + // see `packages/next/server/next-server.ts` for more details. if ( untrustedFilePath.startsWith(pathJoin(this.distDir, 'static') + sep) || untrustedFilePath.startsWith(pathJoin(this.distDir, 'server') + sep) || diff --git a/packages/next/server/on-demand-entry-handler.ts b/packages/next/server/dev/on-demand-entry-handler.ts similarity index 96% rename from packages/next/server/on-demand-entry-handler.ts rename to packages/next/server/dev/on-demand-entry-handler.ts index 5fd750e50a636..7045a3a093ced 100644 --- a/packages/next/server/on-demand-entry-handler.ts +++ b/packages/next/server/dev/on-demand-entry-handler.ts @@ -3,14 +3,11 @@ import { IncomingMessage, ServerResponse } from 'http' import { join, posix } from 'path' import { parse } from 'url' import { webpack, isWebpack5 } from 'next/dist/compiled/webpack/webpack' -import * as Log from '../build/output/log' -import { - normalizePagePath, - normalizePathSep, -} from '../next-server/server/normalize-page-path' -import { pageNotFoundError } from '../next-server/server/require' -import { findPageFile } from './lib/find-page-file' -import getRouteFromEntrypoint from '../next-server/server/get-route-from-entrypoint' +import * as Log from '../../build/output/log' +import { normalizePagePath, normalizePathSep } from '../normalize-page-path' +import { pageNotFoundError } from '../require' +import { findPageFile } from '../lib/find-page-file' +import getRouteFromEntrypoint from '../get-route-from-entrypoint' export const ADDED = Symbol('added') export const BUILDING = Symbol('building') diff --git a/packages/next/server/static-paths-worker.ts b/packages/next/server/dev/static-paths-worker.ts similarity index 81% rename from packages/next/server/static-paths-worker.ts rename to packages/next/server/dev/static-paths-worker.ts index 78200786e0ead..eb29a6b99d81f 100644 --- a/packages/next/server/static-paths-worker.ts +++ b/packages/next/server/dev/static-paths-worker.ts @@ -1,6 +1,6 @@ -import { buildStaticPaths } from '../build/utils' -import { loadComponents } from '../next-server/server/load-components' -import '../next-server/server/node-polyfill-fetch' +import { buildStaticPaths } from '../../build/utils' +import { loadComponents } from '../load-components' +import '../node-polyfill-fetch' type RuntimeConfig = any @@ -24,7 +24,7 @@ export async function loadStaticPaths( } // update work memory runtime-config - require('../shared/lib/runtime-config').setConfig(config) + require('../../shared/lib/runtime-config').setConfig(config) const components = await loadComponents(distDir, pathname, serverless) diff --git a/packages/next/next-server/server/font-utils.ts b/packages/next/server/font-utils.ts similarity index 93% rename from packages/next/next-server/server/font-utils.ts rename to packages/next/server/font-utils.ts index db5de03a294a1..1db371dd90595 100644 --- a/packages/next/next-server/server/font-utils.ts +++ b/packages/next/server/font-utils.ts @@ -1,5 +1,5 @@ -import * as Log from '../../build/output/log' -import { GOOGLE_FONT_PROVIDER } from '../../shared/lib/constants' +import * as Log from '../build/output/log' +import { GOOGLE_FONT_PROVIDER } from '../shared/lib/constants' const https = require('https') const CHROME_UA = diff --git a/packages/next/next-server/server/get-page-files.ts b/packages/next/server/get-page-files.ts similarity index 100% rename from packages/next/next-server/server/get-page-files.ts rename to packages/next/server/get-page-files.ts diff --git a/packages/next/next-server/server/get-route-from-entrypoint.ts b/packages/next/server/get-route-from-entrypoint.ts similarity index 88% rename from packages/next/next-server/server/get-route-from-entrypoint.ts rename to packages/next/server/get-route-from-entrypoint.ts index 48da52f6e31ed..c412e2d886ccc 100644 --- a/packages/next/next-server/server/get-route-from-entrypoint.ts +++ b/packages/next/server/get-route-from-entrypoint.ts @@ -1,4 +1,4 @@ -import getRouteFromAssetPath from '../../shared/lib/router/utils/get-route-from-asset-path' +import getRouteFromAssetPath from '../shared/lib/router/utils/get-route-from-asset-path' // matches pages/:page*.js const SERVER_ROUTE_NAME_REGEX = /^pages[/\\](.*)$/ diff --git a/packages/next/next-server/server/image-config.ts b/packages/next/server/image-config.ts similarity index 100% rename from packages/next/next-server/server/image-config.ts rename to packages/next/server/image-config.ts diff --git a/packages/next/next-server/server/image-optimizer.ts b/packages/next/server/image-optimizer.ts similarity index 99% rename from packages/next/next-server/server/image-optimizer.ts rename to packages/next/server/image-optimizer.ts index 1e789489ce954..5def834f5993e 100644 --- a/packages/next/next-server/server/image-optimizer.ts +++ b/packages/next/server/image-optimizer.ts @@ -8,8 +8,8 @@ import isAnimated from 'next/dist/compiled/is-animated' import { join } from 'path' import Stream from 'stream' import nodeUrl, { UrlWithParsedQuery } from 'url' -import { NextConfig } from '../../next-server/server/config-shared' -import { fileExists } from '../../lib/file-exists' +import { NextConfig } from './config-shared' +import { fileExists } from '../lib/file-exists' import { ImageConfig, imageConfigDefault } from './image-config' import { processBuffer, Operation } from './lib/squoosh/main' import Server from './next-server' diff --git a/packages/next/next-server/server/incremental-cache.ts b/packages/next/server/incremental-cache.ts similarity index 98% rename from packages/next/next-server/server/incremental-cache.ts rename to packages/next/server/incremental-cache.ts index 32ad4d63b1cb1..d015dd6ba41b0 100644 --- a/packages/next/next-server/server/incremental-cache.ts +++ b/packages/next/server/incremental-cache.ts @@ -1,8 +1,8 @@ import { promises, readFileSync } from 'fs' import LRUCache from 'next/dist/compiled/lru-cache' import path from 'path' -import { PrerenderManifest } from '../../build' -import { PRERENDER_MANIFEST } from '../../shared/lib/constants' +import { PrerenderManifest } from '../build' +import { PRERENDER_MANIFEST } from '../shared/lib/constants' import { normalizePagePath } from './normalize-page-path' function toRoute(pathname: string): string { diff --git a/packages/next/server/lib/find-page-file.ts b/packages/next/server/lib/find-page-file.ts index 08da65906416e..c58a77ade6ec7 100644 --- a/packages/next/server/lib/find-page-file.ts +++ b/packages/next/server/lib/find-page-file.ts @@ -2,7 +2,7 @@ import { join, sep as pathSeparator, normalize } from 'path' import chalk from 'chalk' import { warn } from '../../build/output/log' import { promises } from 'fs' -import { denormalizePagePath } from '../../next-server/server/normalize-page-path' +import { denormalizePagePath } from '../normalize-page-path' import { fileExists } from '../../lib/file-exists' async function isTrueCasePagePath(pagePath: string, pagesDir: string) { diff --git a/packages/next/next-server/server/lib/recursive-readdir-sync.ts b/packages/next/server/lib/recursive-readdir-sync.ts similarity index 100% rename from packages/next/next-server/server/lib/recursive-readdir-sync.ts rename to packages/next/server/lib/recursive-readdir-sync.ts diff --git a/packages/next/next-server/server/lib/squoosh/LICENSE b/packages/next/server/lib/squoosh/LICENSE similarity index 100% rename from packages/next/next-server/server/lib/squoosh/LICENSE rename to packages/next/server/lib/squoosh/LICENSE diff --git a/packages/next/next-server/server/lib/squoosh/codecs.ts b/packages/next/server/lib/squoosh/codecs.ts similarity index 100% rename from packages/next/next-server/server/lib/squoosh/codecs.ts rename to packages/next/server/lib/squoosh/codecs.ts diff --git a/packages/next/next-server/server/lib/squoosh/emscripten-utils.ts b/packages/next/server/lib/squoosh/emscripten-utils.ts similarity index 100% rename from packages/next/next-server/server/lib/squoosh/emscripten-utils.ts rename to packages/next/server/lib/squoosh/emscripten-utils.ts diff --git a/packages/next/next-server/server/lib/squoosh/image_data.ts b/packages/next/server/lib/squoosh/image_data.ts similarity index 100% rename from packages/next/next-server/server/lib/squoosh/image_data.ts rename to packages/next/server/lib/squoosh/image_data.ts diff --git a/packages/next/next-server/server/lib/squoosh/impl.ts b/packages/next/server/lib/squoosh/impl.ts similarity index 100% rename from packages/next/next-server/server/lib/squoosh/impl.ts rename to packages/next/server/lib/squoosh/impl.ts diff --git a/packages/next/next-server/server/lib/squoosh/main.ts b/packages/next/server/lib/squoosh/main.ts similarity index 97% rename from packages/next/next-server/server/lib/squoosh/main.ts rename to packages/next/server/lib/squoosh/main.ts index 3e81a335cd9b8..013571366f7cc 100644 --- a/packages/next/next-server/server/lib/squoosh/main.ts +++ b/packages/next/server/lib/squoosh/main.ts @@ -1,6 +1,6 @@ import { Worker } from 'jest-worker' import * as path from 'path' -import { execOnce } from '../../../../shared/lib/utils' +import { execOnce } from '../../../shared/lib/utils' import { cpus } from 'os' type RotateOperation = { diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js b/packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js rename to packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.js diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm b/packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm rename to packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_dec.wasm diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js b/packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js rename to packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.js diff --git a/packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm b/packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm rename to packages/next/server/lib/squoosh/mozjpeg/mozjpeg_node_enc.wasm diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng.js b/packages/next/server/lib/squoosh/png/squoosh_oxipng.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng.js rename to packages/next/server/lib/squoosh/png/squoosh_oxipng.js diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng_bg.wasm b/packages/next/server/lib/squoosh/png/squoosh_oxipng_bg.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/png/squoosh_oxipng_bg.wasm rename to packages/next/server/lib/squoosh/png/squoosh_oxipng_bg.wasm diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_png.js b/packages/next/server/lib/squoosh/png/squoosh_png.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/png/squoosh_png.js rename to packages/next/server/lib/squoosh/png/squoosh_png.js diff --git a/packages/next/next-server/server/lib/squoosh/png/squoosh_png_bg.wasm b/packages/next/server/lib/squoosh/png/squoosh_png_bg.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/png/squoosh_png_bg.wasm rename to packages/next/server/lib/squoosh/png/squoosh_png_bg.wasm diff --git a/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize.js b/packages/next/server/lib/squoosh/resize/squoosh_resize.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/resize/squoosh_resize.js rename to packages/next/server/lib/squoosh/resize/squoosh_resize.js diff --git a/packages/next/next-server/server/lib/squoosh/resize/squoosh_resize_bg.wasm b/packages/next/server/lib/squoosh/resize/squoosh_resize_bg.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/resize/squoosh_resize_bg.wasm rename to packages/next/server/lib/squoosh/resize/squoosh_resize_bg.wasm diff --git a/packages/next/next-server/server/lib/squoosh/rotate/rotate.wasm b/packages/next/server/lib/squoosh/rotate/rotate.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/rotate/rotate.wasm rename to packages/next/server/lib/squoosh/rotate/rotate.wasm diff --git a/packages/next/next-server/server/lib/squoosh/text-decoder.ts b/packages/next/server/lib/squoosh/text-decoder.ts similarity index 100% rename from packages/next/next-server/server/lib/squoosh/text-decoder.ts rename to packages/next/server/lib/squoosh/text-decoder.ts diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js b/packages/next/server/lib/squoosh/webp/webp_node_dec.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js rename to packages/next/server/lib/squoosh/webp/webp_node_dec.js diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.wasm b/packages/next/server/lib/squoosh/webp/webp_node_dec.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.wasm rename to packages/next/server/lib/squoosh/webp/webp_node_dec.wasm diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.js b/packages/next/server/lib/squoosh/webp/webp_node_enc.js similarity index 100% rename from packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.js rename to packages/next/server/lib/squoosh/webp/webp_node_enc.js diff --git a/packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.wasm b/packages/next/server/lib/squoosh/webp/webp_node_enc.wasm similarity index 100% rename from packages/next/next-server/server/lib/squoosh/webp/webp_node_enc.wasm rename to packages/next/server/lib/squoosh/webp/webp_node_enc.wasm diff --git a/packages/next/next-server/server/load-components.ts b/packages/next/server/load-components.ts similarity index 96% rename from packages/next/next-server/server/load-components.ts rename to packages/next/server/load-components.ts index d828d53756559..7ac7fd369faac 100644 --- a/packages/next/next-server/server/load-components.ts +++ b/packages/next/server/load-components.ts @@ -1,11 +1,11 @@ import { BUILD_MANIFEST, REACT_LOADABLE_MANIFEST, -} from '../../shared/lib/constants' +} from '../shared/lib/constants' import { join } from 'path' import { requirePage } from './require' import { BuildManifest } from './get-page-files' -import { AppType, DocumentType } from '../../shared/lib/utils' +import { AppType, DocumentType } from '../shared/lib/utils' import { PageConfig, GetStaticPaths, diff --git a/packages/next/next-server/server/next-server.ts b/packages/next/server/next-server.ts similarity index 98% rename from packages/next/next-server/server/next-server.ts rename to packages/next/server/next-server.ts index b2efea28c9df5..32ef98432e60c 100644 --- a/packages/next/next-server/server/next-server.ts +++ b/packages/next/server/next-server.ts @@ -10,7 +10,7 @@ import { ParsedUrlQuery, } from 'querystring' import { format as formatUrl, parse as parseUrl, UrlWithParsedQuery } from 'url' -import { PrerenderManifest } from '../../build' +import { PrerenderManifest } from '../build' import { getRedirectStatus, Header, @@ -18,8 +18,8 @@ import { Rewrite, RouteType, CustomRoutes, -} from '../../lib/load-custom-routes' -import { withCoalescedInvoke } from '../../lib/coalesced-function' +} from '../lib/load-custom-routes' +import { withCoalescedInvoke } from '../lib/coalesced-function' import { BUILD_ID_FILE, CLIENT_PUBLIC_FILES_PATH, @@ -33,19 +33,15 @@ import { SERVER_DIRECTORY, STATIC_STATUS_PAGES, TEMPORARY_REDIRECT_STATUS, -} from '../../shared/lib/constants' +} from '../shared/lib/constants' import { getRouteMatcher, getRouteRegex, getSortedRoutes, isDynamicRoute, -} from '../../shared/lib/router/utils' -import * as envConfig from '../../shared/lib/runtime-config' -import { - isResSent, - NextApiRequest, - NextApiResponse, -} from '../../shared/lib/utils' +} from '../shared/lib/router/utils' +import * as envConfig from '../shared/lib/runtime-config' +import { isResSent, NextApiRequest, NextApiResponse } from '../shared/lib/utils' import { apiResolver, setLazyProp, @@ -54,7 +50,7 @@ import { __ApiPreviewProps, } from './api-utils' import { DomainLocales, isTargetLikeServerless, NextConfig } from './config' -import pathMatch from '../../shared/lib/router/utils/path-match' +import pathMatch from '../shared/lib/router/utils/path-match' import { recursiveReadDirSync } from './lib/recursive-readdir-sync' import { loadComponents, LoadComponentsReturnType } from './load-components' import { normalizePagePath } from './normalize-page-path' @@ -69,28 +65,28 @@ import Router, { } from './router' import prepareDestination, { compileNonPath, -} from '../../shared/lib/router/utils/prepare-destination' +} from '../shared/lib/router/utils/prepare-destination' import { sendPayload, setRevalidateHeaders } from './send-payload' import { serveStatic } from './serve-static' import { IncrementalCache } from './incremental-cache' -import { execOnce } from '../../shared/lib/utils' +import { execOnce } from '../shared/lib/utils' import { isBlockedPage } from './utils' import { loadEnvConfig } from '@next/env' import './node-polyfill-fetch' -import { PagesManifest } from '../../build/webpack/plugins/pages-manifest-plugin' -import { removePathTrailingSlash } from '../../client/normalize-trailing-slash' -import getRouteFromAssetPath from '../../shared/lib/router/utils/get-route-from-asset-path' +import { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin' +import { removePathTrailingSlash } from '../client/normalize-trailing-slash' +import getRouteFromAssetPath from '../shared/lib/router/utils/get-route-from-asset-path' import { FontManifest } from './font-utils' import { denormalizePagePath } from './denormalize-page-path' import accept from '@hapi/accept' -import { normalizeLocalePath } from '../../shared/lib/i18n/normalize-locale-path' -import { detectLocaleCookie } from '../../shared/lib/i18n/detect-locale-cookie' -import * as Log from '../../build/output/log' +import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' +import { detectLocaleCookie } from '../shared/lib/i18n/detect-locale-cookie' +import * as Log from '../build/output/log' import { imageOptimizer } from './image-optimizer' -import { detectDomainLocale } from '../../shared/lib/i18n/detect-domain-locale' +import { detectDomainLocale } from '../shared/lib/i18n/detect-domain-locale' import cookie from 'next/dist/compiled/cookie' -import escapePathDelimiters from '../../shared/lib/router/utils/escape-path-delimiters' -import { getUtils } from '../../build/webpack/loaders/next-serverless-loader/utils' +import escapePathDelimiters from '../shared/lib/router/utils/escape-path-delimiters' +import { getUtils } from '../build/webpack/loaders/next-serverless-loader/utils' import { PreviewData } from 'next/types' const getCustomRouteMatcher = pathMatch(true) diff --git a/packages/next/server/next.ts b/packages/next/server/next.ts index 4eba61bca4b2f..05099837d28ad 100644 --- a/packages/next/server/next.ts +++ b/packages/next/server/next.ts @@ -1,11 +1,8 @@ -import '../next-server/server/node-polyfill-fetch' -import { - default as Server, - ServerConstructor, -} from '../next-server/server/next-server' +import './node-polyfill-fetch' +import { default as Server, ServerConstructor } from './next-server' import { NON_STANDARD_NODE_ENV } from '../lib/constants' import * as log from '../build/output/log' -import loadConfig, { NextConfig } from '../next-server/server/config' +import loadConfig, { NextConfig } from './config' import { resolve } from 'path' import { PHASE_DEVELOPMENT_SERVER, @@ -25,7 +22,7 @@ let ServerImpl: typeof Server const getServerImpl = async () => { if (ServerImpl === undefined) - ServerImpl = (await import('../next-server/server/next-server')).default + ServerImpl = (await import('./next-server')).default return ServerImpl } @@ -112,7 +109,7 @@ export class NextServer { } ): Promise { if (options.dev) { - const DevServer = require('./next-dev-server').default + const DevServer = require('./dev/next-dev-server').default return new DevServer(options) } return new (await getServerImpl())(options) diff --git a/packages/next/next-server/server/node-polyfill-fetch.js b/packages/next/server/node-polyfill-fetch.js similarity index 100% rename from packages/next/next-server/server/node-polyfill-fetch.js rename to packages/next/server/node-polyfill-fetch.js diff --git a/packages/next/next-server/server/normalize-page-path.ts b/packages/next/server/normalize-page-path.ts similarity index 100% rename from packages/next/next-server/server/normalize-page-path.ts rename to packages/next/server/normalize-page-path.ts diff --git a/packages/next/next-server/server/optimize-amp.ts b/packages/next/server/optimize-amp.ts similarity index 100% rename from packages/next/next-server/server/optimize-amp.ts rename to packages/next/server/optimize-amp.ts diff --git a/packages/next/next-server/server/render.tsx b/packages/next/server/render.tsx similarity index 97% rename from packages/next/next-server/server/render.tsx rename to packages/next/server/render.tsx index 380b08201c260..ed74ad5ce738a 100644 --- a/packages/next/next-server/server/render.tsx +++ b/packages/next/server/render.tsx @@ -2,8 +2,8 @@ import { IncomingMessage, ServerResponse } from 'http' import { ParsedUrlQuery } from 'querystring' import React from 'react' import { renderToStaticMarkup, renderToString } from 'react-dom/server' -import { warn } from '../../build/output/log' -import { UnwrapPromise } from '../../lib/coalesced-function' +import { warn } from '../build/output/log' +import { UnwrapPromise } from '../lib/coalesced-function' import { GSP_NO_RETURNED_VALUE, GSSP_COMPONENT_MEMBER_ERROR, @@ -13,25 +13,25 @@ import { SERVER_PROPS_SSG_CONFLICT, SSG_GET_INITIAL_PROPS_CONFLICT, UNSTABLE_REVALIDATE_RENAME_ERROR, -} from '../../lib/constants' -import { isSerializableProps } from '../../lib/is-serializable-props' -import { GetServerSideProps, GetStaticProps, PreviewData } from '../../types' -import { isInAmpMode } from '../../shared/lib/amp' -import { AmpStateContext } from '../../shared/lib/amp-context' +} from '../lib/constants' +import { isSerializableProps } from '../lib/is-serializable-props' +import { GetServerSideProps, GetStaticProps, PreviewData } from '../types' +import { isInAmpMode } from '../shared/lib/amp' +import { AmpStateContext } from '../shared/lib/amp-context' import { AMP_RENDER_TARGET, SERVER_PROPS_ID, STATIC_PROPS_ID, STATIC_STATUS_PAGES, -} from '../../shared/lib/constants' -import { defaultHead } from '../../shared/lib/head' -import { HeadManagerContext } from '../../shared/lib/head-manager-context' -import Loadable from '../../shared/lib/loadable' -import { LoadableContext } from '../../shared/lib/loadable-context' -import postProcess from '../../shared/lib/post-process' -import { RouterContext } from '../../shared/lib/router-context' -import { NextRouter } from '../../shared/lib/router/router' -import { isDynamicRoute } from '../../shared/lib/router/utils/is-dynamic' +} from '../shared/lib/constants' +import { defaultHead } from '../shared/lib/head' +import { HeadManagerContext } from '../shared/lib/head-manager-context' +import Loadable from '../shared/lib/loadable' +import { LoadableContext } from '../shared/lib/loadable-context' +import postProcess from '../shared/lib/post-process' +import { RouterContext } from '../shared/lib/router-context' +import { NextRouter } from '../shared/lib/router/router' +import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic' import { AppType, ComponentsEnhancer, @@ -43,7 +43,7 @@ import { loadGetInitialProps, NextComponentType, RenderPage, -} from '../../shared/lib/utils' +} from '../shared/lib/utils' import { tryGetPreviewData, NextApiRequestCookies, @@ -58,7 +58,7 @@ import { allowedStatusCodes, getRedirectStatus, Redirect, -} from '../../lib/load-custom-routes' +} from '../lib/load-custom-routes' import { DomainLocales } from './config' function noRouter() { diff --git a/packages/next/next-server/server/require.ts b/packages/next/server/require.ts similarity index 90% rename from packages/next/next-server/server/require.ts rename to packages/next/server/require.ts index 4fdeb2db94ee7..7e3fcd06179e1 100644 --- a/packages/next/next-server/server/require.ts +++ b/packages/next/server/require.ts @@ -5,10 +5,10 @@ import { SERVER_DIRECTORY, SERVERLESS_DIRECTORY, FONT_MANIFEST, -} from '../../shared/lib/constants' +} from '../shared/lib/constants' import { normalizePagePath, denormalizePagePath } from './normalize-page-path' -import { PagesManifest } from '../../build/webpack/plugins/pages-manifest-plugin' -import { normalizeLocalePath } from '../../shared/lib/i18n/normalize-locale-path' +import { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin' +import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' export function pageNotFoundError(page: string): Error { const err: any = new Error(`Cannot find module for page: ${page}`) diff --git a/packages/next/next-server/server/router.ts b/packages/next/server/router.ts similarity index 96% rename from packages/next/next-server/server/router.ts rename to packages/next/server/router.ts index 61439c780b7a8..3a1603984c2c2 100644 --- a/packages/next/next-server/server/router.ts +++ b/packages/next/server/router.ts @@ -1,11 +1,11 @@ import { IncomingMessage, ServerResponse } from 'http' import { UrlWithParsedQuery } from 'url' -import pathMatch from '../../shared/lib/router/utils/path-match' -import { removePathTrailingSlash } from '../../client/normalize-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 pathMatch from '../shared/lib/router/utils/path-match' +import { removePathTrailingSlash } from '../client/normalize-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' export const route = pathMatch() diff --git a/packages/next/next-server/server/send-payload.ts b/packages/next/server/send-payload.ts similarity index 98% rename from packages/next/next-server/server/send-payload.ts rename to packages/next/server/send-payload.ts index a29512605b438..713a1fc6c4d73 100644 --- a/packages/next/next-server/server/send-payload.ts +++ b/packages/next/server/send-payload.ts @@ -1,5 +1,5 @@ import { IncomingMessage, ServerResponse } from 'http' -import { isResSent } from '../../shared/lib/utils' +import { isResSent } from '../shared/lib/utils' import generateETag from 'etag' import fresh from 'next/dist/compiled/fresh' diff --git a/packages/next/next-server/server/serve-static.ts b/packages/next/server/serve-static.ts similarity index 100% rename from packages/next/next-server/server/serve-static.ts rename to packages/next/server/serve-static.ts diff --git a/packages/next/next-server/server/utils.ts b/packages/next/server/utils.ts similarity index 88% rename from packages/next/next-server/server/utils.ts rename to packages/next/server/utils.ts index e3753127ce26c..c8c90fdd97890 100644 --- a/packages/next/next-server/server/utils.ts +++ b/packages/next/server/utils.ts @@ -1,4 +1,4 @@ -import { BLOCKED_PAGES } from '../../shared/lib/constants' +import { BLOCKED_PAGES } from '../shared/lib/constants' export function isBlockedPage(pathname: string): boolean { return BLOCKED_PAGES.includes(pathname) diff --git a/packages/next/shared/lib/router/router.ts b/packages/next/shared/lib/router/router.ts index c3e69847ac424..babffab9d11eb 100644 --- a/packages/next/shared/lib/router/router.ts +++ b/packages/next/shared/lib/router/router.ts @@ -13,8 +13,8 @@ import { markAssetError, } from '../../../client/route-loader' import { RouterEvent } from '../../../client/router' -import { DomainLocales } from '../../../next-server/server/config' -import { denormalizePagePath } from '../../../next-server/server/denormalize-page-path' +import { DomainLocales } from '../../../server/config' +import { denormalizePagePath } from '../../../server/denormalize-page-path' import { normalizeLocalePath } from '../i18n/normalize-locale-path' import mitt, { MittEmitter } from '../mitt' import { diff --git a/packages/next/shared/lib/utils.ts b/packages/next/shared/lib/utils.ts index dd0fb11050e61..499ca94bab122 100644 --- a/packages/next/shared/lib/utils.ts +++ b/packages/next/shared/lib/utils.ts @@ -5,8 +5,8 @@ import { UrlObject } from 'url' import { formatUrl } from './router/utils/format-url' import { NextRouter } from './router/router' import { Env } from '@next/env' -import { BuildManifest } from '../../next-server/server/get-page-files' -import { DomainLocales } from '../../next-server/server/config' +import { BuildManifest } from '../../server/get-page-files' +import { DomainLocales } from '../../server/config' import { PreviewData } from 'next/types' export type NextComponentType< diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 810bcfb34d01d..48a67e839a3af 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -808,9 +808,8 @@ export async function compile(task, opts) { 'lib', 'client', 'telemetry', - 'nextserver', 'shared', - 'nextserver_wasm', + 'server_wasm', // we compile this each time so that fresh runtime data is pulled // before each publish 'ncc_amp_optimizer', @@ -926,17 +925,8 @@ export default async function (task) { await task.watch('lib/**/*.+(js|ts|tsx)', 'lib', opts) await task.watch('cli/**/*.+(js|ts|tsx)', 'cli', opts) await task.watch('telemetry/**/*.+(js|ts|tsx)', 'telemetry', opts) - await task.watch('next-server/**/*.+(js|ts|tsx)', 'nextserver', opts) await task.watch('shared/**/*.+(js|ts|tsx)', 'shared', opts) - await task.watch('next-server/**/*.+(wasm)', 'nextserver_wasm', opts) -} - -export async function nextserver(task, opts) { - await task - .source(opts.src || 'next-server/**/*.+(js|ts|tsx)') - .babel('server', { dev: opts.dev }) - .target('dist/next-server') - notify('Compiled server files') + await task.watch('server/**/*.+(wasm)', 'server_wasm', opts) } export async function shared(task, opts) { @@ -947,10 +937,8 @@ export async function shared(task, opts) { notify('Compiled shared files') } -export async function nextserver_wasm(task, opts) { - await task - .source(opts.src || 'next-server/**/*.+(wasm)') - .target('dist/next-server') +export async function server_wasm(task, opts) { + await task.source(opts.src || 'server/**/*.+(wasm)').target('dist/server') notify('Moved server wasm files') } diff --git a/packages/next/telemetry/events/version.ts b/packages/next/telemetry/events/version.ts index 155419d57f8ff..9a45ed9f3e10e 100644 --- a/packages/next/telemetry/events/version.ts +++ b/packages/next/telemetry/events/version.ts @@ -6,7 +6,7 @@ import { PHASE_EXPORT, PHASE_PRODUCTION_BUILD, } from '../../shared/lib/constants' -import { normalizeConfig } from '../../next-server/server/config' +import { normalizeConfig } from '../../server/config' const EVENT_VERSION = 'NEXT_CLI_SESSION_STARTED' diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index cb9d59442b249..00f5909c514da 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -18,7 +18,7 @@ import { import { NextApiRequestCookies, // @ts-ignore This path is generated at build time and conflicts otherwise -} from '../dist/next-server/server/api-utils' +} from '../dist/server/api-utils' // @ts-ignore This path is generated at build time and conflicts otherwise import next from '../dist/server/next'