diff --git a/.eslintrc.json b/.eslintrc.json index feb49b2ecbbff..4dfa939d385d4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -213,6 +213,18 @@ ], "eslint-plugin/require-meta-docs-url": "error" } + }, + { + "files": ["packages/**/*.tsx", "packages/**/*.ts"], + "rules": { + "@typescript-eslint/consistent-type-imports": [ + "error", + { + "disallowTypeAnnotations": false + } + ], + "@typescript-eslint/no-import-type-side-effects": "error" + } } ], "rules": { diff --git a/packages/create-next-app/create-app.ts b/packages/create-next-app/create-app.ts index 23d0c1419edfb..89719e48ad473 100644 --- a/packages/create-next-app/create-app.ts +++ b/packages/create-next-app/create-app.ts @@ -3,13 +3,13 @@ import retry from 'async-retry' import { red, green, cyan } from 'picocolors' import fs from 'fs' import path from 'path' +import type { RepoInfo } from './helpers/examples' import { downloadAndExtractExample, downloadAndExtractRepo, getRepoInfo, existsInRepo, hasRepo, - RepoInfo, } from './helpers/examples' import { makeDir } from './helpers/make-dir' import { tryGitInit } from './helpers/git' @@ -19,12 +19,8 @@ import { getOnline } from './helpers/is-online' import { isWriteable } from './helpers/is-writeable' import type { PackageManager } from './helpers/get-pkg-manager' -import { - getTemplateFile, - installTemplate, - TemplateMode, - TemplateType, -} from './templates' +import type { TemplateMode, TemplateType } from './templates' +import { getTemplateFile, installTemplate } from './templates' export class DownloadError extends Error {} diff --git a/packages/font/src/google/get-proxy-agent.ts b/packages/font/src/google/get-proxy-agent.ts index 9095a6f5a12f8..eb2db1b21fa34 100644 --- a/packages/font/src/google/get-proxy-agent.ts +++ b/packages/font/src/google/get-proxy-agent.ts @@ -2,7 +2,7 @@ import HttpsProxyAgent from 'next/dist/compiled/https-proxy-agent' // @ts-ignore import HttpProxyAgent from 'next/dist/compiled/http-proxy-agent' -import { Agent } from 'https' +import type { Agent } from 'https' /** * If the http(s)_proxy environment variables is set, return a proxy agent. diff --git a/packages/next-codemod/lib/cra-to-next/global-css-transform.ts b/packages/next-codemod/lib/cra-to-next/global-css-transform.ts index 6687194e64d57..46b539b1ff9e8 100644 --- a/packages/next-codemod/lib/cra-to-next/global-css-transform.ts +++ b/packages/next-codemod/lib/cra-to-next/global-css-transform.ts @@ -1,5 +1,5 @@ import nodePath from 'path' -import { API, FileInfo, Options } from 'jscodeshift' +import type { API, FileInfo, Options } from 'jscodeshift' export const globalCssContext = { cssImports: new Set(), diff --git a/packages/next-codemod/lib/cra-to-next/index-to-component.ts b/packages/next-codemod/lib/cra-to-next/index-to-component.ts index cb66d61f873be..bcb15b2941d4d 100644 --- a/packages/next-codemod/lib/cra-to-next/index-to-component.ts +++ b/packages/next-codemod/lib/cra-to-next/index-to-component.ts @@ -1,4 +1,4 @@ -import { API, FileInfo, JSXElement, Options } from 'jscodeshift' +import type { API, FileInfo, JSXElement, Options } from 'jscodeshift' export const indexContext = { multipleRenderRoots: false, diff --git a/packages/next-codemod/transforms/add-missing-react-import.ts b/packages/next-codemod/transforms/add-missing-react-import.ts index da966ab8094ba..5e6267ed736c1 100644 --- a/packages/next-codemod/transforms/add-missing-react-import.ts +++ b/packages/next-codemod/transforms/add-missing-react-import.ts @@ -1,4 +1,10 @@ -import { API, Collection, FileInfo, JSCodeshift, Options } from 'jscodeshift' +import type { + API, + Collection, + FileInfo, + JSCodeshift, + Options, +} from 'jscodeshift' function addReactImport(j: JSCodeshift, root: Collection) { // We create an import specifier, this is the value of an import, eg: diff --git a/packages/next-codemod/transforms/name-default-component.ts b/packages/next-codemod/transforms/name-default-component.ts index 8a7d4169ff1da..6e02b73adfdc7 100644 --- a/packages/next-codemod/transforms/name-default-component.ts +++ b/packages/next-codemod/transforms/name-default-component.ts @@ -1,4 +1,4 @@ -import { +import type { API, ArrowFunctionExpression, ASTPath, diff --git a/packages/next-codemod/transforms/new-link.ts b/packages/next-codemod/transforms/new-link.ts index 1214db85c06ef..fce40964cc074 100644 --- a/packages/next-codemod/transforms/new-link.ts +++ b/packages/next-codemod/transforms/new-link.ts @@ -1,4 +1,4 @@ -import { API, FileInfo } from 'jscodeshift' +import type { API, FileInfo } from 'jscodeshift' export default function transformer(file: FileInfo, api: API) { const j = api.jscodeshift.withParser('tsx') diff --git a/packages/next/src/build/analysis/get-page-static-info.ts b/packages/next/src/build/analysis/get-page-static-info.ts index 37440dfe8065c..45e99e28e9933 100644 --- a/packages/next/src/build/analysis/get-page-static-info.ts +++ b/packages/next/src/build/analysis/get-page-static-info.ts @@ -4,7 +4,7 @@ import type { Middleware, RouteHas } from '../../lib/load-custom-routes' import { promises as fs } from 'fs' import LRUCache from 'next/dist/compiled/lru-cache' import { matcher } from 'next/dist/compiled/micromatch' -import { ServerRuntime } from 'next/types' +import type { ServerRuntime } from 'next/types' import { extractExportedConstValue, UnsupportedValueError, diff --git a/packages/next/src/build/babel/loader/get-config.ts b/packages/next/src/build/babel/loader/get-config.ts index 3aaa549176ebf..6fd0d56663df0 100644 --- a/packages/next/src/build/babel/loader/get-config.ts +++ b/packages/next/src/build/babel/loader/get-config.ts @@ -4,7 +4,7 @@ import JSON5 from 'next/dist/compiled/json5' import { createConfigItem, loadOptions } from 'next/dist/compiled/babel/core' import loadConfig from 'next/dist/compiled/babel/core-lib-config' -import { NextBabelLoaderOptions, NextJsLoaderContext } from './types' +import type { NextBabelLoaderOptions, NextJsLoaderContext } from './types' import { consumeIterator } from './util' import * as Log from '../../output/log' diff --git a/packages/next/src/build/babel/loader/index.ts b/packages/next/src/build/babel/loader/index.ts index e7c77416d54fc..b8da35142ca5a 100644 --- a/packages/next/src/build/babel/loader/index.ts +++ b/packages/next/src/build/babel/loader/index.ts @@ -1,6 +1,6 @@ -import { Span } from '../../../trace' +import type { Span } from '../../../trace' import transform from './transform' -import { NextJsLoaderContext } from './types' +import type { NextJsLoaderContext } from './types' async function nextBabelLoader( this: NextJsLoaderContext, diff --git a/packages/next/src/build/babel/loader/transform.ts b/packages/next/src/build/babel/loader/transform.ts index 57dd2985ec419..8357313bb943c 100644 --- a/packages/next/src/build/babel/loader/transform.ts +++ b/packages/next/src/build/babel/loader/transform.ts @@ -11,8 +11,8 @@ import PluginPass from 'next/dist/compiled/babel/core-lib-plugin-pass' import getConfig from './get-config' import { consumeIterator } from './util' -import { Span } from '../../../trace' -import { NextJsLoaderContext } from './types' +import type { Span } from '../../../trace' +import type { NextJsLoaderContext } from './types' function getTraversalParams(file: any, pluginPairs: any[]) { const passPairs = [] diff --git a/packages/next/src/build/babel/loader/types.d.ts b/packages/next/src/build/babel/loader/types.d.ts index 896d2bf55e835..49dedf35776ec 100644 --- a/packages/next/src/build/babel/loader/types.d.ts +++ b/packages/next/src/build/babel/loader/types.d.ts @@ -1,5 +1,5 @@ -import { webpack } from 'next/dist/compiled/webpack/webpack' -import { Span } from '../../../trace' +import type { webpack } from 'next/dist/compiled/webpack/webpack' +import type { Span } from '../../../trace' export interface NextJsLoaderContext extends webpack.LoaderContext<{}> { currentTraceSpan: Span diff --git a/packages/next/src/build/babel/plugins/amp-attributes.ts b/packages/next/src/build/babel/plugins/amp-attributes.ts index b19b7f9184ef3..b76d00ebabc06 100644 --- a/packages/next/src/build/babel/plugins/amp-attributes.ts +++ b/packages/next/src/build/babel/plugins/amp-attributes.ts @@ -1,4 +1,4 @@ -import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core' +import type { NodePath, types, PluginObj } from 'next/dist/compiled/babel/core' export default function AmpAttributePatcher(): PluginObj { return { diff --git a/packages/next/src/build/babel/plugins/commonjs.ts b/packages/next/src/build/babel/plugins/commonjs.ts index 766153450221b..01573619015ca 100644 --- a/packages/next/src/build/babel/plugins/commonjs.ts +++ b/packages/next/src/build/babel/plugins/commonjs.ts @@ -1,4 +1,5 @@ -import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core' +import type { NodePath, types } from 'next/dist/compiled/babel/core' +import type { PluginObj } from 'next/dist/compiled/babel/core' import commonjsPlugin from 'next/dist/compiled/babel/plugin-transform-modules-commonjs' // Handle module.exports in user code diff --git a/packages/next/src/build/babel/plugins/jsx-pragma.ts b/packages/next/src/build/babel/plugins/jsx-pragma.ts index e992088b2435e..8413ddac3fc25 100644 --- a/packages/next/src/build/babel/plugins/jsx-pragma.ts +++ b/packages/next/src/build/babel/plugins/jsx-pragma.ts @@ -1,8 +1,8 @@ -import { +import type { NodePath, - PluginObj, types as BabelTypes, } from 'next/dist/compiled/babel/core' +import type { PluginObj } from 'next/dist/compiled/babel/core' import jsx from 'next/dist/compiled/babel/plugin-syntax-jsx' export default function ({ diff --git a/packages/next/src/build/babel/plugins/next-font-unsupported.ts b/packages/next/src/build/babel/plugins/next-font-unsupported.ts index 49dc853ea3e64..c29dd8e3cd81c 100644 --- a/packages/next/src/build/babel/plugins/next-font-unsupported.ts +++ b/packages/next/src/build/babel/plugins/next-font-unsupported.ts @@ -1,4 +1,5 @@ -import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core' +import type { NodePath, types } from 'next/dist/compiled/babel/core' +import type { PluginObj } from 'next/dist/compiled/babel/core' export default function NextPageDisallowReExportAllExports(): PluginObj { return { diff --git a/packages/next/src/build/babel/plugins/next-page-config.ts b/packages/next/src/build/babel/plugins/next-page-config.ts index 3126ba6ccf533..ceae6f8dd952d 100644 --- a/packages/next/src/build/babel/plugins/next-page-config.ts +++ b/packages/next/src/build/babel/plugins/next-page-config.ts @@ -1,11 +1,11 @@ -import { - NodePath, +import { types as BabelTypes } from 'next/dist/compiled/babel/core' +import type { PluginObj, PluginPass, - types as BabelTypes, Visitor, + NodePath, } from 'next/dist/compiled/babel/core' -import { PageConfig } from 'next/types' +import type { PageConfig } from 'next/types' import { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants' const CONFIG_KEY = 'config' diff --git a/packages/next/src/build/babel/plugins/next-page-disallow-re-export-all-exports.ts b/packages/next/src/build/babel/plugins/next-page-disallow-re-export-all-exports.ts index 93ffe83ea838b..7814fbecd995a 100644 --- a/packages/next/src/build/babel/plugins/next-page-disallow-re-export-all-exports.ts +++ b/packages/next/src/build/babel/plugins/next-page-disallow-re-export-all-exports.ts @@ -1,4 +1,5 @@ -import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core' +import type { NodePath, types } from 'next/dist/compiled/babel/core' +import type { PluginObj } from 'next/dist/compiled/babel/core' export default function NextPageDisallowReExportAllExports(): PluginObj { return { diff --git a/packages/next/src/build/babel/plugins/next-ssg-transform.ts b/packages/next/src/build/babel/plugins/next-ssg-transform.ts index eb741358a1ce5..db6be10944b94 100644 --- a/packages/next/src/build/babel/plugins/next-ssg-transform.ts +++ b/packages/next/src/build/babel/plugins/next-ssg-transform.ts @@ -1,8 +1,8 @@ -import { +import type { NodePath, - PluginObj, types as BabelTypes, } from 'next/dist/compiled/babel/core' +import type { PluginObj } from 'next/dist/compiled/babel/core' import { SERVER_PROPS_SSG_CONFLICT } from '../../../lib/constants' import { SERVER_PROPS_ID, STATIC_PROPS_ID } from '../../../shared/lib/constants' diff --git a/packages/next/src/build/babel/plugins/optimize-hook-destructuring.ts b/packages/next/src/build/babel/plugins/optimize-hook-destructuring.ts index a951ae376b6b2..63e9ccd7abe11 100644 --- a/packages/next/src/build/babel/plugins/optimize-hook-destructuring.ts +++ b/packages/next/src/build/babel/plugins/optimize-hook-destructuring.ts @@ -1,9 +1,8 @@ -import { +import type { NodePath, - PluginObj, types as BabelTypes, } from 'next/dist/compiled/babel/core' - +import type { PluginObj } from 'next/dist/compiled/babel/core' // matches any hook-like (the default) const isHook = /^use[A-Z]/ diff --git a/packages/next/src/build/babel/plugins/react-loadable-plugin.ts b/packages/next/src/build/babel/plugins/react-loadable-plugin.ts index 045f29271a673..884e6f3b1ed26 100644 --- a/packages/next/src/build/babel/plugins/react-loadable-plugin.ts +++ b/packages/next/src/build/babel/plugins/react-loadable-plugin.ts @@ -23,11 +23,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR // Modified to put `webpack` and `modules` under `loadableGenerated` to be backwards compatible with next/dynamic which has a `modules` key // Modified to support `dynamic(import('something'))` and `dynamic(import('something'), options) -import { +import type { NodePath, - PluginObj, types as BabelTypes, } from 'next/dist/compiled/babel/core' +import type { PluginObj } from 'next/dist/compiled/babel/core' import { relative as relativePath } from 'path' diff --git a/packages/next/src/build/babel/preset.ts b/packages/next/src/build/babel/preset.ts index 5ea2a647a5e9b..4a2f34fb825f4 100644 --- a/packages/next/src/build/babel/preset.ts +++ b/packages/next/src/build/babel/preset.ts @@ -1,4 +1,4 @@ -import { PluginItem } from 'next/dist/compiled/babel/core' +import type { PluginItem } from 'next/dist/compiled/babel/core' import { dirname } from 'path' const isLoadIntentTest = process.env.NODE_ENV === 'test' diff --git a/packages/next/src/build/collect-build-traces.ts b/packages/next/src/build/collect-build-traces.ts index e64fd17834698..54f72c254a91a 100644 --- a/packages/next/src/build/collect-build-traces.ts +++ b/packages/next/src/build/collect-build-traces.ts @@ -14,7 +14,7 @@ import { import path from 'path' import fs from 'fs/promises' -import { PageInfo } from './utils' +import type { PageInfo } from './utils' import { loadBindings } from './swc' import { nonNullable } from '../lib/non-nullable' import * as ciEnvironment from '../telemetry/ci-info' diff --git a/packages/next/src/build/compiler.ts b/packages/next/src/build/compiler.ts index 8af624eae1dc0..5206a4d7813ad 100644 --- a/packages/next/src/build/compiler.ts +++ b/packages/next/src/build/compiler.ts @@ -1,5 +1,5 @@ import { webpack } from 'next/dist/compiled/webpack/webpack' -import { Span } from '../trace' +import type { Span } from '../trace' export type CompilerResult = { errors: webpack.StatsError[] diff --git a/packages/next/src/build/entries.ts b/packages/next/src/build/entries.ts index 551f2a5e960b0..828eb49bda84e 100644 --- a/packages/next/src/build/entries.ts +++ b/packages/next/src/build/entries.ts @@ -32,11 +32,11 @@ import { CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, CLIENT_STATIC_FILES_RUNTIME_POLYFILLS, CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH, - CompilerNameValues, COMPILER_NAMES, EDGE_RUNTIME_WEBPACK, } from '../shared/lib/constants' -import { __ApiPreviewProps } from '../server/api-utils' +import type { CompilerNameValues } from '../shared/lib/constants' +import type { __ApiPreviewProps } from '../server/api-utils' import { warn } from './output/log' import { isMiddlewareFile, @@ -46,10 +46,10 @@ import { import { getPageStaticInfo } from './analysis/get-page-static-info' import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' -import { ServerRuntime } from '../../types' +import type { ServerRuntime } from '../../types' import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' import { encodeMatchers } from './webpack/loaders/next-middleware-loader' -import { EdgeFunctionLoaderOptions } from './webpack/loaders/next-edge-function-loader' +import type { EdgeFunctionLoaderOptions } from './webpack/loaders/next-edge-function-loader' import { isAppRouteRoute } from '../lib/is-app-route-route' import { normalizeMetadataRoute } from '../lib/metadata/get-metadata-route' import { getRouteLoaderEntry } from './webpack/loaders/next-route-loader' diff --git a/packages/next/src/build/handle-externals.ts b/packages/next/src/build/handle-externals.ts index a52f9dea1a021..2e0eb816b1495 100644 --- a/packages/next/src/build/handle-externals.ts +++ b/packages/next/src/build/handle-externals.ts @@ -1,4 +1,5 @@ -import { WebpackLayerName, WEBPACK_LAYERS } from '../lib/constants' +import { WEBPACK_LAYERS } from '../lib/constants' +import type { WebpackLayerName } from '../lib/constants' import { defaultOverrides } from '../server/require-hook' import { BARREL_OPTIMIZATION_PREFIX } from '../shared/lib/constants' import path from '../shared/lib/isomorphic/path' @@ -9,7 +10,7 @@ import { NODE_RESOLVE_OPTIONS, } from './webpack-config' import { isWebpackAppLayer, isWebpackServerLayer } from './worker' -import { NextConfigComplete } from '../server/config-shared' +import type { NextConfigComplete } from '../server/config-shared' const reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\/)/ const pathSeparators = '[/\\\\]' diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index a226078d05853..4b6654d25349c 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -31,9 +31,11 @@ import { import { FileType, fileExists } from '../lib/file-exists' import { findPagesDir } from '../lib/find-pages-dir' import loadCustomRoutes, { + normalizeRouteRegex, +} from '../lib/load-custom-routes' +import type { CustomRoutes, Header, - normalizeRouteRegex, Redirect, Rewrite, RouteHas, @@ -72,9 +74,9 @@ import { FUNCTIONS_CONFIG_MANIFEST, } from '../shared/lib/constants' import { getSortedRoutes, isDynamicRoute } from '../shared/lib/router/utils' -import { __ApiPreviewProps } from '../server/api-utils' +import type { __ApiPreviewProps } from '../server/api-utils' import loadConfig from '../server/config' -import { BuildManifest } from '../server/get-page-files' +import type { BuildManifest } from '../server/get-page-files' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' import { getPagePath } from '../server/require' import * as ciEnvironment from '../telemetry/ci-info' @@ -84,10 +86,10 @@ import { eventBuildFeatureUsage, eventNextPlugins, EVENT_BUILD_FEATURE_USAGE, - EventBuildFeatureUsage, eventPackageUsedInGetServerSideProps, eventBuildCompleted, } from '../telemetry/events' +import type { EventBuildFeatureUsage } from '../telemetry/events' import { Telemetry } from '../telemetry/storage' import { isDynamicMetadataRoute, @@ -103,17 +105,17 @@ import { detectConflictingPaths, computeFromManifest, getJsPageSizeInKb, - PageInfo, printCustomRoutes, printTreeView, copyTracedFiles, isReservedPage, - AppConfig, isAppBuiltinNotFoundPage, } from './utils' +import type { PageInfo, AppConfig } from './utils' import { writeBuildId } from './write-build-id' import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' -import isError, { NextError } from '../lib/is-error' +import isError from '../lib/is-error' +import type { NextError } from '../lib/is-error' import { isEdgeRuntime } from '../lib/is-edge-runtime' import { recursiveCopy } from '../lib/recursive-copy' import { recursiveReadDir } from '../lib/recursive-readdir' @@ -149,7 +151,7 @@ import { buildDataRoute } from '../server/lib/router-utils/build-data-route' import { initialize as initializeIncrementalCache } from '../server/lib/incremental-cache-server' import { nodeFs } from '../server/lib/node-fs-methods' import { collectBuildTraces } from './collect-build-traces' -import { BuildTraceContext } from './webpack/plugins/next-trace-entrypoints-plugin' +import type { BuildTraceContext } from './webpack/plugins/next-trace-entrypoints-plugin' import { formatManifest } from './manifests/formatter/format-manifest' interface ExperimentalBypassForInfo { diff --git a/packages/next/src/build/load-jsconfig.ts b/packages/next/src/build/load-jsconfig.ts index aaca3d52f7061..28f37dc6ce7d3 100644 --- a/packages/next/src/build/load-jsconfig.ts +++ b/packages/next/src/build/load-jsconfig.ts @@ -1,6 +1,6 @@ import path from 'path' import fs from 'fs' -import { NextConfigComplete } from '../server/config-shared' +import type { NextConfigComplete } from '../server/config-shared' import * as Log from './output/log' import { getTypeScriptConfiguration } from '../lib/typescript/getTypeScriptConfiguration' import { readFileSync } from 'fs' diff --git a/packages/next/src/build/output/index.ts b/packages/next/src/build/output/index.ts index 60932a079c11e..1519fe64387e8 100644 --- a/packages/next/src/build/output/index.ts +++ b/packages/next/src/build/output/index.ts @@ -3,9 +3,11 @@ import stripAnsi from 'next/dist/compiled/strip-ansi' import textTable from 'next/dist/compiled/text-table' import createStore from 'next/dist/compiled/unistore' import formatWebpackMessages from '../../client/dev/error-overlay/format-webpack-messages' -import { OutputState, store as consoleStore } from './store' +import { store as consoleStore } from './store' +import type { OutputState } from './store' import type { webpack } from 'next/dist/compiled/webpack/webpack' -import { CompilerNameValues, COMPILER_NAMES } from '../../shared/lib/constants' +import { COMPILER_NAMES } from '../../shared/lib/constants' +import type { CompilerNameValues } from '../../shared/lib/constants' export function startedDevelopmentServer(appUrl: string, bindAddr: string) { consoleStore.setState({ appUrl, bindAddr }) diff --git a/packages/next/src/build/swc/index.ts b/packages/next/src/build/swc/index.ts index 6accfadab603c..7d7f2ea107d49 100644 --- a/packages/next/src/build/swc/index.ts +++ b/packages/next/src/build/swc/index.ts @@ -8,12 +8,10 @@ import { getParserOptions } from './options' import { eventSwcLoadFailure } from '../../telemetry/events/swc-load-failure' import { patchIncorrectLockfile } from '../../lib/patch-incorrect-lockfile' import { downloadWasmSwc, downloadNativeNextSwc } from '../../lib/download-swc' -import { NextConfigComplete, TurboRule } from '../../server/config-shared' +import type { NextConfigComplete, TurboRule } from '../../server/config-shared' import { isDeepStrictEqual } from 'util' -import { - DefineEnvPluginOptions, - getDefineEnv, -} from '../webpack/plugins/define-env-plugin' +import { getDefineEnv } from '../webpack/plugins/define-env-plugin' +import type { DefineEnvPluginOptions } from '../webpack/plugins/define-env-plugin' const nextVersion = process.env.__NEXT_VERSION as string diff --git a/packages/next/src/build/type-check.ts b/packages/next/src/build/type-check.ts index b52cfb6d9743d..c8c18352311da 100644 --- a/packages/next/src/build/type-check.ts +++ b/packages/next/src/build/type-check.ts @@ -11,12 +11,12 @@ import { eventTypeCheckCompleted } from '../telemetry/events' import isError from '../lib/is-error' /** - * typescript will be loaded in "next/lib/verifyTypeScriptSetup" and + * typescript will be loaded in "next/lib/verify-typescript-setup" and * then passed to "next/lib/typescript/runTypeCheck" as a parameter. * * Since it is impossible to pass a function from main thread to a worker, * instead of running "next/lib/typescript/runTypeCheck" in a worker, - * we will run entire "next/lib/verifyTypeScriptSetup" in a worker instead. + * we will run entire "next/lib/verify-typescript-setup" in a worker instead. */ function verifyTypeScriptSetup( dir: string, @@ -31,14 +31,14 @@ function verifyTypeScriptSetup( hasPagesDir: boolean ) { const typeCheckWorker = new JestWorker( - require.resolve('../lib/verifyTypeScriptSetup'), + require.resolve('../lib/verify-typescript-setup'), { numWorkers: 1, enableWorkerThreads, maxRetries: 0, } ) as JestWorker & { - verifyTypeScriptSetup: typeof import('../lib/verifyTypeScriptSetup').verifyTypeScriptSetup + verifyTypeScriptSetup: typeof import('../lib/verify-typescript-setup').verifyTypeScriptSetup } typeCheckWorker.getStdout().pipe(process.stdout) diff --git a/packages/next/src/build/utils.ts b/packages/next/src/build/utils.ts index 5742f6da9b348..beb14976125d3 100644 --- a/packages/next/src/build/utils.ts +++ b/packages/next/src/build/utils.ts @@ -50,10 +50,8 @@ import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing- import { isEdgeRuntime } from '../lib/is-edge-runtime' import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' import * as Log from './output/log' -import { - loadComponents, - LoadComponentsReturnType, -} from '../server/load-components' +import { loadComponents } from '../server/load-components' +import type { LoadComponentsReturnType } from '../server/load-components' import { trace } from '../trace' import { setHttpClientAndAgentOptions } from '../server/setup-http-agent-env' import { Sema } from 'next/dist/compiled/async-sema' diff --git a/packages/next/src/build/webpack-build/impl.ts b/packages/next/src/build/webpack-build/impl.ts index d0c686c2c3d74..d64f0eaca9d03 100644 --- a/packages/next/src/build/webpack-build/impl.ts +++ b/packages/next/src/build/webpack-build/impl.ts @@ -1,18 +1,18 @@ -import { type webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' import { red } from '../../lib/picocolors' import formatWebpackMessages from '../../client/dev/error-overlay/format-webpack-messages' import { nonNullable } from '../../lib/non-nullable' +import type { COMPILER_INDEXES } from '../../shared/lib/constants' import { COMPILER_NAMES, CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, APP_CLIENT_INTERNALS, PHASE_PRODUCTION_BUILD, - COMPILER_INDEXES, } from '../../shared/lib/constants' import { runCompiler } from '../compiler' import * as Log from '../output/log' import getBaseWebpackConfig, { loadProjectInfo } from '../webpack-config' -import { NextError } from '../../lib/is-error' +import type { NextError } from '../../lib/is-error' import { TelemetryPlugin } from '../webpack/plugins/telemetry-plugin' import { NextBuildContext, @@ -23,11 +23,9 @@ import { createEntrypoints } from '../entries' import loadConfig from '../../server/config' import { trace } from '../../trace' import { WEBPACK_LAYERS } from '../../lib/constants' -import { - BuildTraceContext, - TraceEntryPointsPlugin, -} from '../webpack/plugins/next-trace-entrypoints-plugin' -import { UnwrapPromise } from '../../lib/coalesced-function' +import { TraceEntryPointsPlugin } from '../webpack/plugins/next-trace-entrypoints-plugin' +import type { BuildTraceContext } from '../webpack/plugins/next-trace-entrypoints-plugin' +import type { UnwrapPromise } from '../../lib/coalesced-function' import origDebug from 'next/dist/compiled/debug' diff --git a/packages/next/src/build/webpack-build/index.ts b/packages/next/src/build/webpack-build/index.ts index 9d5855f8c5072..6d55342f1ebce 100644 --- a/packages/next/src/build/webpack-build/index.ts +++ b/packages/next/src/build/webpack-build/index.ts @@ -1,10 +1,10 @@ -import { COMPILER_INDEXES } from '../../shared/lib/constants' +import type { COMPILER_INDEXES } from '../../shared/lib/constants' import * as Log from '../output/log' import { NextBuildContext } from '../build-context' import type { BuildTraceContext } from '../webpack/plugins/next-trace-entrypoints-plugin' import { Worker } from 'next/dist/compiled/jest-worker' import origDebug from 'next/dist/compiled/debug' -import { ChildProcess } from 'child_process' +import type { ChildProcess } from 'child_process' import path from 'path' const debug = origDebug('next:build:webpack-build') diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 2681305d6fb49..1a3344be3a1d7 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -17,10 +17,10 @@ import { RSC_ACTION_CLIENT_WRAPPER_ALIAS, RSC_ACTION_VALIDATE_ALIAS, WEBPACK_RESOURCE_QUERIES, - WebpackLayerName, } from '../lib/constants' +import type { WebpackLayerName } from '../lib/constants' import { isWebpackDefaultLayer, isWebpackServerLayer } from './utils' -import { CustomRoutes } from '../lib/load-custom-routes.js' +import type { CustomRoutes } from '../lib/load-custom-routes.js' import { CLIENT_STATIC_FILES_RUNTIME_AMP, CLIENT_STATIC_FILES_RUNTIME_MAIN, @@ -32,10 +32,10 @@ import { REACT_LOADABLE_MANIFEST, SERVER_DIRECTORY, COMPILER_NAMES, - CompilerNameValues, } from '../shared/lib/constants' +import type { CompilerNameValues } from '../shared/lib/constants' import { execOnce } from '../shared/lib/utils' -import { NextConfigComplete } from '../server/config-shared' +import type { NextConfigComplete } from '../server/config-shared' import { finalizeEntrypoint } from './entries' import * as Log from './output/log' import { buildConfiguration } from './webpack/config' @@ -72,7 +72,7 @@ import { getBabelConfigFile } from './get-babel-config-file' import { defaultOverrides } from '../server/require-hook' import { needsExperimentalReact } from '../lib/needs-experimental-react' import { getDefineEnvPlugin } from './webpack/plugins/define-env-plugin' -import { SWCLoaderOptions } from './webpack/loaders/next-swc-loader' +import type { SWCLoaderOptions } from './webpack/loaders/next-swc-loader' import { isResourceInPackages, makeExternalHandler } from './handle-externals' type ExcludesFalse = (x: T | false) => x is T diff --git a/packages/next/src/build/webpack/config/blocks/base.ts b/packages/next/src/build/webpack/config/blocks/base.ts index c580c056faaef..2fc42f11bcb80 100644 --- a/packages/next/src/build/webpack/config/blocks/base.ts +++ b/packages/next/src/build/webpack/config/blocks/base.ts @@ -1,7 +1,7 @@ import curry from 'next/dist/compiled/lodash.curry' -import { webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' import { COMPILER_NAMES } from '../../../../shared/lib/constants' -import { ConfigurationContext } from '../utils' +import type { ConfigurationContext } from '../utils' export const base = curry(function base( ctx: ConfigurationContext, diff --git a/packages/next/src/build/webpack/config/blocks/css/index.ts b/packages/next/src/build/webpack/config/blocks/css/index.ts index 632c5fa959993..4cd621d937f5c 100644 --- a/packages/next/src/build/webpack/config/blocks/css/index.ts +++ b/packages/next/src/build/webpack/config/blocks/css/index.ts @@ -1,7 +1,8 @@ import curry from 'next/dist/compiled/lodash.curry' -import { webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' import { loader, plugin } from '../../helpers' -import { ConfigurationContext, ConfigurationFn, pipe } from '../../utils' +import { pipe } from '../../utils' +import type { ConfigurationContext, ConfigurationFn } from '../../utils' import { getCssModuleLoader, getGlobalCssLoader } from './loaders' import { getNextFontLoader } from './loaders/next-font' import { diff --git a/packages/next/src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts b/packages/next/src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts index 567329efb404f..2291a07484e4d 100644 --- a/packages/next/src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts +++ b/packages/next/src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts @@ -1,6 +1,6 @@ import loaderUtils from 'next/dist/compiled/loader-utils3' import path from 'path' -import { webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' const regexLikeIndexModule = /(? source export default NoopLoader diff --git a/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts b/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts index f67dbf9f688e3..015dd08426bfd 100644 --- a/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts +++ b/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts @@ -12,7 +12,7 @@ import { CLIENT_STATIC_FILES_RUNTIME_AMP, SYSTEM_ENTRYPOINTS, } from '../../../shared/lib/constants' -import { BuildManifest } from '../../../server/get-page-files' +import type { BuildManifest } from '../../../server/get-page-files' import getRouteFromEntrypoint from '../../../server/get-route-from-entrypoint' import { ampFirstEntryNamesMap } from './next-drop-client-page-plugin' import { getSortedRoutes } from '../../../shared/lib/router/utils' diff --git a/packages/next/src/build/webpack/plugins/css-minimizer-plugin.ts b/packages/next/src/build/webpack/plugins/css-minimizer-plugin.ts index 7d2a328a94add..d79ad14b71b4e 100644 --- a/packages/next/src/build/webpack/plugins/css-minimizer-plugin.ts +++ b/packages/next/src/build/webpack/plugins/css-minimizer-plugin.ts @@ -1,6 +1,7 @@ import cssnanoSimple from 'next/dist/compiled/cssnano-simple' import postcssScss from 'next/dist/compiled/postcss-scss' -import postcss, { Parser } from 'postcss' +import postcss from 'postcss' +import type { Parser } from 'postcss' import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { spans } from './profiling-plugin' diff --git a/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts b/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts index 0c2e964c7439e..c62935a243a84 100644 --- a/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts +++ b/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts @@ -32,7 +32,7 @@ import { import { traverseModules, forEachEntryModule } from '../utils' import { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep' import { getProxiedPluginState } from '../../build-context' -import { SizeLimit } from '../../../../types' +import type { SizeLimit } from '../../../../types' interface Options { dev: boolean diff --git a/packages/next/src/build/webpack/plugins/font-stylesheet-gathering-plugin.ts b/packages/next/src/build/webpack/plugins/font-stylesheet-gathering-plugin.ts index ea5eedfb28fd9..399bc60aa7d48 100644 --- a/packages/next/src/build/webpack/plugins/font-stylesheet-gathering-plugin.ts +++ b/packages/next/src/build/webpack/plugins/font-stylesheet-gathering-plugin.ts @@ -6,8 +6,8 @@ import { import { getFontDefinitionFromNetwork, getFontOverrideCss, - FontManifest, } from '../../../server/font-utils' +import type { FontManifest } from '../../../server/font-utils' import postcss from 'postcss' import minifier from 'next/dist/compiled/cssnano-simple' import { diff --git a/packages/next/src/build/webpack/plugins/jsconfig-paths-plugin.ts b/packages/next/src/build/webpack/plugins/jsconfig-paths-plugin.ts index 25b73740cdd4c..2e65e9e74ed33 100644 --- a/packages/next/src/build/webpack/plugins/jsconfig-paths-plugin.ts +++ b/packages/next/src/build/webpack/plugins/jsconfig-paths-plugin.ts @@ -4,7 +4,7 @@ * https://github.com/microsoft/TypeScript/blob/214df64e287804577afa1fea0184c18c40f7d1ca/LICENSE.txt */ import path from 'path' -import { webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' import { debug } from 'next/dist/compiled/debug' const log = debug('next:jsconfig-paths-plugin') diff --git a/packages/next/src/build/webpack/plugins/memory-with-gc-cache-plugin.ts b/packages/next/src/build/webpack/plugins/memory-with-gc-cache-plugin.ts index 8a0f6b480c2c3..65c734378270d 100644 --- a/packages/next/src/build/webpack/plugins/memory-with-gc-cache-plugin.ts +++ b/packages/next/src/build/webpack/plugins/memory-with-gc-cache-plugin.ts @@ -32,7 +32,8 @@ The default for max generations is 5, so 1/5th of the modules would be marked fo This plugin instead always checks the cache and decreases the time to live of all entries. That way memory is cleaned up earlier. */ -import { type Compiler, webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' +import type { Compiler } from 'next/dist/compiled/webpack/webpack' // Webpack doesn't expose Etag as a type so get it this way instead. type Etag = Parameters[1] diff --git a/packages/next/src/build/webpack/plugins/middleware-plugin.ts b/packages/next/src/build/webpack/plugins/middleware-plugin.ts index 07536f36831b2..17fe1c6cb6754 100644 --- a/packages/next/src/build/webpack/plugins/middleware-plugin.ts +++ b/packages/next/src/build/webpack/plugins/middleware-plugin.ts @@ -22,8 +22,8 @@ import { SERVER_REFERENCE_MANIFEST, PRERENDER_MANIFEST, } from '../../../shared/lib/constants' -import { MiddlewareConfig } from '../../analysis/get-page-static-info' -import { Telemetry } from '../../../telemetry/storage' +import type { MiddlewareConfig } from '../../analysis/get-page-static-info' +import type { Telemetry } from '../../../telemetry/storage' import { traceGlobals } from '../../../trace/shared' import { EVENT_BUILD_FEATURE_USAGE } from '../../../telemetry/events' import { normalizeAppPath } from '../../../shared/lib/router/utils/app-paths' diff --git a/packages/next/src/build/webpack/plugins/next-drop-client-page-plugin.ts b/packages/next/src/build/webpack/plugins/next-drop-client-page-plugin.ts index 0706a8515afd3..b03428e7c32cb 100644 --- a/packages/next/src/build/webpack/plugins/next-drop-client-page-plugin.ts +++ b/packages/next/src/build/webpack/plugins/next-drop-client-page-plugin.ts @@ -1,4 +1,4 @@ -import { webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' import { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants' export const ampFirstEntryNamesMap: WeakMap = diff --git a/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts b/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts index 7ce133dbb774d..1f61d3520d29d 100644 --- a/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts +++ b/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts @@ -1,11 +1,9 @@ import nodePath from 'path' -import { Span } from '../../../trace' +import type { Span } from '../../../trace' import { spans } from './profiling-plugin' import isError from '../../../lib/is-error' -import { - nodeFileTrace, - NodeFileTraceReasons, -} from 'next/dist/compiled/@vercel/nft' +import { nodeFileTrace } from 'next/dist/compiled/@vercel/nft' +import type { NodeFileTraceReasons } from 'next/dist/compiled/@vercel/nft' import { CLIENT_REFERENCE_MANIFEST, TRACE_OUTPUT_VERSION, @@ -15,7 +13,7 @@ import { NODE_ESM_RESOLVE_OPTIONS, NODE_RESOLVE_OPTIONS, } from '../../webpack-config' -import { NextConfigComplete } from '../../../server/config-shared' +import type { NextConfigComplete } from '../../../server/config-shared' import { loadBindings } from '../../swc' import { isMatch } from 'next/dist/compiled/micromatch' import { getModuleBuildInfo } from '../loaders/get-module-build-info' diff --git a/packages/next/src/build/webpack/plugins/profiling-plugin.ts b/packages/next/src/build/webpack/plugins/profiling-plugin.ts index 1534368c298c7..c2c48b3de2d08 100644 --- a/packages/next/src/build/webpack/plugins/profiling-plugin.ts +++ b/packages/next/src/build/webpack/plugins/profiling-plugin.ts @@ -1,5 +1,5 @@ import { NormalModule } from 'next/dist/compiled/webpack/webpack' -import { Span } from '../../../trace' +import type { Span } from '../../../trace' import type { webpack } from 'next/dist/compiled/webpack/webpack' const pluginName = 'ProfilingPlugin' diff --git a/packages/next/src/build/webpack/plugins/telemetry-plugin.ts b/packages/next/src/build/webpack/plugins/telemetry-plugin.ts index 156ef5802d24d..9299dd78206cb 100644 --- a/packages/next/src/build/webpack/plugins/telemetry-plugin.ts +++ b/packages/next/src/build/webpack/plugins/telemetry-plugin.ts @@ -1,4 +1,5 @@ -import { NormalModule, webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' +import { NormalModule } from 'next/dist/compiled/webpack/webpack' /** * List of target triples next-swc native binary supports. diff --git a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.ts b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.ts index 6862511ea0de6..4281344e71ed2 100644 --- a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.ts +++ b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.ts @@ -6,7 +6,7 @@ import { getBabelError } from './parseBabel' import { getCssError } from './parseCss' import { getScssError } from './parseScss' import { getNotFoundError, getImageError } from './parseNotFoundError' -import { SimpleWebpackError } from './simpleWebpackError' +import type { SimpleWebpackError } from './simpleWebpackError' import isError from '../../../../lib/is-error' import { getRscError } from './parseRSC' import { getNextFontError } from './parseNextFontError' diff --git a/packages/next/src/build/webpack/utils.ts b/packages/next/src/build/webpack/utils.ts index 8470a323642e1..95aa01b18bc23 100644 --- a/packages/next/src/build/webpack/utils.ts +++ b/packages/next/src/build/webpack/utils.ts @@ -1,4 +1,4 @@ -import { webpack } from 'next/dist/compiled/webpack/webpack' +import type { webpack } from 'next/dist/compiled/webpack/webpack' import { isAppRouteRoute } from '../../lib/is-app-route-route' export function traverseModules( diff --git a/packages/next/src/cli/next-build-args.ts b/packages/next/src/cli/next-build-args.ts index 814ac16df8396..7d328bc68935a 100755 --- a/packages/next/src/cli/next-build-args.ts +++ b/packages/next/src/cli/next-build-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' export const validArgs: arg.Spec = { // Types diff --git a/packages/next/src/cli/next-build.ts b/packages/next/src/cli/next-build.ts index d0b3334e55454..634bbc0fc5a59 100755 --- a/packages/next/src/cli/next-build.ts +++ b/packages/next/src/cli/next-build.ts @@ -3,7 +3,7 @@ import '../server/lib/cpu-profile' import { existsSync } from 'fs' import * as Log from '../build/output/log' -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import build from '../build' import { printAndExit } from '../server/lib/utils' import isError from '../lib/is-error' diff --git a/packages/next/src/cli/next-dev-args.ts b/packages/next/src/cli/next-dev-args.ts index 7d89d04b41940..a1ce6258936d7 100644 --- a/packages/next/src/cli/next-dev-args.ts +++ b/packages/next/src/cli/next-dev-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' export const validArgs: arg.Spec = { // Types diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index 70546ea42f008..9805f183f2dd0 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -4,21 +4,19 @@ import '../server/lib/cpu-profile' import type { StartServerOptions } from '../server/lib/start-server' import { RESTART_EXIT_CODE, getPort, printAndExit } from '../server/lib/utils' import * as Log from '../build/output/log' -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import { getProjectDir } from '../lib/get-project-dir' import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' import path from 'path' -import { NextConfigComplete } from '../server/config-shared' +import type { NextConfigComplete } from '../server/config-shared' import { setGlobal, traceGlobals } from '../trace/shared' import { Telemetry } from '../telemetry/storage' import loadConfig, { getEnabledExperimentalFeatures } from '../server/config' import { findPagesDir } from '../lib/find-pages-dir' import { fileExists, FileType } from '../lib/file-exists' import { getNpxCommand } from '../lib/helpers/get-npx-command' -import { - SelfSignedCertificate, - createSelfSignedCertificate, -} from '../lib/mkcert' +import { createSelfSignedCertificate } from '../lib/mkcert' +import type { SelfSignedCertificate } from '../lib/mkcert' import uploadTrace from '../trace/upload-trace' import { initialEnv, loadEnvConfig } from '@next/env' import { trace } from '../trace' diff --git a/packages/next/src/cli/next-export-args.ts b/packages/next/src/cli/next-export-args.ts index e6c66da77dd30..f573274be7a1b 100755 --- a/packages/next/src/cli/next-export-args.ts +++ b/packages/next/src/cli/next-export-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' export const validArgs: arg.Spec = { // Types diff --git a/packages/next/src/cli/next-export.ts b/packages/next/src/cli/next-export.ts index a53d05dce0c01..1791ced809b16 100755 --- a/packages/next/src/cli/next-export.ts +++ b/packages/next/src/cli/next-export.ts @@ -7,7 +7,7 @@ import { cyan } from '../lib/picocolors' import exportApp, { ExportError } from '../export' import * as Log from '../build/output/log' import { printAndExit } from '../server/lib/utils' -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import { trace } from '../trace' import { getProjectDir } from '../lib/get-project-dir' diff --git a/packages/next/src/cli/next-info-args.ts b/packages/next/src/cli/next-info-args.ts index dafea92660d84..53cdbc4b92da9 100755 --- a/packages/next/src/cli/next-info-args.ts +++ b/packages/next/src/cli/next-info-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' /** * Supported CLI arguments. diff --git a/packages/next/src/cli/next-info.ts b/packages/next/src/cli/next-info.ts index 46d2f4efb41c0..282f742368f79 100755 --- a/packages/next/src/cli/next-info.ts +++ b/packages/next/src/cli/next-info.ts @@ -7,7 +7,7 @@ import { bold, cyan, yellow } from '../lib/picocolors' const { fetch } = require('next/dist/compiled/undici') as { fetch: typeof global.fetch } -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import { PHASE_INFO } from '../shared/lib/constants' import loadConfig from '../server/config' diff --git a/packages/next/src/cli/next-lint-args.ts b/packages/next/src/cli/next-lint-args.ts index 854af64be303f..5e1fbfe3c49aa 100755 --- a/packages/next/src/cli/next-lint-args.ts +++ b/packages/next/src/cli/next-lint-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' const validEslintArgs: arg.Spec = { // Types diff --git a/packages/next/src/cli/next-lint.ts b/packages/next/src/cli/next-lint.ts index 93984a473d658..170826fb071c4 100755 --- a/packages/next/src/cli/next-lint.ts +++ b/packages/next/src/cli/next-lint.ts @@ -4,7 +4,7 @@ import { existsSync } from 'fs' import { join } from 'path' import { green } from '../lib/picocolors' -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import { ESLINT_DEFAULT_DIRS } from '../lib/constants' import { runLintCheck } from '../lib/eslint/runLintCheck' import { printAndExit } from '../server/lib/utils' @@ -15,7 +15,7 @@ import { eventLintCheckCompleted } from '../telemetry/events' import { CompileError } from '../lib/compile-error' import { getProjectDir } from '../lib/get-project-dir' import { findPagesDir } from '../lib/find-pages-dir' -import { verifyTypeScriptSetup } from '../lib/verifyTypeScriptSetup' +import { verifyTypeScriptSetup } from '../lib/verify-typescript-setup' const eslintOptions = (args: arg.Spec, defaultCacheLocation: string) => ({ overrideConfigFile: args['--config'] || null, diff --git a/packages/next/src/cli/next-start-args.ts b/packages/next/src/cli/next-start-args.ts index 1c95bafd0bc71..151d1cd33bc4d 100755 --- a/packages/next/src/cli/next-start-args.ts +++ b/packages/next/src/cli/next-start-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' export const validArgs: arg.Spec = { // Types diff --git a/packages/next/src/cli/next-start.ts b/packages/next/src/cli/next-start.ts index 312ddf8ebc2cf..9b072ba99edb9 100755 --- a/packages/next/src/cli/next-start.ts +++ b/packages/next/src/cli/next-start.ts @@ -3,7 +3,7 @@ import '../server/lib/cpu-profile' import { startServer } from '../server/lib/start-server' import { getPort, printAndExit } from '../server/lib/utils' import { getProjectDir } from '../lib/get-project-dir' -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import { getReservedPortExplanation, isPortIsReserved, diff --git a/packages/next/src/cli/next-telemetry-args.ts b/packages/next/src/cli/next-telemetry-args.ts index 91b07af36d4fe..bdb5a7375076c 100755 --- a/packages/next/src/cli/next-telemetry-args.ts +++ b/packages/next/src/cli/next-telemetry-args.ts @@ -1,4 +1,4 @@ -import arg from 'next/dist/compiled/arg/index.js' +import type arg from 'next/dist/compiled/arg/index.js' export const validArgs: arg.Spec = { // Types diff --git a/packages/next/src/cli/next-telemetry.ts b/packages/next/src/cli/next-telemetry.ts index 7a61b92bbfb82..e1039873131b4 100755 --- a/packages/next/src/cli/next-telemetry.ts +++ b/packages/next/src/cli/next-telemetry.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node import { bold, cyan, green, red, yellow } from '../lib/picocolors' -import { CliCommand } from '../lib/commands' +import type { CliCommand } from '../lib/commands' import { Telemetry } from '../telemetry/storage' const nextTelemetry: CliCommand = (args) => { diff --git a/packages/next/src/client/compat/router.ts b/packages/next/src/client/compat/router.ts index e9143c4117bd7..ec5752e7627f9 100644 --- a/packages/next/src/client/compat/router.ts +++ b/packages/next/src/client/compat/router.ts @@ -1,6 +1,6 @@ import { useContext } from 'react' import { RouterContext } from '../../shared/lib/router-context.shared-runtime' -import { NextRouter } from '../router' +import type { NextRouter } from '../router' /** * useRouter from `next/compat/router` is designed to assist developers diff --git a/packages/next/src/client/components/app-router.tsx b/packages/next/src/client/components/app-router.tsx index 51c749f002b3a..5f2d106e67d1f 100644 --- a/packages/next/src/client/components/app-router.tsx +++ b/packages/next/src/client/components/app-router.tsx @@ -33,8 +33,10 @@ import { ACTION_RESTORE, ACTION_SERVER_ACTION, ACTION_SERVER_PATCH, - Mutable, PrefetchKind, +} from './router-reducer/router-reducer-types' +import type { + Mutable, ReducerActions, RouterChangeByServerResponse, RouterNavigate, @@ -47,10 +49,8 @@ import { } from '../../shared/lib/hooks-client-context.shared-runtime' import { useReducerWithReduxDevtools } from './use-reducer-with-devtools' import { ErrorBoundary } from './error-boundary' -import { - createInitialRouterState, - InitialRouterStateParameters, -} from './router-reducer/create-initial-router-state' +import { createInitialRouterState } from './router-reducer/create-initial-router-state' +import type { InitialRouterStateParameters } from './router-reducer/create-initial-router-state' import { isBot } from '../../shared/lib/router/utils/is-bot' import { addBasePath } from '../add-base-path' import { AppRouterAnnouncer } from './app-router-announcer' diff --git a/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx b/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx index d4a2da56d3acc..6c4240d780a91 100644 --- a/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx +++ b/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx @@ -1,4 +1,4 @@ -import { ReactNode } from 'react' +import type { ReactNode } from 'react' import React, { useCallback, useEffect, @@ -36,10 +36,8 @@ import { } from './internal/helpers/use-websocket' import { parseComponentStack } from './internal/helpers/parse-component-stack' import type { VersionInfo } from '../../../server/dev/parse-version-info' -import { - HMR_ACTIONS_SENT_TO_BROWSER, - HMR_ACTION_TYPES, -} from '../../../server/dev/hot-reloader-types' +import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../server/dev/hot-reloader-types' +import type { HMR_ACTION_TYPES } from '../../../server/dev/hot-reloader-types' interface Dispatcher { onBuildOk(): void diff --git a/packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx b/packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx index 715e3fd1b9571..7d3c49cd0b670 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx @@ -1,13 +1,14 @@ import * as React from 'react' -import { - ACTION_UNHANDLED_ERROR, +import { ACTION_UNHANDLED_ERROR } from './error-overlay-reducer' +import type { OverlayState, UnhandledErrorAction, } from './error-overlay-reducer' import { ShadowPortal } from './components/ShadowPortal' import { BuildError } from './container/BuildError' -import { Errors, SupportedErrorEvent } from './container/Errors' +import { Errors } from './container/Errors' +import type { SupportedErrorEvent } from './container/Errors' import { RootLayoutError } from './container/RootLayoutError' import { parseStack } from './helpers/parseStack' import { Base } from './styles/Base' diff --git a/packages/next/src/client/components/react-dev-overlay/internal/components/CodeFrame/CodeFrame.tsx b/packages/next/src/client/components/react-dev-overlay/internal/components/CodeFrame/CodeFrame.tsx index eb8b8172b2880..3f879291291bf 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/components/CodeFrame/CodeFrame.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/components/CodeFrame/CodeFrame.tsx @@ -1,6 +1,6 @@ import Anser from 'next/dist/compiled/anser' import * as React from 'react' -import { StackFrame } from 'next/dist/compiled/stacktrace-parser' +import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' import stripAnsi from 'next/dist/compiled/strip-ansi' import { getFrameSource } from '../../helpers/stack-frame' import { useOpenInEditor } from '../../helpers/use-open-in-editor' diff --git a/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx b/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx index ab6d9df6652e7..3a799356d28e1 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx @@ -2,6 +2,8 @@ import * as React from 'react' import { ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION, +} from '../error-overlay-reducer' +import type { UnhandledErrorAction, UnhandledRejectionAction, } from '../error-overlay-reducer' @@ -14,7 +16,8 @@ import { import { LeftRightDialogHeader } from '../components/LeftRightDialogHeader' import { Overlay } from '../components/Overlay' import { Toast } from '../components/Toast' -import { getErrorByType, ReadyRuntimeError } from '../helpers/getErrorByType' +import { getErrorByType } from '../helpers/getErrorByType' +import type { ReadyRuntimeError } from '../helpers/getErrorByType' import { getErrorSource } from '../helpers/nodeStackFrames' import { noop as css } from '../helpers/noop-template' import { CloseIcon } from '../icons/CloseIcon' diff --git a/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/index.tsx b/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/index.tsx index 6efe28bdffb90..bc348bbb4e7d4 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/index.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/index.tsx @@ -1,8 +1,8 @@ import * as React from 'react' import { CodeFrame } from '../../components/CodeFrame' -import { ReadyRuntimeError } from '../../helpers/getErrorByType' +import type { ReadyRuntimeError } from '../../helpers/getErrorByType' import { noop as css } from '../../helpers/noop-template' -import { OriginalStackFrame } from '../../helpers/stack-frame' +import type { OriginalStackFrame } from '../../helpers/stack-frame' import { groupStackFramesByFramework } from '../../helpers/group-stack-frames-by-framework' import { CallStackFrame } from './CallStackFrame' import { GroupedStackFrames } from './GroupedStackFrames' diff --git a/packages/next/src/client/components/react-dev-overlay/internal/error-overlay-reducer.ts b/packages/next/src/client/components/react-dev-overlay/internal/error-overlay-reducer.ts index 44cb2470db7a4..4536a263277e4 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/error-overlay-reducer.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/error-overlay-reducer.ts @@ -1,7 +1,7 @@ import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' import type { VersionInfo } from '../../../../server/dev/parse-version-info' import type { SupportedErrorEvent } from './container/Errors' -import { ComponentStackFrame } from './helpers/parse-component-stack' +import type { ComponentStackFrame } from './helpers/parse-component-stack' export const ACTION_BUILD_OK = 'build-ok' export const ACTION_BUILD_ERROR = 'build-error' diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts index 9819e90555692..cd0b866e31127 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts @@ -2,10 +2,11 @@ import { ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION, } from '../error-overlay-reducer' -import { SupportedErrorEvent } from '../container/Errors' +import type { SupportedErrorEvent } from '../container/Errors' import { getErrorSource } from './nodeStackFrames' -import { getOriginalStackFrames, OriginalStackFrame } from './stack-frame' -import { ComponentStackFrame } from './parse-component-stack' +import { getOriginalStackFrames } from './stack-frame' +import type { OriginalStackFrame } from './stack-frame' +import type { ComponentStackFrame } from './parse-component-stack' export type ReadyRuntimeError = { id: number diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/getRawSourceMap.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/getRawSourceMap.ts index 504fa2c93bf85..0670daa0a8610 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/getRawSourceMap.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/getRawSourceMap.ts @@ -1,6 +1,5 @@ -import dataUriToBuffer, { - MimeBuffer, -} from 'next/dist/compiled/data-uri-to-buffer' +import dataUriToBuffer from 'next/dist/compiled/data-uri-to-buffer' +import type { MimeBuffer } from 'next/dist/compiled/data-uri-to-buffer' import type { RawSourceMap } from 'source-map' import { getSourceMapUrl } from './getSourceMapUrl' diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/nodeStackFrames.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/nodeStackFrames.ts index cb3f9db12a072..d3691fe629654 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/nodeStackFrames.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/nodeStackFrames.ts @@ -1,4 +1,5 @@ -import { parse, StackFrame } from 'next/dist/compiled/stacktrace-parser' +import { parse } from 'next/dist/compiled/stacktrace-parser' +import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' export function getFilesystemFrame(frame: StackFrame): StackFrame { const f: StackFrame = { ...frame } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/parseStack.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/parseStack.ts index ed95a92a82182..fbd509339945c 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/parseStack.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/parseStack.ts @@ -1,4 +1,5 @@ -import { parse, StackFrame } from 'next/dist/compiled/stacktrace-parser' +import { parse } from 'next/dist/compiled/stacktrace-parser' +import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' const regexNextStatic = /\/_next(\/static\/.+)/g diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts index c02e961aeeca6..a213da0579787 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts @@ -1,4 +1,4 @@ -import { StackFrame } from 'next/dist/compiled/stacktrace-parser' +import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' // import type { OriginalStackFrameResponse } from '../../middleware' export type OriginalStackFrame = diff --git a/packages/next/src/client/components/redirect-boundary.tsx b/packages/next/src/client/components/redirect-boundary.tsx index 8d407fd6e9d6e..f0ee6fad318c4 100644 --- a/packages/next/src/client/components/redirect-boundary.tsx +++ b/packages/next/src/client/components/redirect-boundary.tsx @@ -1,6 +1,6 @@ 'use client' import React, { useEffect } from 'react' -import { AppRouterInstance } from '../../shared/lib/app-router-context.shared-runtime' +import type { AppRouterInstance } from '../../shared/lib/app-router-context.shared-runtime' import { useRouter } from './navigation' import { RedirectType, diff --git a/packages/next/src/client/components/router-reducer/apply-flight-data.ts b/packages/next/src/client/components/router-reducer/apply-flight-data.ts index 003d0a5cde9e4..f30a8df3bc8ba 100644 --- a/packages/next/src/client/components/router-reducer/apply-flight-data.ts +++ b/packages/next/src/client/components/router-reducer/apply-flight-data.ts @@ -1,8 +1,6 @@ -import { - CacheNode, - CacheStates, -} from '../../../shared/lib/app-router-context.shared-runtime' -import { FlightDataPath } from '../../../server/app-render/types' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' +import type { FlightDataPath } from '../../../server/app-render/types' import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head' import { fillCacheWithNewSubTreeData } from './fill-cache-with-new-subtree-data' diff --git a/packages/next/src/client/components/router-reducer/compute-changed-path.ts b/packages/next/src/client/components/router-reducer/compute-changed-path.ts index 3a80a5a051b8a..fc3c751595c26 100644 --- a/packages/next/src/client/components/router-reducer/compute-changed-path.ts +++ b/packages/next/src/client/components/router-reducer/compute-changed-path.ts @@ -1,4 +1,7 @@ -import { FlightRouterState, Segment } from '../../../server/app-render/types' +import type { + FlightRouterState, + Segment, +} from '../../../server/app-render/types' import { INTERCEPTION_ROUTE_MARKERS } from '../../../server/future/helpers/interception-routes' import { isGroupSegment } from '../../../shared/lib/segment' import { matchSegment } from '../match-segments' diff --git a/packages/next/src/client/components/router-reducer/create-initial-router-state.test.tsx b/packages/next/src/client/components/router-reducer/create-initial-router-state.test.tsx index 414b553c63249..036944640cadf 100644 --- a/packages/next/src/client/components/router-reducer/create-initial-router-state.test.tsx +++ b/packages/next/src/client/components/router-reducer/create-initial-router-state.test.tsx @@ -1,9 +1,7 @@ import React from 'react' import type { FlightRouterState } from '../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import { createInitialRouterState } from './create-initial-router-state' const buildId = 'development' diff --git a/packages/next/src/client/components/router-reducer/create-record-from-thenable.ts b/packages/next/src/client/components/router-reducer/create-record-from-thenable.ts index 2976bc8decf71..ae63ff16ef564 100644 --- a/packages/next/src/client/components/router-reducer/create-record-from-thenable.ts +++ b/packages/next/src/client/components/router-reducer/create-record-from-thenable.ts @@ -1,4 +1,4 @@ -import { ThenableRecord } from './router-reducer-types' +import type { ThenableRecord } from './router-reducer-types' /** * Create data fetching record for Promise. diff --git a/packages/next/src/client/components/router-reducer/create-router-cache-key.ts b/packages/next/src/client/components/router-reducer/create-router-cache-key.ts index 3e9d739a717d7..dcf334d06ef48 100644 --- a/packages/next/src/client/components/router-reducer/create-router-cache-key.ts +++ b/packages/next/src/client/components/router-reducer/create-router-cache-key.ts @@ -1,4 +1,4 @@ -import { Segment } from '../../../server/app-render/types' +import type { Segment } from '../../../server/app-render/types' export function createRouterCacheKey( segment: Segment, diff --git a/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.test.tsx b/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.test.tsx index f64fd86b2af90..5aacf327c2270 100644 --- a/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.test.tsx +++ b/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.test.tsx @@ -1,12 +1,10 @@ import React from 'react' import type { FetchServerResponseResult } from './fetch-server-response' import { fillCacheWithDataProperty } from './fill-cache-with-data-property' -import { - CacheStates, - CacheNode, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import { createRecordFromThenable } from './create-record-from-thenable' -import { ThenableRecord } from './router-reducer-types' +import type { ThenableRecord } from './router-reducer-types' describe('fillCacheWithDataProperty', () => { it('should add data property', () => { const fetchServerResponseMock: jest.Mock< diff --git a/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.ts b/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.ts index 274b9070f0c19..5584747ef06d6 100644 --- a/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.ts +++ b/packages/next/src/client/components/router-reducer/fill-cache-with-data-property.ts @@ -1,10 +1,8 @@ import type { FetchServerResponseResult } from './fetch-server-response' import type { ThenableRecord } from './router-reducer-types' -import { FlightSegmentPath } from '../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../shared/lib/app-router-context.shared-runtime' +import type { FlightSegmentPath } from '../../../server/app-render/types' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import { createRouterCacheKey } from './create-router-cache-key' /** diff --git a/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.test.tsx b/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.test.tsx index ac888a3ede0ff..d81ee63e12817 100644 --- a/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.test.tsx +++ b/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.test.tsx @@ -1,9 +1,7 @@ import React from 'react' import { fillCacheWithNewSubTreeData } from './fill-cache-with-new-subtree-data' -import { - CacheStates, - CacheNode, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import type { FlightData } from '../../../server/app-render/types' const getFlightData = (): FlightData => { diff --git a/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts b/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts index 7e9a93699fb65..694f24b0b0e93 100644 --- a/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts +++ b/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts @@ -1,7 +1,5 @@ -import { - CacheNode, - CacheStates, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import type { FlightDataPath } from '../../../server/app-render/types' import { invalidateCacheByRouterState } from './invalidate-cache-by-router-state' import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head' diff --git a/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.test.tsx b/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.test.tsx index 1edbeffd7b3e9..ba0d5fbc602b2 100644 --- a/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.test.tsx +++ b/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.test.tsx @@ -1,9 +1,7 @@ import React from 'react' import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head' -import { - CacheStates, - CacheNode, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import type { FlightData } from '../../../server/app-render/types' const getFlightData = (): FlightData => { diff --git a/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts b/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts index f558edfab2f1e..4292b7f4607a0 100644 --- a/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts +++ b/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts @@ -1,7 +1,5 @@ -import { - CacheNode, - CacheStates, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import type { FlightRouterState } from '../../../server/app-render/types' import { createRouterCacheKey } from './create-router-cache-key' diff --git a/packages/next/src/client/components/router-reducer/get-prefetch-cache-entry-status.ts b/packages/next/src/client/components/router-reducer/get-prefetch-cache-entry-status.ts index f2a6cedb134b0..efc899716b63a 100644 --- a/packages/next/src/client/components/router-reducer/get-prefetch-cache-entry-status.ts +++ b/packages/next/src/client/components/router-reducer/get-prefetch-cache-entry-status.ts @@ -1,4 +1,4 @@ -import { PrefetchCacheEntry } from './router-reducer-types' +import type { PrefetchCacheEntry } from './router-reducer-types' const FIVE_MINUTES = 5 * 60 * 1000 const THIRTY_SECONDS = 30 * 1000 diff --git a/packages/next/src/client/components/router-reducer/handle-mutable.ts b/packages/next/src/client/components/router-reducer/handle-mutable.ts index d5f48235bbde6..37b7f23066177 100644 --- a/packages/next/src/client/components/router-reducer/handle-mutable.ts +++ b/packages/next/src/client/components/router-reducer/handle-mutable.ts @@ -1,5 +1,5 @@ import { computeChangedPath } from './compute-changed-path' -import { +import type { Mutable, ReadonlyReducerState, ReducerState, diff --git a/packages/next/src/client/components/router-reducer/invalidate-cache-below-flight-segmentpath.test.tsx b/packages/next/src/client/components/router-reducer/invalidate-cache-below-flight-segmentpath.test.tsx index 8c23c47d42d74..9f062babb0f75 100644 --- a/packages/next/src/client/components/router-reducer/invalidate-cache-below-flight-segmentpath.test.tsx +++ b/packages/next/src/client/components/router-reducer/invalidate-cache-below-flight-segmentpath.test.tsx @@ -1,10 +1,8 @@ import React from 'react' import type { FlightData } from '../../../server/app-render/types' import { invalidateCacheBelowFlightSegmentPath } from './invalidate-cache-below-flight-segmentpath' -import { - CacheStates, - CacheNode, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import { fillCacheWithNewSubTreeData } from './fill-cache-with-new-subtree-data' const getFlightData = (): FlightData => { diff --git a/packages/next/src/client/components/router-reducer/invalidate-cache-by-router-state.test.tsx b/packages/next/src/client/components/router-reducer/invalidate-cache-by-router-state.test.tsx index bdd819b0614d9..c365d6ae9765e 100644 --- a/packages/next/src/client/components/router-reducer/invalidate-cache-by-router-state.test.tsx +++ b/packages/next/src/client/components/router-reducer/invalidate-cache-by-router-state.test.tsx @@ -1,9 +1,7 @@ import React from 'react' import { invalidateCacheByRouterState } from './invalidate-cache-by-router-state' -import { - CacheStates, - CacheNode, -} from '../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime' import type { FlightRouterState } from '../../../server/app-render/types' describe('invalidateCacheByRouterState', () => { diff --git a/packages/next/src/client/components/router-reducer/reducers/fast-refresh-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/fast-refresh-reducer.ts index dcf618118fb11..09acc94b4a9a8 100644 --- a/packages/next/src/client/components/router-reducer/reducers/fast-refresh-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/fast-refresh-reducer.ts @@ -4,7 +4,7 @@ import { readRecordValue } from '../read-record-value' import { createHrefFromUrl } from '../create-href-from-url' import { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree' import { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout' -import { +import type { ReadonlyReducerState, ReducerState, FastRefreshAction, diff --git a/packages/next/src/client/components/router-reducer/reducers/find-head-in-cache.test.tsx b/packages/next/src/client/components/router-reducer/reducers/find-head-in-cache.test.tsx index 2d4cdef348b1e..f3eaaad8a5c64 100644 --- a/packages/next/src/client/components/router-reducer/reducers/find-head-in-cache.test.tsx +++ b/packages/next/src/client/components/router-reducer/reducers/find-head-in-cache.test.tsx @@ -1,9 +1,7 @@ import React from 'react' import type { FlightRouterState } from '../../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' import { findHeadInCache } from './find-head-in-cache' describe('findHeadInCache', () => { diff --git a/packages/next/src/client/components/router-reducer/reducers/get-segment-value.ts b/packages/next/src/client/components/router-reducer/reducers/get-segment-value.ts index 52000f5578bda..2ec8269583afa 100644 --- a/packages/next/src/client/components/router-reducer/reducers/get-segment-value.ts +++ b/packages/next/src/client/components/router-reducer/reducers/get-segment-value.ts @@ -1,4 +1,4 @@ -import { Segment } from '../../../../server/app-render/types' +import type { Segment } from '../../../../server/app-render/types' export function getSegmentValue(segment: Segment) { return Array.isArray(segment) ? segment[1] : segment diff --git a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.test.tsx b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.test.tsx index fcde9b963e9fd..6b2e9f0d343db 100644 --- a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.test.tsx +++ b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.test.tsx @@ -1,6 +1,18 @@ import React from 'react' import type { fetchServerResponse as fetchServerResponseType } from '../fetch-server-response' import type { FlightData } from '../../../../server/app-render/types' +import type { FlightRouterState } from '../../../../server/app-render/types' +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' +import { createInitialRouterState } from '../create-initial-router-state' +import { + ACTION_NAVIGATE, + ACTION_PREFETCH, + PrefetchKind, +} from '../router-reducer-types' +import type { NavigateAction, PrefetchAction } from '../router-reducer-types' +import { navigateReducer } from './navigate-reducer' +import { prefetchReducer } from './prefetch-reducer' const buildId = 'development' @@ -75,22 +87,6 @@ jest.mock('../fetch-server-response', () => { } }) -import { FlightRouterState } from '../../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' -import { createInitialRouterState } from '../create-initial-router-state' -import { - NavigateAction, - ACTION_NAVIGATE, - ACTION_PREFETCH, - PrefetchAction, - PrefetchKind, -} from '../router-reducer-types' -import { navigateReducer } from './navigate-reducer' -import { prefetchReducer } from './prefetch-reducer' - const getInitialRouterStateTree = (): FlightRouterState => [ '', { diff --git a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts index 2436a15aca527..6ffefb5076d7c 100644 --- a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts @@ -1,15 +1,11 @@ -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' import type { FlightRouterState, FlightSegmentPath, } from '../../../../server/app-render/types' -import { - FetchServerResponseResult, - fetchServerResponse, -} from '../fetch-server-response' +import { fetchServerResponse } from '../fetch-server-response' +import type { FetchServerResponseResult } from '../fetch-server-response' import { createRecordFromThenable } from '../create-record-from-thenable' import { readRecordValue } from '../read-record-value' import { createHrefFromUrl } from '../create-href-from-url' @@ -19,14 +15,14 @@ import { createOptimisticTree } from '../create-optimistic-tree' import { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree' import { shouldHardNavigate } from '../should-hard-navigate' import { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout' -import { +import type { Mutable, NavigateAction, - PrefetchKind, ReadonlyReducerState, ReducerState, ThenableRecord, } from '../router-reducer-types' +import { PrefetchKind } from '../router-reducer-types' import { handleMutable } from '../handle-mutable' import { applyFlightData } from '../apply-flight-data' import { diff --git a/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.test.tsx b/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.test.tsx index bbbee6ff5f2a4..c5eca08342ead 100644 --- a/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.test.tsx +++ b/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.test.tsx @@ -1,6 +1,16 @@ import React from 'react' import type { fetchServerResponse as fetchServerResponseType } from '../fetch-server-response' import type { FlightData } from '../../../../server/app-render/types' +import type { FlightRouterState } from '../../../../server/app-render/types' +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' +import { createInitialRouterState } from '../create-initial-router-state' +import { ACTION_PREFETCH, PrefetchKind } from '../router-reducer-types' +import type { PrefetchAction } from '../router-reducer-types' +import { prefetchReducer } from './prefetch-reducer' +import { fetchServerResponse } from '../fetch-server-response' +import { createRecordFromThenable } from '../create-record-from-thenable' + jest.mock('../fetch-server-response', () => { const flightData: FlightData = [ [ @@ -32,20 +42,6 @@ jest.mock('../fetch-server-response', () => { }, } }) -import { FlightRouterState } from '../../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' -import { createInitialRouterState } from '../create-initial-router-state' -import { - PrefetchAction, - ACTION_PREFETCH, - PrefetchKind, -} from '../router-reducer-types' -import { prefetchReducer } from './prefetch-reducer' -import { fetchServerResponse } from '../fetch-server-response' -import { createRecordFromThenable } from '../create-record-from-thenable' const getInitialRouterStateTree = (): FlightRouterState => [ '', diff --git a/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.ts index 9344223de3c8d..9c9e87785b437 100644 --- a/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.ts @@ -1,11 +1,11 @@ import { createHrefFromUrl } from '../create-href-from-url' import { fetchServerResponse } from '../fetch-server-response' -import { +import type { PrefetchAction, ReducerState, ReadonlyReducerState, - PrefetchKind, } from '../router-reducer-types' +import { PrefetchKind } from '../router-reducer-types' import { createRecordFromThenable } from '../create-record-from-thenable' import { prunePrefetchCache } from './prune-prefetch-cache' import { NEXT_RSC_UNION_QUERY } from '../../app-router-headers' diff --git a/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.test.tsx b/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.test.tsx index bbf36b1ec538c..dec910480ee19 100644 --- a/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.test.tsx +++ b/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.test.tsx @@ -1,7 +1,13 @@ import React from 'react' import type { fetchServerResponse } from '../fetch-server-response' import type { FlightData } from '../../../../server/app-render/types' - +import type { FlightRouterState } from '../../../../server/app-render/types' +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' +import { createInitialRouterState } from '../create-initial-router-state' +import { ACTION_REFRESH } from '../router-reducer-types' +import type { RefreshAction } from '../router-reducer-types' +import { refreshReducer } from './refresh-reducer' const buildId = 'development' jest.mock('../fetch-server-response', () => { @@ -42,14 +48,6 @@ jest.mock('../fetch-server-response', () => { }, } }) -import { FlightRouterState } from '../../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' -import { createInitialRouterState } from '../create-initial-router-state' -import { RefreshAction, ACTION_REFRESH } from '../router-reducer-types' -import { refreshReducer } from './refresh-reducer' const getInitialRouterStateTree = (): FlightRouterState => [ '', diff --git a/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts index bd6dfc4ef9047..804f3d619427d 100644 --- a/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts @@ -4,7 +4,7 @@ import { readRecordValue } from '../read-record-value' import { createHrefFromUrl } from '../create-href-from-url' import { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree' import { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout' -import { +import type { ReadonlyReducerState, ReducerState, RefreshAction, diff --git a/packages/next/src/client/components/router-reducer/reducers/restore-reducer.test.tsx b/packages/next/src/client/components/router-reducer/reducers/restore-reducer.test.tsx index 36c978926517f..8cca3d7a9701c 100644 --- a/packages/next/src/client/components/router-reducer/reducers/restore-reducer.test.tsx +++ b/packages/next/src/client/components/router-reducer/reducers/restore-reducer.test.tsx @@ -1,11 +1,10 @@ import React from 'react' import type { FlightRouterState } from '../../../../server/app-render/types' -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' import { createInitialRouterState } from '../create-initial-router-state' -import { RestoreAction, ACTION_RESTORE } from '../router-reducer-types' +import { ACTION_RESTORE } from '../router-reducer-types' +import type { RestoreAction } from '../router-reducer-types' import { restoreReducer } from './restore-reducer' const buildId = 'development' diff --git a/packages/next/src/client/components/router-reducer/reducers/restore-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/restore-reducer.ts index 675ae5e64ef4a..9b0ff103c94a6 100644 --- a/packages/next/src/client/components/router-reducer/reducers/restore-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/restore-reducer.ts @@ -1,5 +1,5 @@ import { createHrefFromUrl } from '../create-href-from-url' -import { +import type { ReadonlyReducerState, ReducerState, RestoreAction, diff --git a/packages/next/src/client/components/router-reducer/reducers/server-action-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/server-action-reducer.ts index d8c67e507cc95..9ccaddafa066e 100644 --- a/packages/next/src/client/components/router-reducer/reducers/server-action-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/server-action-reducer.ts @@ -1,4 +1,4 @@ -import { +import type { ActionFlightResponse, ActionResult, FlightData, @@ -24,7 +24,7 @@ const { createFromFetch, encodeReply } = ( require('react-server-dom-webpack/client') ) as typeof import('react-server-dom-webpack/client') -import { +import type { ReadonlyReducerState, ReducerState, ServerActionAction, diff --git a/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.test.tsx b/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.test.tsx index 9e7035dc7e819..c1349a2740afc 100644 --- a/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.test.tsx +++ b/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.test.tsx @@ -4,7 +4,13 @@ import type { FlightData, FlightRouterState, } from '../../../../server/app-render/types' - +import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime' +import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime' +import { createInitialRouterState } from '../create-initial-router-state' +import { ACTION_SERVER_PATCH, ACTION_NAVIGATE } from '../router-reducer-types' +import type { ServerPatchAction, NavigateAction } from '../router-reducer-types' +import { navigateReducer } from './navigate-reducer' +import { serverPatchReducer } from './server-patch-reducer' const buildId = 'development' const globalMutable = { @@ -42,19 +48,6 @@ jest.mock('../fetch-server-response', () => { }, } }) -import { - CacheNode, - CacheStates, -} from '../../../../shared/lib/app-router-context.shared-runtime' -import { createInitialRouterState } from '../create-initial-router-state' -import { - ServerPatchAction, - ACTION_SERVER_PATCH, - NavigateAction, - ACTION_NAVIGATE, -} from '../router-reducer-types' -import { navigateReducer } from './navigate-reducer' -import { serverPatchReducer } from './server-patch-reducer' const flightDataForPatch: FlightData = [ [ diff --git a/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.ts index 980f3b39827f6..d0697ea16084c 100644 --- a/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.ts @@ -1,7 +1,7 @@ import { createHrefFromUrl } from '../create-href-from-url' import { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree' import { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout' -import { +import type { ServerPatchAction, ReducerState, ReadonlyReducerState, diff --git a/packages/next/src/client/components/router-reducer/router-reducer.ts b/packages/next/src/client/components/router-reducer/router-reducer.ts index d7832711aec20..ec48a3c9a8635 100644 --- a/packages/next/src/client/components/router-reducer/router-reducer.ts +++ b/packages/next/src/client/components/router-reducer/router-reducer.ts @@ -4,11 +4,13 @@ import { ACTION_RESTORE, ACTION_REFRESH, ACTION_PREFETCH, + ACTION_FAST_REFRESH, + ACTION_SERVER_ACTION, +} from './router-reducer-types' +import type { ReducerActions, ReducerState, ReadonlyReducerState, - ACTION_FAST_REFRESH, - ACTION_SERVER_ACTION, } from './router-reducer-types' import { navigateReducer } from './reducers/navigate-reducer' import { serverPatchReducer } from './reducers/server-patch-reducer' diff --git a/packages/next/src/client/dev/dev-build-watcher.ts b/packages/next/src/client/dev/dev-build-watcher.ts index ef9c008603c4a..231c3536cfbe9 100644 --- a/packages/next/src/client/dev/dev-build-watcher.ts +++ b/packages/next/src/client/dev/dev-build-watcher.ts @@ -1,8 +1,6 @@ /* eslint-disable @typescript-eslint/no-use-before-define */ -import { - HMR_ACTIONS_SENT_TO_BROWSER, - HMR_ACTION_TYPES, -} from '../../server/dev/hot-reloader-types' +import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../server/dev/hot-reloader-types' +import type { HMR_ACTION_TYPES } from '../../server/dev/hot-reloader-types' import { addMessageListener } from './error-overlay/websocket' type VerticalPosition = 'top' | 'bottom' diff --git a/packages/next/src/client/dev/error-overlay/hot-dev-client.ts b/packages/next/src/client/dev/error-overlay/hot-dev-client.ts index 04992a011bb54..5fb470ea358e0 100644 --- a/packages/next/src/client/dev/error-overlay/hot-dev-client.ts +++ b/packages/next/src/client/dev/error-overlay/hot-dev-client.ts @@ -38,11 +38,8 @@ import { import stripAnsi from 'next/dist/compiled/strip-ansi' import { addMessageListener, sendMessage } from './websocket' import formatWebpackMessages from './format-webpack-messages' -import { - HMR_ACTIONS_SENT_TO_BROWSER, - HMR_ACTION_TYPES, -} from '../../../server/dev/hot-reloader-types' - +import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../server/dev/hot-reloader-types' +import type { HMR_ACTION_TYPES } from '../../../server/dev/hot-reloader-types' // This alternative WebpackDevServer combines the functionality of: // https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js // https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js diff --git a/packages/next/src/client/dev/error-overlay/websocket.ts b/packages/next/src/client/dev/error-overlay/websocket.ts index 7273c9482f111..5a90b045d186c 100644 --- a/packages/next/src/client/dev/error-overlay/websocket.ts +++ b/packages/next/src/client/dev/error-overlay/websocket.ts @@ -1,4 +1,4 @@ -import { HMR_ACTION_TYPES } from '../../../server/dev/hot-reloader-types' +import type { HMR_ACTION_TYPES } from '../../../server/dev/hot-reloader-types' let source: WebSocket diff --git a/packages/next/src/client/index.tsx b/packages/next/src/client/index.tsx index 0bce4c663e899..f8904d1308977 100644 --- a/packages/next/src/client/index.tsx +++ b/packages/next/src/client/index.tsx @@ -11,7 +11,8 @@ import type { import React from 'react' import ReactDOM from 'react-dom/client' import { HeadManagerContext } from '../shared/lib/head-manager-context.shared-runtime' -import mitt, { MittEmitter } from '../shared/lib/mitt' +import mitt from '../shared/lib/mitt' +import type { MittEmitter } from '../shared/lib/mitt' import { RouterContext } from '../shared/lib/router-context.shared-runtime' import { handleSmoothScroll } from '../shared/lib/router/utils/handle-smooth-scroll' import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic' @@ -20,22 +21,18 @@ import { assign, } from '../shared/lib/router/utils/querystring' import { setConfig } from '../shared/lib/runtime-config.external' -import { - getURL, - loadGetInitialProps, - NextWebVitalsMetric, - NEXT_DATA, - ST, -} from '../shared/lib/utils' +import { getURL, loadGetInitialProps, ST } from '../shared/lib/utils' +import type { NextWebVitalsMetric, NEXT_DATA } from '../shared/lib/utils' import { Portal } from './portal' import initHeadManager from './head-manager' -import PageLoader, { StyleSheetTuple } from './page-loader' +import PageLoader from './page-loader' +import type { StyleSheetTuple } from './page-loader' import measureWebVitals from './performance-relayer' import { RouteAnnouncer } from './route-announcer' import { createRouter, makePublicRouterInstance } from './router' import { getProperError } from '../lib/is-error' import { ImageConfigContext } from '../shared/lib/image-config-context.shared-runtime' -import { ImageConfigComplete } from '../shared/lib/image-config' +import type { ImageConfigComplete } from '../shared/lib/image-config' import { removeBasePath } from './remove-base-path' import { hasBasePath } from './has-base-path' import { AppRouterContext } from '../shared/lib/app-router-context.shared-runtime' diff --git a/packages/next/src/client/legacy/image.tsx b/packages/next/src/client/legacy/image.tsx index 0ef397d4320df..d982e9fa8a330 100644 --- a/packages/next/src/client/legacy/image.tsx +++ b/packages/next/src/client/legacy/image.tsx @@ -10,11 +10,13 @@ import React, { } from 'react' import Head from '../../shared/lib/head' import { - ImageConfigComplete, imageConfigDefault, - LoaderValue, VALID_LOADERS, } from '../../shared/lib/image-config' +import type { + ImageConfigComplete, + LoaderValue, +} from '../../shared/lib/image-config' import { useIntersection } from '../use-intersection' import { ImageConfigContext } from '../../shared/lib/image-config-context.shared-runtime' import { warnOnce } from '../../shared/lib/utils/warn-once' diff --git a/packages/next/src/client/link.tsx b/packages/next/src/client/link.tsx index 7a15dee249e26..92d6646f0ebac 100644 --- a/packages/next/src/client/link.tsx +++ b/packages/next/src/client/link.tsx @@ -6,15 +6,15 @@ import type { } from '../shared/lib/router/router' import React from 'react' -import { UrlObject } from 'url' +import type { UrlObject } from 'url' import { resolveHref } from './resolve-href' import { isLocalURL } from '../shared/lib/router/utils/is-local-url' import { formatUrl } from '../shared/lib/router/utils/format-url' import { isAbsoluteUrl } from '../shared/lib/utils' import { addLocale } from './add-locale' import { RouterContext } from '../shared/lib/router-context.shared-runtime' -import { - AppRouterContext, +import { AppRouterContext } from '../shared/lib/app-router-context.shared-runtime' +import type { AppRouterInstance, PrefetchOptions as AppRouterPrefetchOptions, } from '../shared/lib/app-router-context.shared-runtime' diff --git a/packages/next/src/client/next-dev-turbopack.ts b/packages/next/src/client/next-dev-turbopack.ts index 3381761de0b1b..54778e0c38277 100644 --- a/packages/next/src/client/next-dev-turbopack.ts +++ b/packages/next/src/client/next-dev-turbopack.ts @@ -7,7 +7,7 @@ import { pageBootrap } from './page-bootstrap' import { addMessageListener, sendMessage } from './dev/error-overlay/websocket' //@ts-expect-error requires "moduleResolution": "node16" in tsconfig.json and not .ts extension import { connect } from '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client.ts' -import { HMR_ACTION_TYPES } from '../server/dev/hot-reloader-types' +import type { HMR_ACTION_TYPES } from '../server/dev/hot-reloader-types' window.next = { version: `${version}-turbo`, diff --git a/packages/next/src/client/page-bootstrap.ts b/packages/next/src/client/page-bootstrap.ts index 1d57584ae5d75..a998607b3ac57 100644 --- a/packages/next/src/client/page-bootstrap.ts +++ b/packages/next/src/client/page-bootstrap.ts @@ -1,8 +1,7 @@ import { hydrate, router } from './' import initOnDemandEntries from './dev/on-demand-entries-client' -import initializeBuildWatcher, { - ShowHideHandler, -} from './dev/dev-build-watcher' +import initializeBuildWatcher from './dev/dev-build-watcher' +import type { ShowHideHandler } from './dev/dev-build-watcher' import { displayContent } from './dev/fouc' import { connectHMR, addMessageListener } from './dev/error-overlay/websocket' import { diff --git a/packages/next/src/client/script.tsx b/packages/next/src/client/script.tsx index f695e691c482d..9fe128aba41e1 100644 --- a/packages/next/src/client/script.tsx +++ b/packages/next/src/client/script.tsx @@ -2,7 +2,7 @@ import ReactDOM from 'react-dom' import React, { useEffect, useContext, useRef } from 'react' -import { ScriptHTMLAttributes } from 'react' +import type { ScriptHTMLAttributes } from 'react' import { HeadManagerContext } from '../shared/lib/head-manager-context.shared-runtime' import { DOMAttributeNames } from './head-manager' import { requestIdleCallback } from './request-idle-callback' diff --git a/packages/next/src/client/tracing/report-to-socket.ts b/packages/next/src/client/tracing/report-to-socket.ts index 74c87703e9997..493bd3aa98831 100644 --- a/packages/next/src/client/tracing/report-to-socket.ts +++ b/packages/next/src/client/tracing/report-to-socket.ts @@ -1,5 +1,5 @@ import { sendMessage } from '../dev/error-overlay/websocket' -import { Span } from './tracer' +import type { Span } from './tracer' export default function reportToSocket(span: Span) { if (span.state.state !== 'ended') { diff --git a/packages/next/src/client/tracing/tracer.ts b/packages/next/src/client/tracing/tracer.ts index f93b5f7219c7a..8694615980caa 100644 --- a/packages/next/src/client/tracing/tracer.ts +++ b/packages/next/src/client/tracing/tracer.ts @@ -1,4 +1,5 @@ -import mitt, { MittEmitter } from '../../shared/lib/mitt' +import mitt from '../../shared/lib/mitt' +import type { MittEmitter } from '../../shared/lib/mitt' export type SpanOptions = { startTime?: number @@ -73,5 +74,5 @@ class Tracer { } } -export { ISpan as Span } +export type { ISpan as Span } export default new Tracer() diff --git a/packages/next/src/client/web-vitals.ts b/packages/next/src/client/web-vitals.ts index 4194cf90f5666..36c532553bcf2 100644 --- a/packages/next/src/client/web-vitals.ts +++ b/packages/next/src/client/web-vitals.ts @@ -6,8 +6,8 @@ import { onINP, onFCP, onTTFB, - Metric, } from 'next/dist/compiled/web-vitals' +import type { Metric } from 'next/dist/compiled/web-vitals' export function useReportWebVitals( reportWebVitalsFn: (metric: Metric) => void diff --git a/packages/next/src/experimental/testmode/playwright/page-route.ts b/packages/next/src/experimental/testmode/playwright/page-route.ts index 1bd083d03fdbe..9c8bafac21e1f 100644 --- a/packages/next/src/experimental/testmode/playwright/page-route.ts +++ b/packages/next/src/experimental/testmode/playwright/page-route.ts @@ -1,9 +1,13 @@ -import type { Page, Route, Request } from '@playwright/test' +import type { + Page, + Route, + Request as PlaywrightRequest, +} from '@playwright/test' import type { FetchHandler } from './next-worker-fixture' function continueRoute( route: Route, - request: Request, + request: PlaywrightRequest, testHeaders: Record ): Promise { return route.continue({ diff --git a/packages/next/src/export/index.ts b/packages/next/src/export/index.ts index b57f8500b0d7f..650c8437e667b 100644 --- a/packages/next/src/export/index.ts +++ b/packages/next/src/export/index.ts @@ -15,7 +15,8 @@ import '../server/require-hook' import { Worker } from '../lib/worker' import { dirname, join, resolve, sep } from 'path' -import { AmpPageStatus, formatAmpMessages } from '../build/output/index' +import { formatAmpMessages } from '../build/output/index' +import type { AmpPageStatus } from '../build/output/index' import * as Log from '../build/output/log' import createSpinner from '../build/spinner' import { SSG_FALLBACK_EXPORT_ERROR } from '../lib/constants' @@ -36,7 +37,7 @@ import { APP_PATH_ROUTES_MANIFEST, } from '../shared/lib/constants' import loadConfig from '../server/config' -import { ExportPathMap, NextConfigComplete } from '../server/config-shared' +import type { ExportPathMap, NextConfigComplete } from '../server/config-shared' import { eventCliSession } from '../telemetry/events' import { hasNextSupport } from '../telemetry/ci-info' import { Telemetry } from '../telemetry/storage' @@ -45,9 +46,9 @@ import { denormalizePagePath } from '../shared/lib/page-path/denormalize-page-pa import { loadEnvConfig } from '@next/env' import { isAPIRoute } from '../lib/is-api-route' import { getPagePath } from '../server/require' -import { Span } from '../trace' -import { FontConfig } from '../server/font-utils' -import { MiddlewareManifest } from '../build/webpack/plugins/middleware-plugin' +import type { Span } from '../trace' +import type { FontConfig } from '../server/font-utils' +import type { MiddlewareManifest } from '../build/webpack/plugins/middleware-plugin' import { isAppRouteRoute } from '../lib/is-app-route-route' import { isAppPageRoute } from '../lib/is-app-page-route' import isError from '../lib/is-error' diff --git a/packages/next/src/export/routes/app-page.ts b/packages/next/src/export/routes/app-page.ts index 71a4a9afc60ff..b94b8fd26e417 100644 --- a/packages/next/src/export/routes/app-page.ts +++ b/packages/next/src/export/routes/app-page.ts @@ -3,7 +3,10 @@ import type { RenderOpts } from '../../server/app-render/types' import type { OutgoingHttpHeaders } from 'http' import type { NextParsedUrlQuery } from '../../server/request-meta' -import { MockedRequest, MockedResponse } from '../../server/lib/mock-request' +import type { + MockedRequest, + MockedResponse, +} from '../../server/lib/mock-request' import { RSC, NEXT_URL, diff --git a/packages/next/src/export/routes/app-route.ts b/packages/next/src/export/routes/app-route.ts index 0cfb77748d4e4..c580cea6ce8e1 100644 --- a/packages/next/src/export/routes/app-route.ts +++ b/packages/next/src/export/routes/app-route.ts @@ -12,7 +12,10 @@ import { signalFromNodeResponse, } from '../../server/web/spec-extension/adapters/next-request' import { toNodeOutgoingHttpHeaders } from '../../server/web/utils' -import { MockedRequest, MockedResponse } from '../../server/lib/mock-request' +import type { + MockedRequest, + MockedResponse, +} from '../../server/lib/mock-request' import { isDynamicUsageError } from '../helpers/is-dynamic-usage-error' import { SERVER_DIRECTORY } from '../../shared/lib/constants' import { hasNextSupport } from '../../telemetry/ci-info' diff --git a/packages/next/src/export/routes/pages.ts b/packages/next/src/export/routes/pages.ts index 6c056de3a3547..31b1db6a3e401 100644 --- a/packages/next/src/export/routes/pages.ts +++ b/packages/next/src/export/routes/pages.ts @@ -6,7 +6,10 @@ import type { NextParsedUrlQuery } from '../../server/request-meta' import RenderResult from '../../server/render-result' import { join } from 'path' -import { MockedRequest, MockedResponse } from '../../server/lib/mock-request' +import type { + MockedRequest, + MockedResponse, +} from '../../server/lib/mock-request' import { isInAmpMode } from '../../shared/lib/amp-mode' import { SERVER_PROPS_EXPORT_ERROR } from '../../lib/constants' import { NEXT_DYNAMIC_NO_SSR_CODE } from '../../shared/lib/lazy-dynamic/no-ssr-error' diff --git a/packages/next/src/lib/batcher.ts b/packages/next/src/lib/batcher.ts index 480b70df15f00..66a69be757c4a 100644 --- a/packages/next/src/lib/batcher.ts +++ b/packages/next/src/lib/batcher.ts @@ -2,7 +2,7 @@ // this imported module. import './polyfill-promise-with-resolvers' -import { SchedulerFn } from '../server/lib/schedule-on-next-tick' +import type { SchedulerFn } from '../server/lib/schedule-on-next-tick' type CacheKeyFn = ( key: K diff --git a/packages/next/src/lib/command-args.ts b/packages/next/src/lib/command-args.ts index 00d1e4164e020..6e132025854a3 100644 --- a/packages/next/src/lib/command-args.ts +++ b/packages/next/src/lib/command-args.ts @@ -1,4 +1,4 @@ -import { getValidatedArgs } from './get-validated-args' +import type { getValidatedArgs } from './get-validated-args' export type CliCommand = (args: ReturnType) => void diff --git a/packages/next/src/lib/commands.ts b/packages/next/src/lib/commands.ts index d921a8583cb56..d3f9b292da6ba 100644 --- a/packages/next/src/lib/commands.ts +++ b/packages/next/src/lib/commands.ts @@ -1,4 +1,4 @@ -import { getValidatedArgs } from './get-validated-args' +import type { getValidatedArgs } from './get-validated-args' export type CliCommand = (args: ReturnType) => void diff --git a/packages/next/src/lib/create-client-router-filter.ts b/packages/next/src/lib/create-client-router-filter.ts index dcf0a6a0bd43c..c4a7d08dd7a12 100644 --- a/packages/next/src/lib/create-client-router-filter.ts +++ b/packages/next/src/lib/create-client-router-filter.ts @@ -1,8 +1,8 @@ -import { Token } from 'next/dist/compiled/path-to-regexp' +import type { Token } from 'next/dist/compiled/path-to-regexp' import { BloomFilter } from '../shared/lib/bloom-filter' import { isDynamicRoute } from '../shared/lib/router/utils' import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-slash' -import { Redirect } from './load-custom-routes' +import type { Redirect } from './load-custom-routes' import { tryToParsePath } from './try-to-parse-path' export function createClientRouterFilter( diff --git a/packages/next/src/lib/eslint/runLintCheck.ts b/packages/next/src/lib/eslint/runLintCheck.ts index 6482f7b10e36a..525dbb24f2893 100644 --- a/packages/next/src/lib/eslint/runLintCheck.ts +++ b/packages/next/src/lib/eslint/runLintCheck.ts @@ -6,7 +6,8 @@ import findUp from 'next/dist/compiled/find-up' import semver from 'next/dist/compiled/semver' import * as CommentJson from 'next/dist/compiled/comment-json' -import { LintResult, formatResults } from './customFormatter' +import { formatResults } from './customFormatter' +import type { LintResult } from './customFormatter' import { writeDefaultConfig } from './writeDefaultConfig' import { hasEslintConfiguration } from './hasEslintConfiguration' import { writeOutputFile } from './writeOutputFile' @@ -17,7 +18,7 @@ import { installDependencies } from '../install-dependencies' import { hasNecessaryDependencies } from '../has-necessary-dependencies' import * as Log from '../../build/output/log' -import { EventLintCheckCompleted } from '../../telemetry/events/build' +import type { EventLintCheckCompleted } from '../../telemetry/events/build' import isError, { getProperError } from '../is-error' import { getPkgManager } from '../helpers/get-pkg-manager' diff --git a/packages/next/src/lib/eslint/writeDefaultConfig.ts b/packages/next/src/lib/eslint/writeDefaultConfig.ts index 53acf19407878..f897ece5d4bb9 100644 --- a/packages/next/src/lib/eslint/writeDefaultConfig.ts +++ b/packages/next/src/lib/eslint/writeDefaultConfig.ts @@ -3,7 +3,7 @@ import { bold, green } from '../picocolors' import os from 'os' import path from 'path' import * as CommentJson from 'next/dist/compiled/comment-json' -import { ConfigAvailable } from './hasEslintConfiguration' +import type { ConfigAvailable } from './hasEslintConfiguration' import * as Log from '../../build/output/log' diff --git a/packages/next/src/lib/generate-interception-routes-rewrites.ts b/packages/next/src/lib/generate-interception-routes-rewrites.ts index c2f96563c6132..85fed64167498 100644 --- a/packages/next/src/lib/generate-interception-routes-rewrites.ts +++ b/packages/next/src/lib/generate-interception-routes-rewrites.ts @@ -5,7 +5,7 @@ import { extractInterceptionRouteInformation, isInterceptionRouteAppPath, } from '../server/future/helpers/interception-routes' -import { Rewrite } from './load-custom-routes' +import type { Rewrite } from './load-custom-routes' // a function that converts normalised paths (e.g. /foo/[bar]/[baz]) to the format expected by pathToRegexp (e.g. /foo/:bar/:baz) function toPathToRegexpPath(path: string): string { diff --git a/packages/next/src/lib/install-dependencies.ts b/packages/next/src/lib/install-dependencies.ts index c1b125bc292a5..ef51f6e048321 100644 --- a/packages/next/src/lib/install-dependencies.ts +++ b/packages/next/src/lib/install-dependencies.ts @@ -1,7 +1,7 @@ import { cyan } from './picocolors' import path from 'path' -import { MissingDependency } from './has-necessary-dependencies' +import type { MissingDependency } from './has-necessary-dependencies' import { getPkgManager } from './helpers/get-pkg-manager' import { install } from './helpers/install' import { getOnline } from './helpers/get-online' diff --git a/packages/next/src/lib/is-edge-runtime.ts b/packages/next/src/lib/is-edge-runtime.ts index 0908e9e7613c4..486f73006d2f5 100644 --- a/packages/next/src/lib/is-edge-runtime.ts +++ b/packages/next/src/lib/is-edge-runtime.ts @@ -1,4 +1,4 @@ -import { ServerRuntime } from '../../types' +import type { ServerRuntime } from '../../types' import { SERVER_RUNTIME } from './constants' export function isEdgeRuntime(value?: string): value is ServerRuntime { diff --git a/packages/next/src/lib/metadata/generate/alternate.tsx b/packages/next/src/lib/metadata/generate/alternate.tsx index 6788d3fbc24aa..8ccc816ba509d 100644 --- a/packages/next/src/lib/metadata/generate/alternate.tsx +++ b/packages/next/src/lib/metadata/generate/alternate.tsx @@ -1,7 +1,7 @@ import type { ResolvedMetadata } from '../types/metadata-interface' import React from 'react' -import { AlternateLinkDescriptor } from '../types/alternative-urls-types' +import type { AlternateLinkDescriptor } from '../types/alternative-urls-types' import { MetaFilter } from './meta' function AlternateLink({ diff --git a/packages/next/src/lib/metadata/metadata.tsx b/packages/next/src/lib/metadata/metadata.tsx index e32ed342dfae3..1f2f7ab7efdea 100644 --- a/packages/next/src/lib/metadata/metadata.tsx +++ b/packages/next/src/lib/metadata/metadata.tsx @@ -18,7 +18,7 @@ import { import { IconsMetadata } from './generate/icons' import { resolveMetadata } from './resolve-metadata' import { MetaFilter } from './generate/meta' -import { ResolvedMetadata } from './types/metadata-interface' +import type { ResolvedMetadata } from './types/metadata-interface' import { createDefaultMetadata } from './default-metadata' import { isNotFoundError } from '../../client/components/not-found' diff --git a/packages/next/src/lib/metadata/resolve-metadata.test.ts b/packages/next/src/lib/metadata/resolve-metadata.test.ts index fff221ac1c872..20feb3ca32d5f 100644 --- a/packages/next/src/lib/metadata/resolve-metadata.test.ts +++ b/packages/next/src/lib/metadata/resolve-metadata.test.ts @@ -1,8 +1,6 @@ -import { - accumulateMetadata as originAccumulateMetadata, - MetadataItems, -} from './resolve-metadata' -import { Metadata } from './types/metadata-interface' +import { accumulateMetadata as originAccumulateMetadata } from './resolve-metadata' +import type { MetadataItems } from './resolve-metadata' +import type { Metadata } from './types/metadata-interface' function accumulateMetadata(metadataItems: MetadataItems) { return originAccumulateMetadata(metadataItems, { diff --git a/packages/next/src/lib/metadata/resolve-metadata.ts b/packages/next/src/lib/metadata/resolve-metadata.ts index 0ec2630dfdee0..e7eed1efa65f7 100644 --- a/packages/next/src/lib/metadata/resolve-metadata.ts +++ b/packages/next/src/lib/metadata/resolve-metadata.ts @@ -9,6 +9,7 @@ import type { Twitter } from './types/twitter-types' import type { OpenGraph } from './types/opengraph-types' import type { ComponentsType } from '../../build/webpack/loaders/next-app-loader' import type { MetadataContext } from './types/resolvers' +import type { LoaderTree } from '../../server/lib/app-dir-module' import { createDefaultMetadata } from './default-metadata' import { resolveOpenGraph, resolveTwitter } from './resolvers/resolve-opengraph' import { resolveTitle } from './resolvers/resolve-title' @@ -17,7 +18,6 @@ import { isClientReference } from '../client-reference' import { getComponentTypeModule, getLayoutOrPageModule, - LoaderTree, } from '../../server/lib/app-dir-module' import { interopDefault } from '../interop-default' import { diff --git a/packages/next/src/lib/metadata/types/metadata-interface.ts b/packages/next/src/lib/metadata/types/metadata-interface.ts index a29c6f47534ea..29450d21c9e42 100644 --- a/packages/next/src/lib/metadata/types/metadata-interface.ts +++ b/packages/next/src/lib/metadata/types/metadata-interface.ts @@ -577,4 +577,4 @@ declare namespace MetadataRoute { export type Manifest = ManifestFile } -export { Metadata, ResolvedMetadata, ResolvingMetadata, MetadataRoute } +export type { Metadata, ResolvedMetadata, ResolvingMetadata, MetadataRoute } diff --git a/packages/next/src/lib/metadata/types/resolvers.ts b/packages/next/src/lib/metadata/types/resolvers.ts index f7feab5115863..994917b068f16 100644 --- a/packages/next/src/lib/metadata/types/resolvers.ts +++ b/packages/next/src/lib/metadata/types/resolvers.ts @@ -1,4 +1,4 @@ -import { Metadata, ResolvedMetadata } from './metadata-interface' +import type { Metadata, ResolvedMetadata } from './metadata-interface' export type FieldResolver = ( T: Metadata[Key] diff --git a/packages/next/src/lib/recursive-copy.ts b/packages/next/src/lib/recursive-copy.ts index df9d163de5d11..68936115c4cd9 100644 --- a/packages/next/src/lib/recursive-copy.ts +++ b/packages/next/src/lib/recursive-copy.ts @@ -1,5 +1,6 @@ import path from 'path' -import { promises, constants, Dirent, Stats } from 'fs' +import type { Dirent, Stats } from 'fs' +import { promises, constants } from 'fs' import { Sema } from 'next/dist/compiled/async-sema' import isError from './is-error' diff --git a/packages/next/src/lib/recursive-delete.ts b/packages/next/src/lib/recursive-delete.ts index 78f3ea4948fc7..9675eee728509 100644 --- a/packages/next/src/lib/recursive-delete.ts +++ b/packages/next/src/lib/recursive-delete.ts @@ -1,4 +1,5 @@ -import { Dirent, promises } from 'fs' +import type { Dirent } from 'fs' +import { promises } from 'fs' import { join, isAbsolute, dirname } from 'path' import isError from './is-error' diff --git a/packages/next/src/lib/turbopack-warning.ts b/packages/next/src/lib/turbopack-warning.ts index 3d0951abab6c3..e55b259dee029 100644 --- a/packages/next/src/lib/turbopack-warning.ts +++ b/packages/next/src/lib/turbopack-warning.ts @@ -1,6 +1,6 @@ import path from 'path' import loadConfig from '../server/config' -import { NextConfig } from '../server/config-shared' +import type { NextConfig } from '../server/config-shared' import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' const supportedTurbopackNextConfigOptions = [ diff --git a/packages/next/src/lib/typescript/missingDependencyError.ts b/packages/next/src/lib/typescript/missingDependencyError.ts index 8cba0a6e7a0d6..d63aedfc7aad8 100644 --- a/packages/next/src/lib/typescript/missingDependencyError.ts +++ b/packages/next/src/lib/typescript/missingDependencyError.ts @@ -1,7 +1,7 @@ import { bold, cyan, red } from '../picocolors' import { getOxfordCommaList } from '../oxford-comma-list' -import { MissingDependency } from '../has-necessary-dependencies' +import type { MissingDependency } from '../has-necessary-dependencies' import { FatalError } from '../fatal-error' import { getPkgManager } from '../helpers/get-pkg-manager' diff --git a/packages/next/src/lib/verify-partytown-setup.ts b/packages/next/src/lib/verify-partytown-setup.ts index 0844ec373117e..fb2e439337d7d 100644 --- a/packages/next/src/lib/verify-partytown-setup.ts +++ b/packages/next/src/lib/verify-partytown-setup.ts @@ -2,10 +2,8 @@ import { promises } from 'fs' import { bold, cyan, red } from './picocolors' import path from 'path' -import { - hasNecessaryDependencies, - NecessaryDependencies, -} from './has-necessary-dependencies' +import { hasNecessaryDependencies } from './has-necessary-dependencies' +import type { NecessaryDependencies } from './has-necessary-dependencies' import { fileExists, FileType } from './file-exists' import { FatalError } from './fatal-error' import * as Log from '../build/output/log' diff --git a/packages/next/src/lib/verifyTypeScriptSetup.ts b/packages/next/src/lib/verify-typescript-setup.ts similarity index 96% rename from packages/next/src/lib/verifyTypeScriptSetup.ts rename to packages/next/src/lib/verify-typescript-setup.ts index f6f18ebf3eb31..b84b745531965 100644 --- a/packages/next/src/lib/verifyTypeScriptSetup.ts +++ b/packages/next/src/lib/verify-typescript-setup.ts @@ -1,16 +1,14 @@ import { bold, cyan, red, yellow } from './picocolors' import path from 'path' -import { - hasNecessaryDependencies, - NecessaryDependencies, -} from './has-necessary-dependencies' +import { hasNecessaryDependencies } from './has-necessary-dependencies' +import type { NecessaryDependencies } from './has-necessary-dependencies' import semver from 'next/dist/compiled/semver' import { CompileError } from './compile-error' import * as log from '../build/output/log' import { getTypeScriptIntent } from './typescript/getTypeScriptIntent' -import { TypeCheckResult } from './typescript/runTypeCheck' +import type { TypeCheckResult } from './typescript/runTypeCheck' import { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations' import { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults' import { installDependencies } from './install-dependencies' diff --git a/packages/next/src/lib/verifyAndLint.ts b/packages/next/src/lib/verifyAndLint.ts index 6dfbc59fa2b79..ff3e308623203 100644 --- a/packages/next/src/lib/verifyAndLint.ts +++ b/packages/next/src/lib/verifyAndLint.ts @@ -3,7 +3,7 @@ import { Worker } from 'next/dist/compiled/jest-worker' import { existsSync } from 'fs' import { join } from 'path' import { ESLINT_DEFAULT_DIRS } from './constants' -import { Telemetry } from '../telemetry/storage' +import type { Telemetry } from '../telemetry/storage' import { eventLintCheckCompleted } from '../telemetry/events' import { CompileError } from './compile-error' import isError from './is-error' diff --git a/packages/next/src/lib/worker.ts b/packages/next/src/lib/worker.ts index 05f1bf4ccf2cd..67e2c94dc4c09 100644 --- a/packages/next/src/lib/worker.ts +++ b/packages/next/src/lib/worker.ts @@ -1,4 +1,4 @@ -import { ChildProcess } from 'child_process' +import type { ChildProcess } from 'child_process' import { Worker as JestWorker } from 'next/dist/compiled/jest-worker' import { getNodeOptionsWithoutInspect } from '../server/lib/utils' diff --git a/packages/next/src/pages/_app.tsx b/packages/next/src/pages/_app.tsx index 2a064dd1c927a..7573e00cdd239 100644 --- a/packages/next/src/pages/_app.tsx +++ b/packages/next/src/pages/_app.tsx @@ -11,9 +11,9 @@ import type { Router } from '../client/router' import { loadGetInitialProps } from '../shared/lib/utils' -export { AppInitialProps, AppType } +export type { AppInitialProps, AppType } -export { NextWebVitalsMetric } +export type { NextWebVitalsMetric } export type AppContext = AppContextType diff --git a/packages/next/src/pages/_document.tsx b/packages/next/src/pages/_document.tsx index f0a29cb15d1fc..78ea281d96b17 100644 --- a/packages/next/src/pages/_document.tsx +++ b/packages/next/src/pages/_document.tsx @@ -1,4 +1,5 @@ -import React, { ReactElement, ReactNode } from 'react' +import React from 'react' +import type { ReactElement, ReactNode } from 'react' import { OPTIMIZED_FONT_PROVIDERS, NEXT_BUILTIN_DOCUMENT, @@ -13,7 +14,8 @@ import type { import type { ScriptProps } from '../client/script' import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin' -import { BuildManifest, getPageFiles } from '../server/get-page-files' +import { getPageFiles } from '../server/get-page-files' +import type { BuildManifest } from '../server/get-page-files' import { htmlEscapeJsonString } from '../server/htmlescape' import isError from '../lib/is-error' @@ -23,7 +25,7 @@ import { } from '../shared/lib/html-context.shared-runtime' import type { HtmlProps } from '../shared/lib/html-context.shared-runtime' -export { DocumentContext, DocumentInitialProps, DocumentProps } +export type { DocumentContext, DocumentInitialProps, DocumentProps } export type OriginProps = { nonce?: string diff --git a/packages/next/src/server/api-utils/node/api-resolver.ts b/packages/next/src/server/api-utils/node/api-resolver.ts index 529b6a62818be..e638fedaf7a5d 100644 --- a/packages/next/src/server/api-utils/node/api-resolver.ts +++ b/packages/next/src/server/api-utils/node/api-resolver.ts @@ -1,7 +1,7 @@ import type { IncomingMessage, ServerResponse } from 'http' import type { NextApiRequest, NextApiResponse } from '../../../shared/lib/utils' import type { PageConfig, ResponseLimit } from 'next/types' -import { __ApiPreviewProps } from '../.' +import type { __ApiPreviewProps } from '../.' import type { CookieSerializeOptions } from 'next/dist/compiled/cookie' import bytes from 'next/dist/compiled/bytes' diff --git a/packages/next/src/server/api-utils/node/try-get-preview-data.ts b/packages/next/src/server/api-utils/node/try-get-preview-data.ts index bebe98cf4495f..ca81d1379e0bb 100644 --- a/packages/next/src/server/api-utils/node/try-get-preview-data.ts +++ b/packages/next/src/server/api-utils/node/try-get-preview-data.ts @@ -1,6 +1,7 @@ import type { IncomingMessage, ServerResponse } from 'http' import type { NextApiResponse } from '../../../shared/lib/utils' -import { checkIsOnDemandRevalidate, __ApiPreviewProps } from '../.' +import { checkIsOnDemandRevalidate } from '../.' +import type { __ApiPreviewProps } from '../.' import type { BaseNextRequest, BaseNextResponse } from '../../base-http' import type { PreviewData } from 'next/types' diff --git a/packages/next/src/server/app-render/action-handler.ts b/packages/next/src/server/app-render/action-handler.ts index 93d4a62b80fdf..aaa5f5af8b7d0 100644 --- a/packages/next/src/server/app-render/action-handler.ts +++ b/packages/next/src/server/app-render/action-handler.ts @@ -19,10 +19,10 @@ import { isRedirectError, } from '../../client/components/redirect' import RenderResult from '../render-result' -import { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external' +import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external' import { FlightRenderResult } from './flight-render-result' -import { ActionResult } from './types' -import { ActionAsyncStorage } from '../../client/components/action-async-storage.external' +import type { ActionResult } from './types' +import type { ActionAsyncStorage } from '../../client/components/action-async-storage.external' import { filterReqHeaders, actionsForbiddenHeaders, @@ -32,7 +32,7 @@ import { getModifiedCookieValues, } from '../web/spec-extension/adapters/request-cookies' -import { RequestStore } from '../../client/components/request-async-storage.external' +import type { RequestStore } from '../../client/components/request-async-storage.external' import { NEXT_CACHE_REVALIDATED_TAGS_HEADER, NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER, diff --git a/packages/next/src/server/app-render/app-render.tsx b/packages/next/src/server/app-render/app-render.tsx index d45e52ab2801a..649264ffccb16 100644 --- a/packages/next/src/server/app-render/app-render.tsx +++ b/packages/next/src/server/app-render/app-render.tsx @@ -10,11 +10,13 @@ import type { RenderOpts, Segment, } from './types' +import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external' +import type { RequestStore } from '../../client/components/request-async-storage.external' import React from 'react' import { createServerComponentRenderer } from './create-server-components-renderer' -import { NextParsedUrlQuery } from '../request-meta' +import type { NextParsedUrlQuery } from '../request-meta' import RenderResult, { type RenderResultMetadata } from '../render-result' import { renderToInitialFizzStream, @@ -37,7 +39,8 @@ import { createMetadataComponents } from '../../lib/metadata/metadata' import { RequestAsyncStorageWrapper } from '../async-storage/request-async-storage-wrapper' import { StaticGenerationAsyncStorageWrapper } from '../async-storage/static-generation-async-storage-wrapper' import { isClientReference } from '../../lib/client-reference' -import { getLayoutOrPageModule, LoaderTree } from '../lib/app-dir-module' +import { getLayoutOrPageModule } from '../lib/app-dir-module' +import type { LoaderTree } from '../lib/app-dir-module' import { isNotFoundError } from '../../client/components/not-found' import { getURLFromRedirectError, @@ -73,8 +76,6 @@ import { appendMutableCookies } from '../web/spec-extension/adapters/request-coo import { createServerInsertedHTML } from './server-inserted-html' import { getRequiredScripts } from './required-scripts' import { addPathPrefix } from '../../shared/lib/router/utils/add-path-prefix' -import { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external' -import { RequestStore } from '../../client/components/request-async-storage.external' export type GetDynamicParamFromSegment = ( // [slug] / [[slug]] / [...slug] diff --git a/packages/next/src/server/app-render/create-server-components-renderer.tsx b/packages/next/src/server/app-render/create-server-components-renderer.tsx index d88f5492c61db..19de10845a0c4 100644 --- a/packages/next/src/server/app-render/create-server-components-renderer.tsx +++ b/packages/next/src/server/app-render/create-server-components-renderer.tsx @@ -3,7 +3,7 @@ import type { FlightResponseRef } from './flight-response-ref' import type { AppPageModule } from '../future/route-modules/app-page/module' import React, { use } from 'react' -import { createErrorHandler } from './create-error-handler' +import type { createErrorHandler } from './create-error-handler' import { useFlightResponse } from './use-flight-response' /** diff --git a/packages/next/src/server/app-render/get-css-inlined-link-tags.tsx b/packages/next/src/server/app-render/get-css-inlined-link-tags.tsx index 0311a3d92d5f4..a453eb84d9e4c 100644 --- a/packages/next/src/server/app-render/get-css-inlined-link-tags.tsx +++ b/packages/next/src/server/app-render/get-css-inlined-link-tags.tsx @@ -1,4 +1,4 @@ -import { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin' +import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin' /** * Get external stylesheet link hrefs based on server CSS manifest. diff --git a/packages/next/src/server/app-render/get-preloadable-fonts.tsx b/packages/next/src/server/app-render/get-preloadable-fonts.tsx index 860e4e1a5042f..61991ababccf8 100644 --- a/packages/next/src/server/app-render/get-preloadable-fonts.tsx +++ b/packages/next/src/server/app-render/get-preloadable-fonts.tsx @@ -1,4 +1,4 @@ -import { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin' +import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin' /** * Get hrefs for fonts to preload diff --git a/packages/next/src/server/app-render/get-segment-param.tsx b/packages/next/src/server/app-render/get-segment-param.tsx index 1dad71f25d723..e609aced06a0d 100644 --- a/packages/next/src/server/app-render/get-segment-param.tsx +++ b/packages/next/src/server/app-render/get-segment-param.tsx @@ -1,5 +1,5 @@ import { INTERCEPTION_ROUTE_MARKERS } from '../future/helpers/interception-routes' -import { DynamicParamTypes } from './types' +import type { DynamicParamTypes } from './types' /** * Parse dynamic route segment to type of parameter diff --git a/packages/next/src/server/app-render/get-short-dynamic-param-type.tsx b/packages/next/src/server/app-render/get-short-dynamic-param-type.tsx index 5e7125db1d870..670fedbdbb171 100644 --- a/packages/next/src/server/app-render/get-short-dynamic-param-type.tsx +++ b/packages/next/src/server/app-render/get-short-dynamic-param-type.tsx @@ -1,4 +1,4 @@ -import { DynamicParamTypes, DynamicParamTypesShort } from './types' +import type { DynamicParamTypes, DynamicParamTypesShort } from './types' export const dynamicParamTypes: Record< DynamicParamTypes, diff --git a/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx b/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx index 49086f94d8123..164234d05b357 100644 --- a/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx +++ b/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx @@ -1,4 +1,4 @@ -import { FlightRouterState } from './types' +import type { FlightRouterState } from './types' import { flightRouterStateSchema } from './types' import { assert } from 'next/dist/compiled/superstruct' diff --git a/packages/next/src/server/async-storage/draft-mode-provider.ts b/packages/next/src/server/async-storage/draft-mode-provider.ts index 06138db7dd169..1d0cac44570cc 100644 --- a/packages/next/src/server/async-storage/draft-mode-provider.ts +++ b/packages/next/src/server/async-storage/draft-mode-provider.ts @@ -7,8 +7,8 @@ import type { NextRequest } from '../web/spec-extension/request' import { COOKIE_NAME_PRERENDER_BYPASS, checkIsOnDemandRevalidate, - __ApiPreviewProps, } from '../api-utils' +import type { __ApiPreviewProps } from '../api-utils' export class DraftModeProvider { public readonly isEnabled: boolean diff --git a/packages/next/src/server/async-storage/request-async-storage-wrapper.ts b/packages/next/src/server/async-storage/request-async-storage-wrapper.ts index 1376ecfb197cd..8eccc19d120a4 100644 --- a/packages/next/src/server/async-storage/request-async-storage-wrapper.ts +++ b/packages/next/src/server/async-storage/request-async-storage-wrapper.ts @@ -5,6 +5,7 @@ import type { RequestStore } from '../../client/components/request-async-storage import type { RenderOpts } from '../app-render/types' import type { AsyncStorageWrapper } from './async-storage-wrapper' import type { NextRequest } from '../web/spec-extension/request' +import type { __ApiPreviewProps } from '../api-utils' import { FLIGHT_PARAMETERS } from '../../client/components/app-router-headers' import { @@ -16,8 +17,8 @@ import { RequestCookiesAdapter, type ReadonlyRequestCookies, } from '../web/spec-extension/adapters/request-cookies' -import { RequestCookies, ResponseCookies } from '../web/spec-extension/cookies' -import { __ApiPreviewProps } from '../api-utils' +import type { ResponseCookies } from '../web/spec-extension/cookies' +import { RequestCookies } from '../web/spec-extension/cookies' import { DraftModeProvider } from './draft-mode-provider' function getHeaders(headers: Headers | IncomingHttpHeaders): ReadonlyHeaders { diff --git a/packages/next/src/server/base-http/index.ts b/packages/next/src/server/base-http/index.ts index 2b1a9ea4c9bd2..412308b3e844e 100644 --- a/packages/next/src/server/base-http/index.ts +++ b/packages/next/src/server/base-http/index.ts @@ -2,7 +2,7 @@ import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http' import type { I18NConfig } from '../config-shared' import { PERMANENT_REDIRECT_STATUS } from '../../shared/lib/constants' -import { NextApiRequestCookies } from '../api-utils' +import type { NextApiRequestCookies } from '../api-utils' import { getCookieParser } from '../api-utils/get-cookie-parser' export interface BaseNextRequestConfig { diff --git a/packages/next/src/server/base-http/node.ts b/packages/next/src/server/base-http/node.ts index 516b707233e83..7a128d51f0b26 100644 --- a/packages/next/src/server/base-http/node.ts +++ b/packages/next/src/server/base-http/node.ts @@ -2,12 +2,14 @@ import type { ServerResponse, IncomingMessage } from 'http' import type { Writable, Readable } from 'stream' import type { SizeLimit } from 'next/types' -import { NextApiRequestCookies, SYMBOL_CLEARED_COOKIES } from '../api-utils' +import { SYMBOL_CLEARED_COOKIES } from '../api-utils' +import type { NextApiRequestCookies } from '../api-utils' import { parseBody } from '../api-utils/node/parse-body' -import { NEXT_REQUEST_META, RequestMeta } from '../request-meta' +import { NEXT_REQUEST_META } from '../request-meta' +import type { RequestMeta } from '../request-meta' import { BaseNextRequest, BaseNextResponse } from './index' -import { OutgoingHttpHeaders } from 'node:http' +import type { OutgoingHttpHeaders } from 'node:http' type Req = IncomingMessage & { [NEXT_REQUEST_META]?: RequestMeta diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index 4f6b867e27127..d9d7d882cb719 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -72,7 +72,7 @@ import { removeRequestMeta, } from './request-meta' -import { ImageConfigComplete } from '../shared/lib/image-config' +import type { ImageConfigComplete } from '../shared/lib/image-config' import { removePathPrefix } from '../shared/lib/router/utils/remove-path-prefix' import { normalizeAppPath, @@ -81,7 +81,7 @@ import { import { getHostname } from '../shared/lib/get-hostname' import { parseUrl as parseUrlUtil } from '../shared/lib/router/utils/parse-url' import { getNextPathnameInfo } from '../shared/lib/router/utils/get-next-pathname-info' -import { MiddlewareMatcher } from '../build/analysis/get-page-static-info' +import type { MiddlewareMatcher } from '../build/analysis/get-page-static-info' import { RSC, RSC_VARY_HEADER, @@ -91,7 +91,7 @@ import { NEXT_ROUTER_PREFETCH, RSC_CONTENT_TYPE_HEADER, } from '../client/components/app-router-headers' -import { +import type { MatchOptions, RouteMatcherManager, } from './future/route-matcher-managers/route-matcher-manager' diff --git a/packages/next/src/server/body-streams.ts b/packages/next/src/server/body-streams.ts index 2370aac8fa5a8..c4d3687766a3d 100644 --- a/packages/next/src/server/body-streams.ts +++ b/packages/next/src/server/body-streams.ts @@ -1,5 +1,6 @@ import type { IncomingMessage } from 'http' -import { PassThrough, Readable } from 'stream' +import type { Readable } from 'stream' +import { PassThrough } from 'stream' export function requestToBodyStream( context: { ReadableStream: typeof ReadableStream }, diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index 0437a2fb45507..6d8cbf38249b7 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -1,4 +1,4 @@ -import { NextConfig } from './config' +import type { NextConfig } from './config' import { VALID_LOADERS } from '../shared/lib/image-config' import { z } from 'next/dist/compiled/zod' diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index c03928b177cfb..8064d3b8d5570 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -1,15 +1,15 @@ import os from 'os' import type { webpack } from 'next/dist/compiled/webpack/webpack' import type { Header, Redirect, Rewrite } from '../lib/load-custom-routes' -import { +import { imageConfigDefault } from '../shared/lib/image-config' +import type { ImageConfig, ImageConfigComplete, - imageConfigDefault, } from '../shared/lib/image-config' -import { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin' -import { WEB_VITALS } from '../shared/lib/utils' +import type { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin' +import type { WEB_VITALS } from '../shared/lib/utils' import type { NextParsedUrlQuery } from './request-meta' -import { SizeLimit } from '../../types' +import type { SizeLimit } from '../../types' export type NextConfigComplete = Required & { images: Required diff --git a/packages/next/src/server/config.ts b/packages/next/src/server/config.ts index 6d224c57a2d69..1a99afa975bf3 100644 --- a/packages/next/src/server/config.ts +++ b/packages/next/src/server/config.ts @@ -4,16 +4,17 @@ import { pathToFileURL } from 'url' import findUp from 'next/dist/compiled/find-up' import * as Log from '../build/output/log' import { CONFIG_FILES, PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' -import { - defaultConfig, - normalizeConfig, +import { defaultConfig, normalizeConfig } from './config-shared' +import type { ExperimentalConfig, NextConfigComplete, NextConfig, TurboLoaderItem, } from './config-shared' + import { loadWebpackHook } from './config-utils' -import { ImageConfig, imageConfigDefault } from '../shared/lib/image-config' +import { imageConfigDefault } from '../shared/lib/image-config' +import type { ImageConfig } from '../shared/lib/image-config' import { loadEnvConfig, updateInitialEnv } from '@next/env' import { flushAndExit } from '../telemetry/flush-and-exit' import { findRootDir } from '../lib/find-root' @@ -23,7 +24,8 @@ import { pathHasPrefix } from '../shared/lib/router/utils/path-has-prefix' import { ZodParsedType, util as ZodUtil } from 'next/dist/compiled/zod' import type { ZodError, ZodIssue } from 'next/dist/compiled/zod' -export { DomainLocale, NextConfig, normalizeConfig } from './config-shared' +export { normalizeConfig } from './config-shared' +export type { DomainLocale, NextConfig } from './config-shared' function processZodErrorMessage(issue: ZodIssue) { let message = issue.message diff --git a/packages/next/src/server/dev/hot-middleware.ts b/packages/next/src/server/dev/hot-middleware.ts index ec673880621a0..506b54f53247b 100644 --- a/packages/next/src/server/dev/hot-middleware.ts +++ b/packages/next/src/server/dev/hot-middleware.ts @@ -25,10 +25,8 @@ import type { webpack } from 'next/dist/compiled/webpack/webpack' import type ws from 'next/dist/compiled/ws' import { isMiddlewareFilename } from '../../build/utils' import type { VersionInfo } from './parse-version-info' -import { - HMR_ACTIONS_SENT_TO_BROWSER, - HMR_ACTION_TYPES, -} from './hot-reloader-types' +import type { HMR_ACTION_TYPES } from './hot-reloader-types' +import { HMR_ACTIONS_SENT_TO_BROWSER } from './hot-reloader-types' function isMiddlewareStats(stats: webpack.Stats) { for (const key of stats.compilation.entrypoints.keys()) { diff --git a/packages/next/src/server/dev/hot-reloader-webpack.ts b/packages/next/src/server/dev/hot-reloader-webpack.ts index 48187503b3990..2e4cfbef17a86 100644 --- a/packages/next/src/server/dev/hot-reloader-webpack.ts +++ b/packages/next/src/server/dev/hot-reloader-webpack.ts @@ -36,7 +36,7 @@ import { COMPILER_NAMES, RSC_MODULE_TYPES, } from '../../shared/lib/constants' -import { __ApiPreviewProps } from '../api-utils' +import type { __ApiPreviewProps } from '../api-utils' import { getPathMatch } from '../../shared/lib/router/utils/path-match' import { findPageFile } from '../lib/find-page-file' import { @@ -59,9 +59,10 @@ import { Span, trace } from '../../trace' import { getProperError } from '../../lib/is-error' import ws from 'next/dist/compiled/ws' import { existsSync, promises as fs } from 'fs' -import { UnwrapPromise } from '../../lib/coalesced-function' +import type { UnwrapPromise } from '../../lib/coalesced-function' import { getRegistry } from '../../lib/helpers/get-registry' -import { parseVersionInfo, VersionInfo } from './parse-version-info' +import { parseVersionInfo } from './parse-version-info' +import type { VersionInfo } from './parse-version-info' import { isAPIRoute } from '../../lib/is-api-route' import { getRouteLoaderEntry } from '../../build/webpack/loaders/next-route-loader' import { @@ -71,9 +72,9 @@ import { import { RouteKind } from '../future/route-kind' import { HMR_ACTIONS_SENT_TO_BROWSER, - HMR_ACTION_TYPES, type NextJsHotReloaderInterface, } from './hot-reloader-types' +import type { HMR_ACTION_TYPES } from './hot-reloader-types' const MILLISECONDS_IN_NANOSECOND = 1_000_000 diff --git a/packages/next/src/server/dev/next-dev-server.ts b/packages/next/src/server/dev/next-dev-server.ts index 561f6958ce548..8c3896c2632f9 100644 --- a/packages/next/src/server/dev/next-dev-server.ts +++ b/packages/next/src/server/dev/next-dev-server.ts @@ -38,31 +38,27 @@ import { Telemetry } from '../../telemetry/storage' import { setGlobal } from '../../trace' import { findPageFile } from '../lib/find-page-file' import { getNodeOptionsWithoutInspect } from '../lib/utils' -import { - UnwrapPromise, - withCoalescedInvoke, -} from '../../lib/coalesced-function' +import { withCoalescedInvoke } from '../../lib/coalesced-function' +import type { UnwrapPromise } from '../../lib/coalesced-function' import { loadDefaultErrorComponents } from '../load-default-error-components' import { DecodeError, MiddlewareNotFoundError } from '../../shared/lib/utils' import * as Log from '../../build/output/log' import isError, { getProperError } from '../../lib/is-error' -import { NodeNextResponse, NodeNextRequest } from '../base-http/node' +import type { NodeNextResponse, NodeNextRequest } from '../base-http/node' import { isMiddlewareFile } from '../../build/utils' import { formatServerError } from '../../lib/format-server-error' -import { - DevRouteMatcherManager, - RouteEnsurer, -} from '../future/route-matcher-managers/dev-route-matcher-manager' +import { DevRouteMatcherManager } from '../future/route-matcher-managers/dev-route-matcher-manager' +import type { RouteEnsurer } from '../future/route-matcher-managers/dev-route-matcher-manager' import { DevPagesRouteMatcherProvider } from '../future/route-matcher-providers/dev/dev-pages-route-matcher-provider' import { DevPagesAPIRouteMatcherProvider } from '../future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider' import { DevAppPageRouteMatcherProvider } from '../future/route-matcher-providers/dev/dev-app-page-route-matcher-provider' import { DevAppRouteRouteMatcherProvider } from '../future/route-matcher-providers/dev/dev-app-route-route-matcher-provider' -import { PagesManifest } from '../../build/webpack/plugins/pages-manifest-plugin' +import type { PagesManifest } from '../../build/webpack/plugins/pages-manifest-plugin' import { NodeManifestLoader } from '../future/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader' import { BatchedFileReader } from '../future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader' import { DefaultFileReader } from '../future/route-matcher-providers/dev/helpers/file-reader/default-file-reader' import { NextBuildContext } from '../../build/build-context' -import { IncrementalCache } from '../lib/incremental-cache' +import type { IncrementalCache } from '../lib/incremental-cache' import LRUCache from 'next/dist/compiled/lru-cache' import { getMiddlewareRouteMatcher } from '../../shared/lib/router/utils/middleware-route-matcher' diff --git a/packages/next/src/server/dev/on-demand-entry-handler.ts b/packages/next/src/server/dev/on-demand-entry-handler.ts index 0529aeb9d56f4..f8e11a0b9fe99 100644 --- a/packages/next/src/server/dev/on-demand-entry-handler.ts +++ b/packages/next/src/server/dev/on-demand-entry-handler.ts @@ -28,16 +28,16 @@ import { } from '../../build/utils' import { PageNotFoundError, stringifyError } from '../../shared/lib/utils' import { - CompilerNameValues, COMPILER_INDEXES, COMPILER_NAMES, RSC_MODULE_TYPES, } from '../../shared/lib/constants' +import type { CompilerNameValues } from '../../shared/lib/constants' import { HMR_ACTIONS_SENT_TO_BROWSER } from './hot-reloader-types' -import HotReloader from './hot-reloader-webpack' +import type HotReloader from './hot-reloader-webpack' import { isAppPageRouteDefinition } from '../future/route-definitions/app-page-route-definition' import { scheduleOnNextTick } from '../lib/schedule-on-next-tick' -import { RouteDefinition } from '../future/route-definitions/route-definition' +import type { RouteDefinition } from '../future/route-definitions/route-definition' import { Batcher } from '../../lib/batcher' const debug = origDebug('next:on-demand-entry-handler') diff --git a/packages/next/src/server/dev/parse-version-info.test.ts b/packages/next/src/server/dev/parse-version-info.test.ts index eddece9321ff1..afca7390afea1 100644 --- a/packages/next/src/server/dev/parse-version-info.test.ts +++ b/packages/next/src/server/dev/parse-version-info.test.ts @@ -1,4 +1,5 @@ -import { parseVersionInfo, VersionInfo } from './parse-version-info' +import { parseVersionInfo } from './parse-version-info' +import type { VersionInfo } from './parse-version-info' describe('parse version info', () => { test.each< diff --git a/packages/next/src/server/dev/static-paths-worker.ts b/packages/next/src/server/dev/static-paths-worker.ts index d357a170fefbf..99e287b24d0db 100644 --- a/packages/next/src/server/dev/static-paths-worker.ts +++ b/packages/next/src/server/dev/static-paths-worker.ts @@ -9,11 +9,11 @@ import { buildAppStaticPaths, buildStaticPaths, collectGenerateParams, - GenerateParams, } from '../../build/utils' +import type { GenerateParams } from '../../build/utils' import { loadComponents } from '../load-components' import { setHttpClientAndAgentOptions } from '../setup-http-agent-env' -import { IncrementalCache } from '../lib/incremental-cache' +import type { IncrementalCache } from '../lib/incremental-cache' import * as serverHooks from '../../client/components/hooks-server-context' import { staticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage.external' diff --git a/packages/next/src/server/future/helpers/i18n-provider.test.ts b/packages/next/src/server/future/helpers/i18n-provider.test.ts index b08d06a9f4e90..22667adfb8bd4 100644 --- a/packages/next/src/server/future/helpers/i18n-provider.test.ts +++ b/packages/next/src/server/future/helpers/i18n-provider.test.ts @@ -1,5 +1,6 @@ -import { DomainLocale } from '../../config' -import { I18NProvider, LocaleAnalysisResult } from './i18n-provider' +import type { DomainLocale } from '../../config' +import { I18NProvider } from './i18n-provider' +import type { LocaleAnalysisResult } from './i18n-provider' describe('I18NProvider', () => { const config = { diff --git a/packages/next/src/server/future/helpers/module-loader/node-module-loader.ts b/packages/next/src/server/future/helpers/module-loader/node-module-loader.ts index 6f70685df7e75..487a9350aaf4a 100644 --- a/packages/next/src/server/future/helpers/module-loader/node-module-loader.ts +++ b/packages/next/src/server/future/helpers/module-loader/node-module-loader.ts @@ -1,4 +1,4 @@ -import { ModuleLoader } from './module-loader' +import type { ModuleLoader } from './module-loader' /** * Loads a module using `await require(id)`. diff --git a/packages/next/src/server/future/normalizers/absolute-filename-normalizer.ts b/packages/next/src/server/future/normalizers/absolute-filename-normalizer.ts index b638e60f85eb6..ad8419461b3d8 100644 --- a/packages/next/src/server/future/normalizers/absolute-filename-normalizer.ts +++ b/packages/next/src/server/future/normalizers/absolute-filename-normalizer.ts @@ -1,5 +1,5 @@ import { absolutePathToPage } from '../../../shared/lib/page-path/absolute-path-to-page' -import { Normalizer } from './normalizer' +import type { Normalizer } from './normalizer' /** * Normalizes a given filename so that it's relative to the provided directory. diff --git a/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts b/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts index 815ce92f92726..df10d54223d81 100644 --- a/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts +++ b/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts @@ -1,5 +1,5 @@ import { Normalizers } from '../../normalizers' -import { Normalizer } from '../../normalizer' +import type { Normalizer } from '../../normalizer' import { PrefixingNormalizer } from '../../prefixing-normalizer' import { normalizePagePath } from '../../../../../shared/lib/page-path/normalize-page-path' diff --git a/packages/next/src/server/future/normalizers/built/app/app-pathname-normalizer.ts b/packages/next/src/server/future/normalizers/built/app/app-pathname-normalizer.ts index 7143e87138a58..c96cb523207d9 100644 --- a/packages/next/src/server/future/normalizers/built/app/app-pathname-normalizer.ts +++ b/packages/next/src/server/future/normalizers/built/app/app-pathname-normalizer.ts @@ -2,7 +2,7 @@ import { normalizeAppPath } from '../../../../../shared/lib/router/utils/app-pat import { Normalizers } from '../../normalizers' import { wrapNormalizerFn } from '../../wrap-normalizer-fn' import { UnderscoreNormalizer } from '../../underscore-normalizer' -import { Normalizer } from '../../normalizer' +import type { Normalizer } from '../../normalizer' export class AppPathnameNormalizer extends Normalizers { constructor() { diff --git a/packages/next/src/server/future/normalizers/built/pages/pages-bundle-path-normalizer.ts b/packages/next/src/server/future/normalizers/built/pages/pages-bundle-path-normalizer.ts index 79cfae76e5997..b895d04e1268f 100644 --- a/packages/next/src/server/future/normalizers/built/pages/pages-bundle-path-normalizer.ts +++ b/packages/next/src/server/future/normalizers/built/pages/pages-bundle-path-normalizer.ts @@ -1,5 +1,5 @@ import { normalizePagePath } from '../../../../../shared/lib/page-path/normalize-page-path' -import { Normalizer } from '../../normalizer' +import type { Normalizer } from '../../normalizer' import { Normalizers } from '../../normalizers' import { PrefixingNormalizer } from '../../prefixing-normalizer' import { wrapNormalizerFn } from '../../wrap-normalizer-fn' diff --git a/packages/next/src/server/future/normalizers/locale-route-normalizer.ts b/packages/next/src/server/future/normalizers/locale-route-normalizer.ts index 61240e4dc845c..80bf2e508fe26 100644 --- a/packages/next/src/server/future/normalizers/locale-route-normalizer.ts +++ b/packages/next/src/server/future/normalizers/locale-route-normalizer.ts @@ -1,5 +1,5 @@ -import { I18NProvider } from '../helpers/i18n-provider' -import { Normalizer } from './normalizer' +import type { I18NProvider } from '../helpers/i18n-provider' +import type { Normalizer } from './normalizer' /** * Normalizes the pathname by removing the locale prefix if any. diff --git a/packages/next/src/server/future/normalizers/normalizers.ts b/packages/next/src/server/future/normalizers/normalizers.ts index 11226a80daeb2..4f9d6c9e24d7c 100644 --- a/packages/next/src/server/future/normalizers/normalizers.ts +++ b/packages/next/src/server/future/normalizers/normalizers.ts @@ -1,4 +1,4 @@ -import { Normalizer } from './normalizer' +import type { Normalizer } from './normalizer' /** * Normalizers combines many normalizers into a single normalizer interface that diff --git a/packages/next/src/server/future/normalizers/prefixing-normalizer.ts b/packages/next/src/server/future/normalizers/prefixing-normalizer.ts index 02bef440af0c6..f16b0109bb4e7 100644 --- a/packages/next/src/server/future/normalizers/prefixing-normalizer.ts +++ b/packages/next/src/server/future/normalizers/prefixing-normalizer.ts @@ -1,5 +1,5 @@ import path from '../../../shared/lib/isomorphic/path' -import { Normalizer } from './normalizer' +import type { Normalizer } from './normalizer' export class PrefixingNormalizer implements Normalizer { private readonly prefix: string diff --git a/packages/next/src/server/future/normalizers/underscore-normalizer.ts b/packages/next/src/server/future/normalizers/underscore-normalizer.ts index 8436889769787..9c3ded43d3b8b 100644 --- a/packages/next/src/server/future/normalizers/underscore-normalizer.ts +++ b/packages/next/src/server/future/normalizers/underscore-normalizer.ts @@ -1,4 +1,4 @@ -import { Normalizer } from './normalizer' +import type { Normalizer } from './normalizer' /** * UnderscoreNormalizer replaces all instances of %5F with _. diff --git a/packages/next/src/server/future/normalizers/wrap-normalizer-fn.ts b/packages/next/src/server/future/normalizers/wrap-normalizer-fn.ts index e8b785661e2fa..202e71a5bf770 100644 --- a/packages/next/src/server/future/normalizers/wrap-normalizer-fn.ts +++ b/packages/next/src/server/future/normalizers/wrap-normalizer-fn.ts @@ -1,4 +1,4 @@ -import { Normalizer } from './normalizer' +import type { Normalizer } from './normalizer' export function wrapNormalizerFn(fn: (pathname: string) => string): Normalizer { return { normalize: fn } diff --git a/packages/next/src/server/future/route-definitions/app-page-route-definition.ts b/packages/next/src/server/future/route-definitions/app-page-route-definition.ts index 8a4ed182ccfee..fbead0628e89c 100644 --- a/packages/next/src/server/future/route-definitions/app-page-route-definition.ts +++ b/packages/next/src/server/future/route-definitions/app-page-route-definition.ts @@ -1,5 +1,5 @@ +import type { RouteDefinition } from './route-definition' import { RouteKind } from '../route-kind' -import { RouteDefinition } from './route-definition' export interface AppPageRouteDefinition extends RouteDefinition { diff --git a/packages/next/src/server/future/route-definitions/locale-route-definition.ts b/packages/next/src/server/future/route-definitions/locale-route-definition.ts index 68978e506836e..365a77e6f83bc 100644 --- a/packages/next/src/server/future/route-definitions/locale-route-definition.ts +++ b/packages/next/src/server/future/route-definitions/locale-route-definition.ts @@ -1,5 +1,5 @@ -import { RouteKind } from '../route-kind' -import { RouteDefinition } from './route-definition' +import type { RouteDefinition } from './route-definition' +import type { RouteKind } from '../route-kind' export interface LocaleRouteDefinition extends RouteDefinition { diff --git a/packages/next/src/server/future/route-definitions/pages-api-route-definition.ts b/packages/next/src/server/future/route-definitions/pages-api-route-definition.ts index 9510b0419198a..b3f94e0b2d9fe 100644 --- a/packages/next/src/server/future/route-definitions/pages-api-route-definition.ts +++ b/packages/next/src/server/future/route-definitions/pages-api-route-definition.ts @@ -1,5 +1,5 @@ -import { RouteKind } from '../route-kind' -import { LocaleRouteDefinition } from './locale-route-definition' +import type { RouteKind } from '../route-kind' +import type { LocaleRouteDefinition } from './locale-route-definition' export interface PagesAPIRouteDefinition extends LocaleRouteDefinition {} diff --git a/packages/next/src/server/future/route-definitions/pages-route-definition.ts b/packages/next/src/server/future/route-definitions/pages-route-definition.ts index 8e5055d8c0afa..76779addb66d9 100644 --- a/packages/next/src/server/future/route-definitions/pages-route-definition.ts +++ b/packages/next/src/server/future/route-definitions/pages-route-definition.ts @@ -1,5 +1,5 @@ -import { RouteKind } from '../route-kind' -import { LocaleRouteDefinition } from './locale-route-definition' +import type { LocaleRouteDefinition } from './locale-route-definition' +import type { RouteKind } from '../route-kind' export interface PagesRouteDefinition extends LocaleRouteDefinition {} diff --git a/packages/next/src/server/future/route-definitions/route-definition.ts b/packages/next/src/server/future/route-definitions/route-definition.ts index dcd23c23f8216..17904242ee716 100644 --- a/packages/next/src/server/future/route-definitions/route-definition.ts +++ b/packages/next/src/server/future/route-definitions/route-definition.ts @@ -1,4 +1,4 @@ -import { RouteKind } from '../route-kind' +import type { RouteKind } from '../route-kind' export interface RouteDefinition { readonly kind: K diff --git a/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.test.ts b/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.test.ts index 7f6454aaef1bc..6c48d759834be 100644 --- a/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.test.ts +++ b/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.test.ts @@ -1,12 +1,12 @@ -import { AppPageRouteDefinition } from '../route-definitions/app-page-route-definition' -import { LocaleRouteDefinition } from '../route-definitions/locale-route-definition' -import { PagesRouteDefinition } from '../route-definitions/pages-route-definition' +import type { AppPageRouteDefinition } from '../route-definitions/app-page-route-definition' +import type { LocaleRouteDefinition } from '../route-definitions/locale-route-definition' +import type { PagesRouteDefinition } from '../route-definitions/pages-route-definition' import { RouteKind } from '../route-kind' -import { RouteMatcherProvider } from '../route-matcher-providers/route-matcher-provider' +import type { RouteMatcherProvider } from '../route-matcher-providers/route-matcher-provider' import { LocaleRouteMatcher } from '../route-matchers/locale-route-matcher' import { RouteMatcher } from '../route-matchers/route-matcher' import { DefaultRouteMatcherManager } from './default-route-matcher-manager' -import { MatchOptions } from './route-matcher-manager' +import type { MatchOptions } from './route-matcher-manager' describe('DefaultRouteMatcherManager', () => { it('will throw an error when used before it has been reloaded', async () => { diff --git a/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.ts b/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.ts index 6b47776376b6d..df40fe02eacbe 100644 --- a/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.ts +++ b/packages/next/src/server/future/route-matcher-managers/default-route-matcher-manager.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { isDynamicRoute } from '../../../shared/lib/router/utils' -import { RouteKind } from '../route-kind' -import { RouteMatch } from '../route-matches/route-match' -import { RouteDefinition } from '../route-definitions/route-definition' -import { RouteMatcherProvider } from '../route-matcher-providers/route-matcher-provider' -import { RouteMatcher } from '../route-matchers/route-matcher' -import { MatchOptions, RouteMatcherManager } from './route-matcher-manager' +import type { RouteKind } from '../route-kind' +import type { RouteMatch } from '../route-matches/route-match' +import type { RouteDefinition } from '../route-definitions/route-definition' +import type { RouteMatcherProvider } from '../route-matcher-providers/route-matcher-provider' +import type { RouteMatcher } from '../route-matchers/route-matcher' +import type { MatchOptions, RouteMatcherManager } from './route-matcher-manager' import { getSortedRoutes } from '../../../shared/lib/router/utils' import { LocaleRouteMatcher } from '../route-matchers/locale-route-matcher' import { ensureLeadingSlash } from '../../../shared/lib/page-path/ensure-leading-slash' diff --git a/packages/next/src/server/future/route-matcher-managers/dev-route-matcher-manager.ts b/packages/next/src/server/future/route-matcher-managers/dev-route-matcher-manager.ts index 464700913f19e..78d69b95a698a 100644 --- a/packages/next/src/server/future/route-matcher-managers/dev-route-matcher-manager.ts +++ b/packages/next/src/server/future/route-matcher-managers/dev-route-matcher-manager.ts @@ -1,12 +1,12 @@ import { RouteKind } from '../route-kind' -import { RouteMatch } from '../route-matches/route-match' -import { RouteDefinition } from '../route-definitions/route-definition' +import type { RouteMatch } from '../route-matches/route-match' +import type { RouteDefinition } from '../route-definitions/route-definition' import { DefaultRouteMatcherManager } from './default-route-matcher-manager' -import { MatchOptions, RouteMatcherManager } from './route-matcher-manager' +import type { MatchOptions, RouteMatcherManager } from './route-matcher-manager' import path from '../../../shared/lib/isomorphic/path' import * as Log from '../../../build/output/log' import { cyan } from '../../../lib/picocolors' -import { RouteMatcher } from '../route-matchers/route-matcher' +import type { RouteMatcher } from '../route-matchers/route-matcher' export interface RouteEnsurer { ensure(match: RouteMatch): Promise diff --git a/packages/next/src/server/future/route-matcher-managers/route-matcher-manager.ts b/packages/next/src/server/future/route-matcher-managers/route-matcher-manager.ts index dc4e8f024caa2..2b58a9891621c 100644 --- a/packages/next/src/server/future/route-matcher-managers/route-matcher-manager.ts +++ b/packages/next/src/server/future/route-matcher-managers/route-matcher-manager.ts @@ -1,5 +1,5 @@ -import { RouteMatch } from '../route-matches/route-match' -import { RouteMatcherProvider } from '../route-matcher-providers/route-matcher-provider' +import type { RouteMatch } from '../route-matches/route-match' +import type { RouteMatcherProvider } from '../route-matcher-providers/route-matcher-provider' import type { LocaleAnalysisResult } from '../helpers/i18n-provider' export type MatchOptions = { diff --git a/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.test.ts index bc3a15b4fac48..e4a97bf14fd8f 100644 --- a/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.test.ts @@ -1,8 +1,8 @@ import { SERVER_DIRECTORY } from '../../../shared/lib/constants' -import { AppPageRouteDefinition } from '../route-definitions/app-page-route-definition' +import type { AppPageRouteDefinition } from '../route-definitions/app-page-route-definition' import { RouteKind } from '../route-kind' import { AppPageRouteMatcherProvider } from './app-page-route-matcher-provider' -import { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' +import type { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' describe('AppPageRouteMatcherProvider', () => { it('returns no routes with an empty manifest', async () => { diff --git a/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.ts index e63751c3cac06..a7d2385754868 100644 --- a/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/app-page-route-matcher-provider.ts @@ -4,7 +4,7 @@ import { APP_PATHS_MANIFEST } from '../../../shared/lib/constants' import { AppNormalizers } from '../normalizers/built/app' import { RouteKind } from '../route-kind' import { AppPageRouteMatcher } from '../route-matchers/app-page-route-matcher' -import { +import type { Manifest, ManifestLoader, } from './helpers/manifest-loaders/manifest-loader' diff --git a/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.test.ts index 335322111f17e..a542b1055be92 100644 --- a/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.test.ts @@ -1,8 +1,8 @@ import { SERVER_DIRECTORY } from '../../../shared/lib/constants' -import { AppRouteRouteDefinition } from '../route-definitions/app-route-route-definition' +import type { AppRouteRouteDefinition } from '../route-definitions/app-route-route-definition' import { RouteKind } from '../route-kind' import { AppRouteRouteMatcherProvider } from './app-route-route-matcher-provider' -import { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' +import type { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' describe('AppRouteRouteMatcherProvider', () => { it('returns no routes with an empty manifest', async () => { diff --git a/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.ts index 98ec570ac696b..2e9845795dc06 100644 --- a/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/app-route-route-matcher-provider.ts @@ -2,7 +2,7 @@ import { isAppRouteRoute } from '../../../lib/is-app-route-route' import { APP_PATHS_MANIFEST } from '../../../shared/lib/constants' import { RouteKind } from '../route-kind' import { AppRouteRouteMatcher } from '../route-matchers/app-route-route-matcher' -import { +import type { Manifest, ManifestLoader, } from './helpers/manifest-loaders/manifest-loader' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.test.ts index 2226b565d075e..c494ebbdfcefb 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.test.ts @@ -1,7 +1,7 @@ -import { AppPageRouteDefinition } from '../../route-definitions/app-page-route-definition' +import type { AppPageRouteDefinition } from '../../route-definitions/app-page-route-definition' import { RouteKind } from '../../route-kind' import { DevAppPageRouteMatcherProvider } from './dev-app-page-route-matcher-provider' -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' describe('DevAppPageRouteMatcher', () => { const dir = '' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts index f57a2a0c392d2..2d7914fc99992 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts @@ -1,4 +1,4 @@ -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' import { AppPageRouteMatcher } from '../../route-matchers/app-page-route-matcher' import { RouteKind } from '../../route-kind' import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.test.ts index 477b22400b65a..d7f9c48cfc093 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.test.ts @@ -1,7 +1,7 @@ -import { AppRouteRouteDefinition } from '../../route-definitions/app-route-route-definition' +import type { AppRouteRouteDefinition } from '../../route-definitions/app-route-route-definition' import { RouteKind } from '../../route-kind' import { DevAppRouteRouteMatcherProvider } from './dev-app-route-route-matcher-provider' -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' describe('DevAppRouteRouteMatcher', () => { const dir = '' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.ts index d196d697436ae..520724e9be74e 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.ts @@ -1,6 +1,6 @@ -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' +import type { Normalizer } from '../../normalizers/normalizer' import { AppRouteRouteMatcher } from '../../route-matchers/app-route-route-matcher' -import { Normalizer } from '../../normalizers/normalizer' import { RouteKind } from '../../route-kind' import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider' import { isAppRouteRoute } from '../../../../lib/is-app-route-route' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.test.ts index f3a9f744b15f4..7386057594187 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.test.ts @@ -1,8 +1,8 @@ import path from 'path' -import { PagesAPIRouteDefinition } from '../../route-definitions/pages-api-route-definition' +import type { PagesAPIRouteDefinition } from '../../route-definitions/pages-api-route-definition' import { RouteKind } from '../../route-kind' import { DevPagesAPIRouteMatcherProvider } from './dev-pages-api-route-matcher-provider' -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' const normalizeSlashes = (p: string) => p.replace(/\//g, path.sep) diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.ts index beea03ceb75f3..38c805a4d2bd4 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.ts @@ -1,11 +1,11 @@ -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' import { PagesAPILocaleRouteMatcher, PagesAPIRouteMatcher, } from '../../route-matchers/pages-api-route-matcher' import { RouteKind } from '../../route-kind' import path from 'path' -import { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer' +import type { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer' import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider' import { DevPagesNormalizers } from '../../normalizers/built/pages' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.test.ts index c5875f2d1cdf2..06eee88592c00 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.test.ts @@ -1,8 +1,8 @@ import path from 'path' -import { PagesRouteDefinition } from '../../route-definitions/pages-route-definition' +import type { PagesRouteDefinition } from '../../route-definitions/pages-route-definition' import { RouteKind } from '../../route-kind' import { DevPagesRouteMatcherProvider } from './dev-pages-route-matcher-provider' -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' const normalizeSlashes = (p: string) => p.replace(/\//g, path.sep) diff --git a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.ts index f391af162329a..fef702de3d2bb 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.ts @@ -1,11 +1,11 @@ -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' import { PagesRouteMatcher, PagesLocaleRouteMatcher, } from '../../route-matchers/pages-route-matcher' import { RouteKind } from '../../route-kind' import path from 'path' -import { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer' +import type { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer' import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider' import { DevPagesNormalizers } from '../../normalizers/built/pages' diff --git a/packages/next/src/server/future/route-matcher-providers/dev/file-cache-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/dev/file-cache-route-matcher-provider.ts index bc212ee825e58..a354d906acabe 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/file-cache-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/file-cache-route-matcher-provider.ts @@ -1,6 +1,6 @@ -import { RouteMatcher } from '../../route-matchers/route-matcher' +import type { RouteMatcher } from '../../route-matchers/route-matcher' import { CachedRouteMatcherProvider } from '../helpers/cached-route-matcher-provider' -import { FileReader } from './helpers/file-reader/file-reader' +import type { FileReader } from './helpers/file-reader/file-reader' /** * This will memoize the matchers when the file contents are the same. diff --git a/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.test.ts b/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.test.ts index 36342762bfce9..beddc544eeec2 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.test.ts @@ -1,5 +1,5 @@ import { BatchedFileReader } from './batched-file-reader' -import { FileReader } from './file-reader' +import type { FileReader } from './file-reader' describe('CachedFileReader', () => { it('will only scan the filesystem a minimal amount of times', async () => { diff --git a/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts b/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts index c6ad88b2f6f35..3b7b5f6e0a7a5 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts @@ -1,4 +1,4 @@ -import { FileReader } from './file-reader' +import type { FileReader } from './file-reader' interface FileReaderBatch { completed: boolean diff --git a/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts b/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts index 96a463fe3b83c..f3411281fe19d 100644 --- a/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts +++ b/packages/next/src/server/future/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts @@ -1,9 +1,6 @@ import type { FileReader } from './file-reader' - -import { - RecursiveReadDirOptions, - recursiveReadDir, -} from '../../../../../../lib/recursive-readdir' +import type { RecursiveReadDirOptions } from '../../../../../../lib/recursive-readdir' +import { recursiveReadDir } from '../../../../../../lib/recursive-readdir' export type DefaultFileReaderOptions = Pick< RecursiveReadDirOptions, diff --git a/packages/next/src/server/future/route-matcher-providers/helpers/cached-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/helpers/cached-route-matcher-provider.ts index e5e27b4e991a9..b21fc3245e503 100644 --- a/packages/next/src/server/future/route-matcher-providers/helpers/cached-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/helpers/cached-route-matcher-provider.ts @@ -1,5 +1,5 @@ -import { RouteMatcher } from '../../route-matchers/route-matcher' -import { RouteMatcherProvider } from '../route-matcher-provider' +import type { RouteMatcherProvider } from '../route-matcher-provider' +import type { RouteMatcher } from '../../route-matchers/route-matcher' interface LoaderComparable { load(): Promise diff --git a/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.ts b/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.ts index a7bcd301439aa..95cedd38b1741 100644 --- a/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.ts +++ b/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.ts @@ -1,6 +1,6 @@ import { SERVER_DIRECTORY } from '../../../../../shared/lib/constants' import path from '../../../../../shared/lib/isomorphic/path' -import { Manifest, ManifestLoader } from './manifest-loader' +import type { Manifest, ManifestLoader } from './manifest-loader' export class NodeManifestLoader implements ManifestLoader { constructor(private readonly distDir: string) {} diff --git a/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.ts b/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.ts index 6ecbcb4e1f0d0..27f187bd66e6a 100644 --- a/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.ts +++ b/packages/next/src/server/future/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.ts @@ -1,4 +1,4 @@ -import { Manifest, ManifestLoader } from './manifest-loader' +import type { Manifest, ManifestLoader } from './manifest-loader' export class ServerManifestLoader implements ManifestLoader { constructor(private readonly getter: (name: string) => Manifest | null) {} diff --git a/packages/next/src/server/future/route-matcher-providers/manifest-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/manifest-route-matcher-provider.ts index e9dffe1997359..33312484785d4 100644 --- a/packages/next/src/server/future/route-matcher-providers/manifest-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/manifest-route-matcher-provider.ts @@ -1,5 +1,5 @@ -import { RouteMatcher } from '../route-matchers/route-matcher' -import { +import type { RouteMatcher } from '../route-matchers/route-matcher' +import type { Manifest, ManifestLoader, } from './helpers/manifest-loaders/manifest-loader' diff --git a/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.test.ts index fa860ed795bd3..62327ded1dbfa 100644 --- a/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.test.ts @@ -1,7 +1,7 @@ import { PAGES_MANIFEST, SERVER_DIRECTORY } from '../../../shared/lib/constants' -import { PagesAPIRouteDefinition } from '../route-definitions/pages-api-route-definition' +import type { PagesAPIRouteDefinition } from '../route-definitions/pages-api-route-definition' import { RouteKind } from '../route-kind' -import { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' +import type { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' import { PagesAPIRouteMatcherProvider } from './pages-api-route-matcher-provider' describe('PagesAPIRouteMatcherProvider', () => { diff --git a/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.ts index aff90bc60b7d3..aad90e1448a5a 100644 --- a/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/pages-api-route-matcher-provider.ts @@ -5,12 +5,12 @@ import { PagesAPILocaleRouteMatcher, PagesAPIRouteMatcher, } from '../route-matchers/pages-api-route-matcher' -import { +import type { Manifest, ManifestLoader, } from './helpers/manifest-loaders/manifest-loader' import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider' -import { I18NProvider } from '../helpers/i18n-provider' +import type { I18NProvider } from '../helpers/i18n-provider' import { PagesNormalizers } from '../normalizers/built/pages' export class PagesAPIRouteMatcherProvider extends ManifestRouteMatcherProvider { diff --git a/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.test.ts b/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.test.ts index 49ab3fca32b5d..f0e698b5beb58 100644 --- a/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.test.ts +++ b/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.test.ts @@ -1,8 +1,8 @@ import { PAGES_MANIFEST, SERVER_DIRECTORY } from '../../../shared/lib/constants' import { I18NProvider } from '../helpers/i18n-provider' -import { PagesRouteDefinition } from '../route-definitions/pages-route-definition' +import type { PagesRouteDefinition } from '../route-definitions/pages-route-definition' import { RouteKind } from '../route-kind' -import { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' +import type { ManifestLoader } from './helpers/manifest-loaders/manifest-loader' import { PagesRouteMatcherProvider } from './pages-route-matcher-provider' describe('PagesRouteMatcherProvider', () => { diff --git a/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.ts index 1624985de963b..a6f340656f025 100644 --- a/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/pages-route-matcher-provider.ts @@ -5,12 +5,12 @@ import { PagesLocaleRouteMatcher, PagesRouteMatcher, } from '../route-matchers/pages-route-matcher' -import { +import type { Manifest, ManifestLoader, } from './helpers/manifest-loaders/manifest-loader' import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider' -import { I18NProvider } from '../helpers/i18n-provider' +import type { I18NProvider } from '../helpers/i18n-provider' import { PagesNormalizers } from '../normalizers/built/pages' export class PagesRouteMatcherProvider extends ManifestRouteMatcherProvider { diff --git a/packages/next/src/server/future/route-matcher-providers/route-matcher-provider.ts b/packages/next/src/server/future/route-matcher-providers/route-matcher-provider.ts index 6263a9db5cf1b..d2c470126384d 100644 --- a/packages/next/src/server/future/route-matcher-providers/route-matcher-provider.ts +++ b/packages/next/src/server/future/route-matcher-providers/route-matcher-provider.ts @@ -1,4 +1,4 @@ -import { RouteMatcher } from '../route-matchers/route-matcher' +import type { RouteMatcher } from '../route-matchers/route-matcher' export interface RouteMatcherProvider { matchers(): Promise> diff --git a/packages/next/src/server/future/route-matchers/app-page-route-matcher.ts b/packages/next/src/server/future/route-matchers/app-page-route-matcher.ts index fc154acdd608e..a87216d6843db 100644 --- a/packages/next/src/server/future/route-matchers/app-page-route-matcher.ts +++ b/packages/next/src/server/future/route-matchers/app-page-route-matcher.ts @@ -1,5 +1,5 @@ import { RouteMatcher } from './route-matcher' -import { AppPageRouteDefinition } from '../route-definitions/app-page-route-definition' +import type { AppPageRouteDefinition } from '../route-definitions/app-page-route-definition' export class AppPageRouteMatcher extends RouteMatcher { public get identity(): string { diff --git a/packages/next/src/server/future/route-matchers/app-route-route-matcher.ts b/packages/next/src/server/future/route-matchers/app-route-route-matcher.ts index 0bc3720ff9d2d..2f64ea91a1f15 100644 --- a/packages/next/src/server/future/route-matchers/app-route-route-matcher.ts +++ b/packages/next/src/server/future/route-matchers/app-route-route-matcher.ts @@ -1,4 +1,4 @@ import { RouteMatcher } from './route-matcher' -import { AppRouteRouteDefinition } from '../route-definitions/app-route-route-definition' +import type { AppRouteRouteDefinition } from '../route-definitions/app-route-route-definition' export class AppRouteRouteMatcher extends RouteMatcher {} diff --git a/packages/next/src/server/future/route-matchers/pages-api-route-matcher.ts b/packages/next/src/server/future/route-matchers/pages-api-route-matcher.ts index 84cd8eec412af..d8a1611acb3ff 100644 --- a/packages/next/src/server/future/route-matchers/pages-api-route-matcher.ts +++ b/packages/next/src/server/future/route-matchers/pages-api-route-matcher.ts @@ -1,4 +1,4 @@ -import { PagesAPIRouteDefinition } from '../route-definitions/pages-api-route-definition' +import type { PagesAPIRouteDefinition } from '../route-definitions/pages-api-route-definition' import { LocaleRouteMatcher } from './locale-route-matcher' import { RouteMatcher } from './route-matcher' diff --git a/packages/next/src/server/future/route-matchers/pages-route-matcher.ts b/packages/next/src/server/future/route-matchers/pages-route-matcher.ts index aacf69d419ccb..571db79a5247a 100644 --- a/packages/next/src/server/future/route-matchers/pages-route-matcher.ts +++ b/packages/next/src/server/future/route-matchers/pages-route-matcher.ts @@ -1,4 +1,4 @@ -import { PagesRouteDefinition } from '../route-definitions/pages-route-definition' +import type { PagesRouteDefinition } from '../route-definitions/pages-route-definition' import { LocaleRouteMatcher } from './locale-route-matcher' import { RouteMatcher } from './route-matcher' diff --git a/packages/next/src/server/future/route-modules/helpers/response-handlers.ts b/packages/next/src/server/future/route-modules/helpers/response-handlers.ts index be04ee0ae2674..a45c720585be3 100644 --- a/packages/next/src/server/future/route-modules/helpers/response-handlers.ts +++ b/packages/next/src/server/future/route-modules/helpers/response-handlers.ts @@ -1,5 +1,5 @@ import { appendMutableCookies } from '../../../web/spec-extension/adapters/request-cookies' -import { ResponseCookies } from '../../../web/spec-extension/cookies' +import type { ResponseCookies } from '../../../web/spec-extension/cookies' export function handleRedirectResponse( url: string, diff --git a/packages/next/src/server/future/route-modules/pages-api/module.ts b/packages/next/src/server/future/route-modules/pages-api/module.ts index 70940f443172b..0ef835f5497b0 100644 --- a/packages/next/src/server/future/route-modules/pages-api/module.ts +++ b/packages/next/src/server/future/route-modules/pages-api/module.ts @@ -2,14 +2,11 @@ import type { IncomingMessage, ServerResponse } from 'http' import type { PagesAPIRouteDefinition } from '../../route-definitions/pages-api-route-definition' import type { PageConfig } from '../../../../../types' import type { ParsedUrlQuery } from 'querystring' +import type { __ApiPreviewProps } from '../../../api-utils' +import type { RouteModuleOptions } from '../route-module' -import { - RouteModule, - RouteModuleOptions, - type RouteModuleHandleContext, -} from '../route-module' +import { RouteModule, type RouteModuleHandleContext } from '../route-module' import { apiResolver } from '../../../api-utils/node/api-resolver' -import { __ApiPreviewProps } from '../../../api-utils' type PagesAPIHandleFn = ( req: IncomingMessage, diff --git a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts index 0d63dd3e8a709..42af26e0249ed 100644 --- a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts +++ b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts @@ -1,10 +1,10 @@ import type { OutgoingHttpHeaders } from 'http' import type { CacheHandler, CacheHandlerContext, CacheHandlerValue } from './' +import type { CacheFs } from '../../../shared/lib/utils' +import type { CachedFetchValue } from '../../response-cache' import LRUCache from 'next/dist/compiled/lru-cache' -import { CacheFs } from '../../../shared/lib/utils' import path from '../../../shared/lib/isomorphic/path' -import { CachedFetchValue } from '../../response-cache' import { NEXT_CACHE_TAGS_HEADER } from '../../../lib/constants' type FileSystemCacheContext = Omit< diff --git a/packages/next/src/server/lib/incremental-cache/index.ts b/packages/next/src/server/lib/incremental-cache/index.ts index 3032aa685300b..91e10c618af45 100644 --- a/packages/next/src/server/lib/incremental-cache/index.ts +++ b/packages/next/src/server/lib/incremental-cache/index.ts @@ -1,16 +1,16 @@ import type { CacheFs } from '../../../shared/lib/utils' - +import type { PrerenderManifest } from '../../../build' +import type { + IncrementalCacheValue, + IncrementalCacheEntry, +} from '../../response-cache' import FetchCache from './fetch-cache' import FileSystemCache from './file-system-cache' -import { PrerenderManifest } from '../../../build' import path from '../../../shared/lib/isomorphic/path' import { encodeText } from '../../stream-utils/encode-decode' import { encode } from '../../../shared/lib/base64-arraybuffer' import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path' -import { - IncrementalCacheValue, - IncrementalCacheEntry, -} from '../../response-cache' + import { CACHE_ONE_YEAR, NEXT_CACHE_REVALIDATED_TAGS_HEADER, diff --git a/packages/next/src/server/lib/render-server.ts b/packages/next/src/server/lib/render-server.ts index 21c2a6ae9f6fc..cf0603588e7d4 100644 --- a/packages/next/src/server/lib/render-server.ts +++ b/packages/next/src/server/lib/render-server.ts @@ -1,8 +1,8 @@ import type { NextServer, RequestHandler } from '../next' import type { DevBundlerService } from './dev-bundler-service' +import type { PropagateToWorkersField } from './router-utils/types' import next from '../next' -import { PropagateToWorkersField } from './router-utils/types' let initializations: Record< string, diff --git a/packages/next/src/server/lib/router-server.ts b/packages/next/src/server/lib/router-server.ts index b1e8e7487fe20..8774e0913f3bb 100644 --- a/packages/next/src/server/lib/router-server.ts +++ b/packages/next/src/server/lib/router-server.ts @@ -1,7 +1,7 @@ // this must come first as it includes require hooks import type { WorkerRequestHandler, WorkerUpgradeHandler } from './types' import type { DevBundler } from './router-utils/setup-dev-bundler' - +import type { NextUrlWithParsedQuery } from '../request-meta' // This is required before other imports to ensure the require hook is setup. import '../node-polyfill-fetch' import '../node-environment' @@ -20,7 +20,7 @@ import { setupFsCheck } from './router-utils/filesystem' import { proxyRequest } from './router-utils/proxy-request' import { isAbortError, pipeReadable } from '../pipe-readable' import { getResolveRoutes } from './router-utils/resolve-routes' -import { NextUrlWithParsedQuery, getRequestMeta } from '../request-meta' +import { getRequestMeta } from '../request-meta' import { pathHasPrefix } from '../../shared/lib/router/utils/path-has-prefix' import { removePathPrefix } from '../../shared/lib/router/utils/remove-path-prefix' import setupCompression from 'next/dist/compiled/compression' diff --git a/packages/next/src/server/lib/router-utils/filesystem.ts b/packages/next/src/server/lib/router-utils/filesystem.ts index dfea25dad2561..6986a891509c3 100644 --- a/packages/next/src/server/lib/router-utils/filesystem.ts +++ b/packages/next/src/server/lib/router-utils/filesystem.ts @@ -5,6 +5,9 @@ import type { } from '../../../build' import type { NextConfigComplete } from '../../config-shared' import type { MiddlewareManifest } from '../../../build/webpack/plugins/middleware-plugin' +import type { UnwrapPromise } from '../../../lib/coalesced-function' +import type { PatchMatcher } from '../../../shared/lib/router/utils/path-match' +import type { MiddlewareRouteMatch } from '../../../shared/lib/router/utils/middleware-route-matcher' import path from 'path' import fs from 'fs/promises' @@ -13,25 +16,18 @@ import setupDebug from 'next/dist/compiled/debug' import LRUCache from 'next/dist/compiled/lru-cache' import loadCustomRoutes from '../../../lib/load-custom-routes' import { modifyRouteRegex } from '../../../lib/redirect-status' -import { UnwrapPromise } from '../../../lib/coalesced-function' import { FileType, fileExists } from '../../../lib/file-exists' import { recursiveReadDir } from '../../../lib/recursive-readdir' import { isDynamicRoute } from '../../../shared/lib/router/utils' import { escapeStringRegexp } from '../../../shared/lib/escape-regexp' -import { - PatchMatcher, - getPathMatch, -} from '../../../shared/lib/router/utils/path-match' +import { getPathMatch } from '../../../shared/lib/router/utils/path-match' import { getRouteRegex } from '../../../shared/lib/router/utils/route-regex' import { getRouteMatcher } from '../../../shared/lib/router/utils/route-matcher' import { pathHasPrefix } from '../../../shared/lib/router/utils/path-has-prefix' import { normalizeLocalePath } from '../../../shared/lib/i18n/normalize-locale-path' import { removePathPrefix } from '../../../shared/lib/router/utils/remove-path-prefix' -import { - MiddlewareRouteMatch, - getMiddlewareRouteMatcher, -} from '../../../shared/lib/router/utils/middleware-route-matcher' +import { getMiddlewareRouteMatcher } from '../../../shared/lib/router/utils/middleware-route-matcher' import { APP_PATH_ROUTES_MANIFEST, diff --git a/packages/next/src/server/lib/router-utils/resolve-routes.ts b/packages/next/src/server/lib/router-utils/resolve-routes.ts index c2f07cd06a17c..287041bf32835 100644 --- a/packages/next/src/server/lib/router-utils/resolve-routes.ts +++ b/packages/next/src/server/lib/router-utils/resolve-routes.ts @@ -4,18 +4,19 @@ import type { IncomingMessage, ServerResponse } from 'http' import type { NextConfigComplete } from '../../config-shared' import type { RenderServer, initialize } from '../router-server' import type { PatchMatcher } from '../../../shared/lib/router/utils/path-match' +import type { Redirect } from '../../../../types' +import type { Header } from '../../../lib/load-custom-routes' +import type { UnwrapPromise } from '../../../lib/coalesced-function' +import type { NextUrlWithParsedQuery } from '../../request-meta' import url from 'url' -import { Redirect } from '../../../../types' import setupDebug from 'next/dist/compiled/debug' import { getCloneableBody } from '../../body-streams' -import { Header } from '../../../lib/load-custom-routes' import { stringifyQuery } from '../../server-route-utils' import { formatHostname } from '../format-hostname' import { toNodeOutgoingHttpHeaders } from '../../web/utils' import { isAbortError } from '../../pipe-readable' import { getHostname } from '../../../shared/lib/get-hostname' -import { UnwrapPromise } from '../../../lib/coalesced-function' import { getRedirectStatus } from '../../../lib/redirect-status' import { normalizeRepeatedSlashes } from '../../../shared/lib/utils' import { relativizeURL } from '../../../shared/lib/router/utils/relativize-url' @@ -25,7 +26,7 @@ import { detectDomainLocale } from '../../../shared/lib/i18n/detect-domain-local import { normalizeLocalePath } from '../../../shared/lib/i18n/normalize-locale-path' import { removePathPrefix } from '../../../shared/lib/router/utils/remove-path-prefix' -import { NextUrlWithParsedQuery, addRequestMeta } from '../../request-meta' +import { addRequestMeta } from '../../request-meta' import { compileNonPath, matchHas, diff --git a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts index 5ba81e901a105..36d4700f1716c 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts @@ -1,17 +1,32 @@ import type { NextConfigComplete } from '../../config-shared' -import { +import type { Endpoint, Route, TurbopackResult, WrittenEndpoint, ServerClientChange, - ServerClientChangeType, Issue, - createDefineEnv, } from '../../../build/swc' import type { Socket } from 'net' -import ws from 'next/dist/compiled/ws' +import type { FilesystemDynamicRoute } from './filesystem' +import type { UnwrapPromise } from '../../../lib/coalesced-function' +import type { MiddlewareMatcher } from '../../../build/analysis/get-page-static-info' +import type { OutputState } from '../../../build/output/store' +import type { MiddlewareRouteMatch } from '../../../shared/lib/router/utils/middleware-route-matcher' +import type { BuildManifest } from '../../get-page-files' +import type { PagesManifest } from '../../../build/webpack/plugins/pages-manifest-plugin' +import type { AppBuildManifest } from '../../../build/webpack/plugins/app-build-manifest-plugin' +import type { PropagateToWorkersField } from './types' +import type { MiddlewareManifest } from '../../../build/webpack/plugins/middleware-plugin' +import type { + HMR_ACTION_TYPES, + NextJsHotReloaderInterface, + ReloadPageAction, + TurbopackConnectedAction, +} from '../../dev/hot-reloader-types' +import ws from 'next/dist/compiled/ws' +import { ServerClientChangeType, createDefineEnv } from '../../../build/swc' import fs from 'fs' import url from 'url' import path from 'path' @@ -20,37 +35,35 @@ import Watchpack from 'watchpack' import { loadEnvConfig } from '@next/env' import isError from '../../../lib/is-error' import findUp from 'next/dist/compiled/find-up' -import { FilesystemDynamicRoute, buildCustomRoute } from './filesystem' +import { buildCustomRoute } from './filesystem' import * as Log from '../../../build/output/log' import HotReloader, { matchNextPageBundleRequest, } from '../../dev/hot-reloader-webpack' import { setGlobal } from '../../../trace/shared' -import { Telemetry } from '../../../telemetry/storage' -import { IncomingMessage, ServerResponse } from 'http' +import type { Telemetry } from '../../../telemetry/storage' +import type { IncomingMessage, ServerResponse } from 'http' import loadJsConfig from '../../../build/load-jsconfig' import { createValidFileMatcher } from '../find-page-file' import { eventCliSession } from '../../../telemetry/events' import { getDefineEnv } from '../../../build/webpack/plugins/define-env-plugin' import { logAppDirError } from '../../dev/log-app-dir-error' -import { UnwrapPromise } from '../../../lib/coalesced-function' import { getSortedRoutes } from '../../../shared/lib/router/utils' import { getStaticInfoIncludingLayouts, sortByPageExts, } from '../../../build/entries' -import { verifyTypeScriptSetup } from '../../../lib/verifyTypeScriptSetup' +import { verifyTypeScriptSetup } from '../../../lib/verify-typescript-setup' import { verifyPartytownSetup } from '../../../lib/verify-partytown-setup' import { getRouteRegex } from '../../../shared/lib/router/utils/route-regex' import { normalizeAppPath } from '../../../shared/lib/router/utils/app-paths' import { buildDataRoute } from './build-data-route' -import { MiddlewareMatcher } from '../../../build/analysis/get-page-static-info' import { getRouteMatcher } from '../../../shared/lib/router/utils/route-matcher' import { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep' import { createClientRouterFilter } from '../../../lib/create-client-router-filter' import { absolutePathToPage } from '../../../shared/lib/page-path/absolute-path-to-page' import { generateInterceptionRoutesRewrites } from '../../../lib/generate-interception-routes-rewrites' -import { OutputState, store as consoleStore } from '../../../build/output/store' +import { store as consoleStore } from '../../../build/output/store' import { APP_BUILD_MANIFEST, @@ -67,10 +80,7 @@ import { SERVER_REFERENCE_MANIFEST, } from '../../../shared/lib/constants' -import { - MiddlewareRouteMatch, - getMiddlewareRouteMatcher, -} from '../../../shared/lib/router/utils/middleware-route-matcher' +import { getMiddlewareRouteMatcher } from '../../../shared/lib/router/utils/middleware-route-matcher' import { NextBuildContext } from '../../../build/build-context' import { @@ -86,24 +96,13 @@ import { getSourceById, parseStack, } from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' -import { BuildManifest } from '../../get-page-files' import { mkdir, readFile, writeFile, rename, unlink } from 'fs/promises' -import { PagesManifest } from '../../../build/webpack/plugins/pages-manifest-plugin' -import { AppBuildManifest } from '../../../build/webpack/plugins/app-build-manifest-plugin' import { PageNotFoundError } from '../../../shared/lib/utils' import { srcEmptySsgManifest } from '../../../build/webpack/plugins/build-manifest-plugin' -import { PropagateToWorkersField } from './types' -import { MiddlewareManifest } from '../../../build/webpack/plugins/middleware-plugin' import { devPageFiles } from '../../../build/webpack/plugins/next-types-plugin/shared' import type { LazyRenderServerInstance } from '../router-server' import { pathToRegexp } from 'next/dist/compiled/path-to-regexp' -import { - HMR_ACTIONS_SENT_TO_BROWSER, - HMR_ACTION_TYPES, - NextJsHotReloaderInterface, - ReloadPageAction, - TurbopackConnectedAction, -} from '../../dev/hot-reloader-types' +import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../dev/hot-reloader-types' import type { Update as TurbopackUpdate } from '../../../build/swc' import { debounce } from '../../utils' import { diff --git a/packages/next/src/server/lib/start-server.ts b/packages/next/src/server/lib/start-server.ts index 6b8eee5963182..de72c76a34dbc 100644 --- a/packages/next/src/server/lib/start-server.ts +++ b/packages/next/src/server/lib/start-server.ts @@ -7,7 +7,7 @@ import '../require-hook' import type { IncomingMessage, ServerResponse } from 'http' import type { SelfSignedCertificate } from '../../lib/mkcert' -import { type WorkerRequestHandler, type WorkerUpgradeHandler } from './types' +import type { WorkerRequestHandler, WorkerUpgradeHandler } from './types' import fs from 'fs' import path from 'path' diff --git a/packages/next/src/server/lib/trace/constants.ts b/packages/next/src/server/lib/trace/constants.ts index 1b45358bdf8ed..a5743c9f59249 100644 --- a/packages/next/src/server/lib/trace/constants.ts +++ b/packages/next/src/server/lib/trace/constants.ts @@ -133,7 +133,6 @@ export { NextServerSpan, NextNodeServerSpan, StartServerSpan, - SpanTypes, RenderSpan, RouterSpan, AppRenderSpan, @@ -141,3 +140,5 @@ export { AppRouteRouteHandlersSpan, ResolveMetadataSpan, } + +export type { SpanTypes } diff --git a/packages/next/src/server/lib/trace/tracer.ts b/packages/next/src/server/lib/trace/tracer.ts index 7d2184cb48e33..60632b318afee 100644 --- a/packages/next/src/server/lib/trace/tracer.ts +++ b/packages/next/src/server/lib/trace/tracer.ts @@ -1,4 +1,5 @@ -import { NextVanillaSpanAllowlist, SpanTypes } from './constants' +import type { SpanTypes } from './constants' +import { NextVanillaSpanAllowlist } from './constants' import type { ContextAPI, @@ -362,13 +363,5 @@ const getTracer = (() => { return () => tracer })() -export { - NextTracer, - getTracer, - Span, - SpanOptions, - ContextAPI, - SpanStatusCode, - TracerSpanOptions, - SpanKind, -} +export { getTracer, SpanStatusCode, SpanKind } +export type { NextTracer, Span, SpanOptions, ContextAPI, TracerSpanOptions } diff --git a/packages/next/src/server/lib/types.ts b/packages/next/src/server/lib/types.ts index 58ed0e201e4bf..f329b57c06b1f 100644 --- a/packages/next/src/server/lib/types.ts +++ b/packages/next/src/server/lib/types.ts @@ -1,6 +1,6 @@ import type { IncomingMessage, ServerResponse } from 'http' -import { Duplex } from 'stream' +import type { Duplex } from 'stream' export type WorkerRequestHandler = ( req: IncomingMessage, diff --git a/packages/next/src/server/load-components.ts b/packages/next/src/server/load-components.ts index 042b3788e989f..63e563b13a2d3 100644 --- a/packages/next/src/server/load-components.ts +++ b/packages/next/src/server/load-components.ts @@ -11,6 +11,7 @@ import type { GetStaticProps, } from 'next/types' import type { RouteModule } from './future/route-modules/route-module' +import type { BuildManifest } from './get-page-files' import { BUILD_MANIFEST, @@ -20,7 +21,6 @@ import { } from '../shared/lib/constants' import { join } from 'path' import { requirePage } from './require' -import { BuildManifest } from './get-page-files' import { interopDefault } from '../lib/interop-default' import { getTracer } from './lib/trace/tracer' import { LoadComponentsSpan } from './lib/trace/constants' diff --git a/packages/next/src/server/load-default-error-components.ts b/packages/next/src/server/load-default-error-components.ts index b6d0516dbb2b9..bd5664f4dbb5b 100644 --- a/packages/next/src/server/load-default-error-components.ts +++ b/packages/next/src/server/load-default-error-components.ts @@ -11,10 +11,10 @@ import type { GetStaticProps, } from 'next/types' import type { RouteModule } from './future/route-modules/route-module' +import type { BuildManifest } from './get-page-files' import { BUILD_MANIFEST } from '../shared/lib/constants' import { join } from 'path' -import { BuildManifest } from './get-page-files' import { interopDefault } from '../lib/interop-default' import { getTracer } from './lib/trace/tracer' import { LoadComponentsSpan } from './lib/trace/constants' diff --git a/packages/next/src/server/next-server.ts b/packages/next/src/server/next-server.ts index ead7b51bc8fed..a550f41fd1ddc 100644 --- a/packages/next/src/server/next-server.ts +++ b/packages/next/src/server/next-server.ts @@ -7,8 +7,8 @@ import './node-polyfill-crypto' import '../lib/polyfill-promise-with-resolvers' import type { TLSSocket } from 'tls' +import type { CacheFs } from '../shared/lib/utils' import { - CacheFs, DecodeError, PageNotFoundError, MiddlewareNotFoundError, @@ -17,20 +17,18 @@ import type { MiddlewareManifest } from '../build/webpack/plugins/middleware-plu import type RenderResult from './render-result' import type { FetchEventResult } from './web/types' import type { PrerenderManifest } from '../build' -import { BaseNextRequest, BaseNextResponse } from './base-http' +import type { BaseNextRequest, BaseNextResponse } from './base-http' import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin' import type { PayloadOptions } from './send-payload' import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta' -import { - getRouteMatcher, - Params, -} from '../shared/lib/router/utils/route-matcher' +import { getRouteMatcher } from '../shared/lib/router/utils/route-matcher' +import type { Params } from '../shared/lib/router/utils/route-matcher' import type { MiddlewareRouteMatch } from '../shared/lib/router/utils/middleware-route-matcher' import type { RouteMatch } from './future/route-matches/route-match' import fs from 'fs' import { join, resolve, isAbsolute } from 'path' -import { IncomingMessage, ServerResponse } from 'http' +import type { IncomingMessage, ServerResponse } from 'http' import type { PagesAPIRouteModule } from './future/route-modules/pages-api/module' import { addRequestMeta, getRequestMeta } from './request-meta' import { @@ -47,28 +45,30 @@ import { INTERNAL_HEADERS, } from '../shared/lib/constants' import { findDir } from '../lib/find-pages-dir' -import { UrlWithParsedQuery } from 'url' +import type { UrlWithParsedQuery } from 'url' import { NodeNextRequest, NodeNextResponse } from './base-http/node' import { sendRenderResult } from './send-payload' -import { ParsedUrlQuery } from 'querystring' -import { ParsedUrl, parseUrl } from '../shared/lib/router/utils/parse-url' +import type { ParsedUrlQuery } from 'querystring' +import type { ParsedUrl } from '../shared/lib/router/utils/parse-url' +import { parseUrl } from '../shared/lib/router/utils/parse-url' import * as Log from '../build/output/log' -import BaseServer, { +import type { Options, FindComponentsResult, MiddlewareRoutingItem, - NoFallbackError, RequestContext, NormalizedRouteManifest, LoadedRenderOpts, } from './base-server' +import BaseServer, { NoFallbackError } from './base-server' import { getMaybePagePath, getPagePath, requireFontManifest } from './require' import { denormalizePagePath } from '../shared/lib/page-path/denormalize-page-path' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' -import { LoadComponentsReturnType, loadComponents } from './load-components' +import { loadComponents } from './load-components' +import type { LoadComponentsReturnType } from './load-components' import isError, { getProperError } from '../lib/is-error' -import { FontManifest } from './font-utils' +import type { FontManifest } from './font-utils' import { splitCookiesString, toNodeOutgoingHttpHeaders } from './web/utils' import { getMiddlewareRouteMatcher } from '../shared/lib/router/utils/middleware-route-matcher' import { loadEnvConfig } from '@next/env' @@ -83,11 +83,9 @@ import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' import { setHttpClientAndAgentOptions } from './setup-http-agent-env' -import { - PagesAPIRouteMatch, - isPagesAPIRouteMatch, -} from './future/route-matches/pages-api-route-match' -import { MatchOptions } from './future/route-matcher-managers/route-matcher-manager' +import { isPagesAPIRouteMatch } from './future/route-matches/pages-api-route-match' +import type { PagesAPIRouteMatch } from './future/route-matches/pages-api-route-match' +import type { MatchOptions } from './future/route-matcher-managers/route-matcher-manager' import { INSTRUMENTATION_HOOK_FILENAME } from '../lib/constants' import { getTracer } from './lib/trace/tracer' import { NextNodeServerSpan } from './lib/trace/constants' diff --git a/packages/next/src/server/next.ts b/packages/next/src/server/next.ts index 061b7cfa255f9..360ccf32695b7 100644 --- a/packages/next/src/server/next.ts +++ b/packages/next/src/server/next.ts @@ -13,7 +13,7 @@ import './require-hook' import './node-polyfill-fetch' import './node-polyfill-crypto' -import { default as Server } from './next-server' +import type { default as Server } from './next-server' import * as log from '../build/output/log' import loadConfig from './config' import path, { resolve } from 'path' diff --git a/packages/next/src/server/render-result.ts b/packages/next/src/server/render-result.ts index 3d66369ec4fe8..0e8907c866c35 100644 --- a/packages/next/src/server/render-result.ts +++ b/packages/next/src/server/render-result.ts @@ -1,5 +1,6 @@ -import { StaticGenerationStore } from '../client/components/static-generation-async-storage.external' -import { pipeReadable, PipeTarget } from './pipe-readable' +import type { StaticGenerationStore } from '../client/components/static-generation-async-storage.external' +import type { PipeTarget } from './pipe-readable' +import { pipeReadable } from './pipe-readable' type ContentTypeOption = string | undefined diff --git a/packages/next/src/server/render.tsx b/packages/next/src/server/render.tsx index a67ba29583d5b..d813406697942 100644 --- a/packages/next/src/server/render.tsx +++ b/packages/next/src/server/render.tsx @@ -35,7 +35,8 @@ import type { ReactReadableStream } from './stream-utils/node-web-streams-helper import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin' import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin' import type { PagesModule } from './future/route-modules/pages/module' - +import type { ComponentsEnhancer } from '../shared/lib/utils' +import type { NextParsedUrlQuery } from './request-meta' import React from 'react' import ReactDOMServer from 'react-dom/server.browser' import { StyleRegistry, createStyleRegistry } from 'styled-jsx' @@ -50,8 +51,8 @@ import { UNSTABLE_REVALIDATE_RENAME_ERROR, CACHE_ONE_YEAR, } from '../lib/constants' +import type { COMPILER_NAMES } from '../shared/lib/constants' import { - COMPILER_NAMES, NEXT_BUILTIN_DOCUMENT, SERVER_PROPS_ID, STATIC_PROPS_ID, @@ -67,7 +68,6 @@ import { LoadableContext } from '../shared/lib/loadable-context.shared-runtime' import { RouterContext } from '../shared/lib/router-context.shared-runtime' import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic' import { - ComponentsEnhancer, getDisplayName, isResSent, loadGetInitialProps, @@ -75,7 +75,7 @@ import { import { HtmlContext } from '../shared/lib/html-context.shared-runtime' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' import { denormalizePagePath } from '../shared/lib/page-path/denormalize-page-path' -import { getRequestMeta, NextParsedUrlQuery } from './request-meta' +import { getRequestMeta } from './request-meta' import { allowedStatusCodes, getRedirectStatus } from '../lib/redirect-status' import RenderResult, { type RenderResultMetadata } from './render-result' import isError from '../lib/is-error' diff --git a/packages/next/src/server/request-meta.ts b/packages/next/src/server/request-meta.ts index 6c331393d2bd6..a2fa7372e3d00 100644 --- a/packages/next/src/server/request-meta.ts +++ b/packages/next/src/server/request-meta.ts @@ -4,8 +4,8 @@ import type { ParsedUrlQuery } from 'querystring' import type { UrlWithParsedQuery } from 'url' import type { BaseNextRequest } from './base-http' import type { CloneableBody } from './body-streams' -import { RouteMatch } from './future/route-matches/route-match' -import { NEXT_RSC_UNION_QUERY } from '../client/components/app-router-headers' +import type { RouteMatch } from './future/route-matches/route-match' +import type { NEXT_RSC_UNION_QUERY } from '../client/components/app-router-headers' // FIXME: (wyattjoh) this is a temporary solution to allow us to pass data between bundled modules export const NEXT_REQUEST_META = Symbol.for('NextInternalRequestMeta') diff --git a/packages/next/src/server/send-payload/index.ts b/packages/next/src/server/send-payload/index.ts index 50d4f1f1dac98..07744acdbf607 100644 --- a/packages/next/src/server/send-payload/index.ts +++ b/packages/next/src/server/send-payload/index.ts @@ -3,7 +3,7 @@ import type { IncomingMessage, ServerResponse } from 'http' import { isResSent } from '../../shared/lib/utils' import { generateETag } from '../lib/etag' import fresh from 'next/dist/compiled/fresh' -import RenderResult from '../render-result' +import type RenderResult from '../render-result' import { setRevalidateHeaders } from './revalidate-headers' import { RSC_CONTENT_TYPE_HEADER } from '../../client/components/app-router-headers' diff --git a/packages/next/src/server/serve-static.ts b/packages/next/src/server/serve-static.ts index be7dce8992a97..c71a6785d8acc 100644 --- a/packages/next/src/server/serve-static.ts +++ b/packages/next/src/server/serve-static.ts @@ -1,4 +1,4 @@ -import { IncomingMessage, ServerResponse } from 'http' +import type { IncomingMessage, ServerResponse } from 'http' import send from 'next/dist/compiled/send' // TODO: Remove this once "send" has updated the "mime", or next.js use custom version of "mime" diff --git a/packages/next/src/server/server-utils.ts b/packages/next/src/server/server-utils.ts index 4e873355872f3..495e7ff3c6e08 100644 --- a/packages/next/src/server/server-utils.ts +++ b/packages/next/src/server/server-utils.ts @@ -3,8 +3,9 @@ import type { RouteMatchFn } from '../shared/lib/router/utils/route-matcher' import type { NextConfig } from './config' import type { BaseNextRequest } from './base-http' import type { ParsedUrlQuery } from 'querystring' +import type { UrlWithParsedQuery } from 'url' -import { format as formatUrl, UrlWithParsedQuery, parse as parseUrl } from 'url' +import { format as formatUrl, parse as parseUrl } from 'url' import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path' import { getPathMatch } from '../shared/lib/router/utils/path-match' import { getNamedRouteRegex } from '../shared/lib/router/utils/route-regex' diff --git a/packages/next/src/server/setup-http-agent-env.ts b/packages/next/src/server/setup-http-agent-env.ts index aa93e7e95b339..6c4deea8c2a46 100644 --- a/packages/next/src/server/setup-http-agent-env.ts +++ b/packages/next/src/server/setup-http-agent-env.ts @@ -1,6 +1,6 @@ +import type { NextConfig } from '../../types' import { Agent as HttpAgent } from 'http' import { Agent as HttpsAgent } from 'https' -import { NextConfig } from '../../types' export function setHttpClientAndAgentOptions(config: { httpAgentOptions?: NextConfig['httpAgentOptions'] diff --git a/packages/next/src/server/web-server.ts b/packages/next/src/server/web-server.ts index 3c8c0f7aaef13..6ba5e5b2108c7 100644 --- a/packages/next/src/server/web-server.ts +++ b/packages/next/src/server/web-server.ts @@ -6,15 +6,15 @@ import type { PayloadOptions } from './send-payload' import type { LoadComponentsReturnType } from './load-components' import type { BaseNextRequest, BaseNextResponse } from './base-http' import type { PrerenderManifest } from '../build' - -import { byteLength } from './api-utils/web' -import BaseServer, { +import type { LoadedRenderOpts, MiddlewareRoutingItem, - NoFallbackError, NormalizedRouteManifest, Options, } from './base-server' + +import { byteLength } from './api-utils/web' +import BaseServer, { NoFallbackError } from './base-server' import { generateETag } from './lib/etag' import { addRequestMeta } from './request-meta' import WebResponseCache from './response-cache/web' diff --git a/packages/next/src/server/web/adapter.ts b/packages/next/src/server/web/adapter.ts index 7cb7f069928a2..d14a8486fae91 100644 --- a/packages/next/src/server/web/adapter.ts +++ b/packages/next/src/server/web/adapter.ts @@ -1,5 +1,6 @@ import type { NextMiddleware, RequestData, FetchEventResult } from './types' import type { RequestInit } from './spec-extension/request' +import type { PrerenderManifest } from '../../build' import { PageSignatureError } from './error' import { fromNodeOutgoingHttpHeaders } from './utils' import { NextFetchEvent } from './spec-extension/fetch-event' @@ -19,7 +20,6 @@ import { NEXT_QUERY_PARAM_PREFIX } from '../../lib/constants' import { ensureInstrumentationRegistered } from './globals' import { RequestAsyncStorageWrapper } from '../async-storage/request-async-storage-wrapper' import { requestAsyncStorage } from '../../client/components/request-async-storage.external' -import { PrerenderManifest } from '../../build' class NextRequestHint extends NextRequest { sourcePage: string diff --git a/packages/next/src/server/web/edge-route-module-wrapper.ts b/packages/next/src/server/web/edge-route-module-wrapper.ts index 3e39c5473562a..72d1010da4596 100644 --- a/packages/next/src/server/web/edge-route-module-wrapper.ts +++ b/packages/next/src/server/web/edge-route-module-wrapper.ts @@ -12,7 +12,7 @@ import { IncrementalCache } from '../lib/incremental-cache' import { RouteMatcher } from '../future/route-matchers/route-matcher' import { removeTrailingSlash } from '../../shared/lib/router/utils/remove-trailing-slash' import { removePathPrefix } from '../../shared/lib/router/utils/remove-path-prefix' -import { NextFetchEvent } from './spec-extension/fetch-event' +import type { NextFetchEvent } from './spec-extension/fetch-event' type WrapOptions = Partial> diff --git a/packages/next/src/server/web/sandbox/context.ts b/packages/next/src/server/web/sandbox/context.ts index 8afadb19a7313..11e04bf577304 100644 --- a/packages/next/src/server/web/sandbox/context.ts +++ b/packages/next/src/server/web/sandbox/context.ts @@ -1,5 +1,10 @@ -import { AsyncLocalStorage } from 'async_hooks' import type { AssetBinding } from '../../../build/webpack/loaders/get-module-build-info' +import type { + EdgeFunctionDefinition, + SUPPORTED_NATIVE_MODULES, +} from '../../../build/webpack/plugins/middleware-plugin' +import type { UnwrapPromise } from '../../../lib/coalesced-function' +import { AsyncLocalStorage } from 'async_hooks' import { decorateServerError, getServerError, @@ -13,11 +18,6 @@ import { readFileSync, promises as fs } from 'fs' import { validateURL } from '../utils' import { pick } from '../../../lib/pick' import { fetchInlineAsset } from './fetch-inline-assets' -import type { - EdgeFunctionDefinition, - SUPPORTED_NATIVE_MODULES, -} from '../../../build/webpack/plugins/middleware-plugin' -import { UnwrapPromise } from '../../../lib/coalesced-function' import { runInContext } from 'vm' import BufferImplementation from 'node:buffer' import EventsImplementation from 'node:events' diff --git a/packages/next/src/server/web/sandbox/sandbox.ts b/packages/next/src/server/web/sandbox/sandbox.ts index b894dc6207207..fa89282a63c7e 100644 --- a/packages/next/src/server/web/sandbox/sandbox.ts +++ b/packages/next/src/server/web/sandbox/sandbox.ts @@ -1,9 +1,9 @@ import type { NodejsRequestData, FetchEventResult, RequestData } from '../types' +import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin' +import type { EdgeRuntime } from 'next/dist/compiled/edge-runtime' import { getServerError } from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' import { getModuleContext } from './context' -import { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin' import { requestToBodyStream } from '../../body-streams' -import type { EdgeRuntime } from 'next/dist/compiled/edge-runtime' import { NEXT_RSC_UNION_QUERY } from '../../../client/components/app-router-headers' export const ErrorSource = Symbol('SandboxError') diff --git a/packages/next/src/server/web/spec-extension/adapters/request-cookies.ts b/packages/next/src/server/web/spec-extension/adapters/request-cookies.ts index b8f14648cbb57..f029a4f160963 100644 --- a/packages/next/src/server/web/spec-extension/adapters/request-cookies.ts +++ b/packages/next/src/server/web/spec-extension/adapters/request-cookies.ts @@ -1,5 +1,5 @@ import type { RequestCookies } from '../cookies' -import { StaticGenerationStore } from '../../../../client/components/static-generation-async-storage.external' +import type { StaticGenerationStore } from '../../../../client/components/static-generation-async-storage.external' import { ResponseCookies } from '../cookies' import { ReflectAdapter } from './reflect' diff --git a/packages/next/src/server/web/spec-extension/fetch-event.ts b/packages/next/src/server/web/spec-extension/fetch-event.ts index cae460cd08d2a..8f7776ac00dea 100644 --- a/packages/next/src/server/web/spec-extension/fetch-event.ts +++ b/packages/next/src/server/web/spec-extension/fetch-event.ts @@ -1,5 +1,5 @@ import { PageSignatureError } from '../error' -import { NextRequest } from './request' +import type { NextRequest } from './request' const responseSymbol = Symbol('response') const passThroughSymbol = Symbol('passThrough') diff --git a/packages/next/src/server/web/spec-extension/revalidate-tag.ts b/packages/next/src/server/web/spec-extension/revalidate-tag.ts index 7c7bff8c2f784..620545987eae6 100644 --- a/packages/next/src/server/web/spec-extension/revalidate-tag.ts +++ b/packages/next/src/server/web/spec-extension/revalidate-tag.ts @@ -1,4 +1,4 @@ -import { +import type { StaticGenerationAsyncStorage, StaticGenerationStore, } from '../../../client/components/static-generation-async-storage.external' diff --git a/packages/next/src/server/web/spec-extension/unstable-cache.ts b/packages/next/src/server/web/spec-extension/unstable-cache.ts index 34dcab8158e0a..27d2e5c8f6dcb 100644 --- a/packages/next/src/server/web/spec-extension/unstable-cache.ts +++ b/packages/next/src/server/web/spec-extension/unstable-cache.ts @@ -1,8 +1,8 @@ -import { +import type { StaticGenerationStore, - staticGenerationAsyncStorage as _staticGenerationAsyncStorage, StaticGenerationAsyncStorage, } from '../../../client/components/static-generation-async-storage.external' +import { staticGenerationAsyncStorage as _staticGenerationAsyncStorage } from '../../../client/components/static-generation-async-storage.external' import { CACHE_ONE_YEAR } from '../../../lib/constants' import { addImplicitTags, validateTags } from '../../lib/patch-fetch' diff --git a/packages/next/src/shared/lib/image-config-context.shared-runtime.ts b/packages/next/src/shared/lib/image-config-context.shared-runtime.ts index a27c0446eda90..d7c3409da7cf2 100644 --- a/packages/next/src/shared/lib/image-config-context.shared-runtime.ts +++ b/packages/next/src/shared/lib/image-config-context.shared-runtime.ts @@ -1,5 +1,6 @@ import React from 'react' -import { ImageConfigComplete, imageConfigDefault } from './image-config' +import type { ImageConfigComplete } from './image-config' +import { imageConfigDefault } from './image-config' export const ImageConfigContext = React.createContext(imageConfigDefault) diff --git a/packages/next/src/shared/lib/image-external.tsx b/packages/next/src/shared/lib/image-external.tsx index e5dd817032247..46ccdb7df8f40 100644 --- a/packages/next/src/shared/lib/image-external.tsx +++ b/packages/next/src/shared/lib/image-external.tsx @@ -8,7 +8,7 @@ import { Image } from '../../client/image-component' // @ts-ignore - This is replaced by webpack alias import defaultLoader from 'next/dist/shared/lib/image-loader' -const unstable_getImgProps = (imgProps: ImageProps) => { +export const unstable_getImgProps = (imgProps: ImageProps) => { warnOnce( 'Warning: unstable_getImgProps() is experimental and may change or be removed at any time. Use at your own risk.' ) @@ -27,10 +27,4 @@ const unstable_getImgProps = (imgProps: ImageProps) => { export default Image -export { - ImageProps, - ImageLoaderProps, - ImageLoader, - StaticImageData, - unstable_getImgProps, -} +export type { ImageProps, ImageLoaderProps, ImageLoader, StaticImageData } diff --git a/packages/next/src/shared/lib/lazy-dynamic/dynamic-no-ssr.tsx b/packages/next/src/shared/lib/lazy-dynamic/dynamic-no-ssr.tsx index e5c1c1e22b2c6..31fa844911507 100644 --- a/packages/next/src/shared/lib/lazy-dynamic/dynamic-no-ssr.tsx +++ b/packages/next/src/shared/lib/lazy-dynamic/dynamic-no-ssr.tsx @@ -1,6 +1,6 @@ 'use client' -import React from 'react' +import type React from 'react' import { NEXT_DYNAMIC_NO_SSR_CODE } from './no-ssr-error' export function suspense() { diff --git a/packages/next/src/shared/lib/router/adapters.test.tsx b/packages/next/src/shared/lib/router/adapters.test.tsx index fa8e48f2fc088..1120d008dcc1d 100644 --- a/packages/next/src/shared/lib/router/adapters.test.tsx +++ b/packages/next/src/shared/lib/router/adapters.test.tsx @@ -1,5 +1,5 @@ +import type { NextRouter } from './router' import { adaptForAppRouterInstance } from './adapters' -import { NextRouter } from './router' describe('adaptForAppRouterInstance', () => { beforeEach(() => jest.resetAllMocks()) diff --git a/packages/next/src/shared/lib/router/adapters.tsx b/packages/next/src/shared/lib/router/adapters.tsx index 8f2878222439e..ad6b6e04eff8a 100644 --- a/packages/next/src/shared/lib/router/adapters.tsx +++ b/packages/next/src/shared/lib/router/adapters.tsx @@ -1,13 +1,14 @@ -import React, { useMemo, useRef } from 'react' import type { AppRouterInstance, NavigateOptions, } from '../app-router-context.shared-runtime' -import { PathnameContext } from '../hooks-client-context.shared-runtime' +import type { Params } from './utils/route-matcher' import type { NextRouter } from './router' + +import React, { useMemo, useRef } from 'react' +import { PathnameContext } from '../hooks-client-context.shared-runtime' import { isDynamicRoute } from './utils' import { asPathToSearchParams } from './utils/as-path-to-search-params' -import { Params } from './utils/route-matcher' import { getRouteRegex } from './utils/route-regex' /** diff --git a/packages/next/src/shared/lib/router/router.ts b/packages/next/src/shared/lib/router/router.ts index db0642e136933..c9e56e1d66b28 100644 --- a/packages/next/src/shared/lib/router/router.ts +++ b/packages/next/src/shared/lib/router/router.ts @@ -7,6 +7,7 @@ import type { RouterEvent } from '../../../client/router' import type { StyleSheetTuple } from '../../../client/page-loader' import type { UrlObject } from 'url' import type PageLoader from '../../../client/page-loader' +import type { AppContextType, NextPageContext, NEXT_DATA } from '../utils' import { removeTrailingSlash } from './utils/remove-trailing-slash' import { getClientBuildManifest, @@ -18,15 +19,7 @@ import isError, { getProperError } from '../../../lib/is-error' import { denormalizePagePath } from '../page-path/denormalize-page-path' import { normalizeLocalePath } from '../i18n/normalize-locale-path' import mitt from '../mitt' -import { - AppContextType, - getLocationOrigin, - getURL, - loadGetInitialProps, - NextPageContext, - ST, - NEXT_DATA, -} from '../utils' +import { getLocationOrigin, getURL, loadGetInitialProps, ST } from '../utils' import { isDynamicRoute } from './utils/is-dynamic' import { parseRelativeUrl } from './utils/parse-relative-url' import resolveRewrites from './utils/resolve-rewrites' diff --git a/packages/next/src/shared/lib/router/utils/get-next-pathname-info.ts b/packages/next/src/shared/lib/router/utils/get-next-pathname-info.ts index 7964d3410a262..79b66bb18e127 100644 --- a/packages/next/src/shared/lib/router/utils/get-next-pathname-info.ts +++ b/packages/next/src/shared/lib/router/utils/get-next-pathname-info.ts @@ -1,7 +1,7 @@ import { normalizeLocalePath } from '../../i18n/normalize-locale-path' import { removePathPrefix } from './remove-path-prefix' import { pathHasPrefix } from './path-has-prefix' -import { I18NProvider } from '../../../../server/future/helpers/i18n-provider' +import type { I18NProvider } from '../../../../server/future/helpers/i18n-provider' export interface NextPathnameInfo { /** diff --git a/packages/next/src/shared/lib/side-effect.tsx b/packages/next/src/shared/lib/side-effect.tsx index 440eef7d40b9b..aaa85a1db4f66 100644 --- a/packages/next/src/shared/lib/side-effect.tsx +++ b/packages/next/src/shared/lib/side-effect.tsx @@ -1,4 +1,5 @@ -import React, { Children, useEffect, useLayoutEffect } from 'react' +import type React from 'react' +import { Children, useEffect, useLayoutEffect } from 'react' type State = JSX.Element[] | undefined diff --git a/packages/next/src/shared/lib/utils.ts b/packages/next/src/shared/lib/utils.ts index 61b8fc394f93a..25886206f7016 100644 --- a/packages/next/src/shared/lib/utils.ts +++ b/packages/next/src/shared/lib/utils.ts @@ -6,7 +6,7 @@ import type { IncomingMessage, ServerResponse } from 'http' import type { NextRouter } from './router/router' import type { ParsedUrlQuery } from 'querystring' import type { PreviewData } from 'next/types' -import { COMPILER_NAMES } from './constants' +import type { COMPILER_NAMES } from './constants' import type fs from 'fs' export type NextComponentType< diff --git a/packages/next/src/telemetry/detached-flush.ts b/packages/next/src/telemetry/detached-flush.ts index 2d66cd18e0bf8..af6bb7ba97f38 100644 --- a/packages/next/src/telemetry/detached-flush.ts +++ b/packages/next/src/telemetry/detached-flush.ts @@ -1,6 +1,7 @@ import fs from 'fs' import path from 'path' -import { Telemetry, TelemetryEvent } from './storage' +import type { TelemetryEvent } from './storage' +import { Telemetry } from './storage' import loadConfig from '../server/config' import { getProjectDir } from '../lib/get-project-dir' import { PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants' diff --git a/packages/next/src/telemetry/events/build.ts b/packages/next/src/telemetry/events/build.ts index d5afddbccdd2d..9019fdb0c2723 100644 --- a/packages/next/src/telemetry/events/build.ts +++ b/packages/next/src/telemetry/events/build.ts @@ -1,4 +1,4 @@ -import { TelemetryPlugin } from '../../build/webpack/plugins/telemetry-plugin' +import type { TelemetryPlugin } from '../../build/webpack/plugins/telemetry-plugin' import type { SWC_TARGET_TRIPLE } from '../../build/webpack/plugins/telemetry-plugin' const REGEXP_DIRECTORY_DUNDER = diff --git a/packages/next/src/telemetry/events/swc-load-failure.ts b/packages/next/src/telemetry/events/swc-load-failure.ts index 2101d9fbb8216..0666af007ec6e 100644 --- a/packages/next/src/telemetry/events/swc-load-failure.ts +++ b/packages/next/src/telemetry/events/swc-load-failure.ts @@ -1,5 +1,5 @@ import { traceGlobals } from '../../trace/shared' -import { Telemetry } from '../storage' +import type { Telemetry } from '../storage' // @ts-ignore JSON import { version as nextVersion, optionalDependencies } from 'next/package.json' diff --git a/packages/next/src/telemetry/events/version.ts b/packages/next/src/telemetry/events/version.ts index d6973f4a7b421..10221dd1cc40c 100644 --- a/packages/next/src/telemetry/events/version.ts +++ b/packages/next/src/telemetry/events/version.ts @@ -1,5 +1,5 @@ +import type { NextConfigComplete } from '../../server/config-shared' import path from 'path' -import { NextConfigComplete } from '../../server/config-shared' const EVENT_VERSION = 'NEXT_CLI_SESSION_STARTED' diff --git a/packages/next/src/telemetry/storage.ts b/packages/next/src/telemetry/storage.ts index ed525b0157402..cb45c8ad89ba3 100644 --- a/packages/next/src/telemetry/storage.ts +++ b/packages/next/src/telemetry/storage.ts @@ -1,6 +1,7 @@ +import type { BinaryLike } from 'crypto' import { bold, cyan, magenta } from '../lib/picocolors' import Conf from 'next/dist/compiled/conf' -import { BinaryLike, createHash, randomBytes } from 'crypto' +import { createHash, randomBytes } from 'crypto' import isDockerFunction from 'next/dist/compiled/is-docker' import path from 'path' diff --git a/packages/next/src/trace/index.ts b/packages/next/src/trace/index.ts index e3928f775f613..4c7f55f4692d5 100644 --- a/packages/next/src/trace/index.ts +++ b/packages/next/src/trace/index.ts @@ -1,5 +1,6 @@ import { trace, flushAllTraces, Span, SpanStatus } from './trace' -import { SpanId, setGlobal } from './shared' +import type { SpanId } from './shared' +import { setGlobal } from './shared' export { trace, flushAllTraces, Span, setGlobal, SpanStatus } export type { SpanId } diff --git a/packages/next/src/trace/report/index.ts b/packages/next/src/trace/report/index.ts index 496c82c235fed..4de15ef6a5f58 100644 --- a/packages/next/src/trace/report/index.ts +++ b/packages/next/src/trace/report/index.ts @@ -1,4 +1,4 @@ -import { SpanId } from '../shared' +import type { SpanId } from '../shared' import reportToTelemetry from './to-telemetry' import reportToJson from './to-json' diff --git a/packages/next/src/trace/report/to-telemetry.ts b/packages/next/src/trace/report/to-telemetry.ts index 5eeb0d6e7b3a5..9e824c4a4c580 100644 --- a/packages/next/src/trace/report/to-telemetry.ts +++ b/packages/next/src/trace/report/to-telemetry.ts @@ -1,4 +1,4 @@ -import { Telemetry } from '../../telemetry/storage' +import type { Telemetry } from '../../telemetry/storage' import { traceGlobals } from '../shared' const TRACE_EVENT_ACCESSLIST = new Map( diff --git a/packages/next/src/trace/trace.ts b/packages/next/src/trace/trace.ts index c2244a23ede81..8a6895ba7ecca 100644 --- a/packages/next/src/trace/trace.ts +++ b/packages/next/src/trace/trace.ts @@ -1,4 +1,4 @@ -import { SpanId } from './shared' +import type { SpanId } from './shared' import { reporter } from './report' const NUM_OF_MICROSEC_IN_NANOSEC = BigInt('1000') diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index b13035993a163..74c1b8b77b68b 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -7,7 +7,8 @@ "esModuleInterop": true, "moduleResolution": "node", "jsx": "react", - "stripInternal": true + "stripInternal": true, + "verbatimModuleSyntax": true }, "exclude": [ "dist", diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index 625b0698c164e..c1f2196f8d0d6 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -7,9 +7,9 @@ import type { Agent as HttpAgent } from 'http' import type { Agent as HttpsAgent } from 'https' -import React from 'react' -import { ParsedUrlQuery } from 'querystring' -import { IncomingMessage, ServerResponse } from 'http' +import type React from 'react' +import type { ParsedUrlQuery } from 'querystring' +import type { IncomingMessage, ServerResponse } from 'http' import { NextPageContext, @@ -20,7 +20,7 @@ import { // @ts-ignore This path is generated at build time and conflicts otherwise } from '../dist/shared/lib/utils' -import { +import type { NextApiRequestCookies, // @ts-ignore This path is generated at build time and conflicts otherwise } from '../dist/server/api-utils' diff --git a/packages/next/types/webpack.d.ts b/packages/next/types/webpack.d.ts index 64e68d48e9048..bcd6eeb8eed18 100644 --- a/packages/next/types/webpack.d.ts +++ b/packages/next/types/webpack.d.ts @@ -27,7 +27,7 @@ declare module 'mini-css-extract-plugin' declare module 'next/dist/compiled/loader-utils3' declare module 'next/dist/compiled/webpack/webpack' { - import webpackSources from 'webpack-sources1' + import type webpackSources from 'webpack-sources1' export function init(): void export let BasicEvaluatedExpression: any export let GraphHelpers: any diff --git a/packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx b/packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx index 049de17386589..b6ff1d234fcf7 100644 --- a/packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx +++ b/packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx @@ -3,7 +3,8 @@ import * as React from 'react' import * as Bus from './bus' import { ShadowPortal } from './components/ShadowPortal' import { BuildError } from './container/BuildError' -import { Errors, SupportedErrorEvent } from './container/Errors' +import type { SupportedErrorEvent } from './container/Errors' +import { Errors } from './container/Errors' import { ErrorBoundary } from './ErrorBoundary' import { Base } from './styles/Base' import { ComponentStyles } from './styles/ComponentStyles' diff --git a/packages/react-dev-overlay/src/internal/bus.ts b/packages/react-dev-overlay/src/internal/bus.ts index 453a39f3e6a02..75bbfa0ca01aa 100644 --- a/packages/react-dev-overlay/src/internal/bus.ts +++ b/packages/react-dev-overlay/src/internal/bus.ts @@ -1,4 +1,4 @@ -import { StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'stacktrace-parser' export const TYPE_BUILD_OK = 'build-ok' export const TYPE_BUILD_ERROR = 'build-error' diff --git a/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx b/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx index 9d85a4377f91f..292b698e641b5 100644 --- a/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx +++ b/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx @@ -1,6 +1,6 @@ import Anser from 'anser' import * as React from 'react' -import { StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'stacktrace-parser' import stripAnsi from 'strip-ansi' import { getFrameSource } from '../../helpers/stack-frame' diff --git a/packages/react-dev-overlay/src/internal/container/Errors.tsx b/packages/react-dev-overlay/src/internal/container/Errors.tsx index 7976037245d45..b7a69daa0142e 100644 --- a/packages/react-dev-overlay/src/internal/container/Errors.tsx +++ b/packages/react-dev-overlay/src/internal/container/Errors.tsx @@ -1,10 +1,6 @@ import * as React from 'react' -import { - TYPE_UNHANDLED_ERROR, - TYPE_UNHANDLED_REJECTION, - UnhandledError, - UnhandledRejection, -} from '../bus' +import type { UnhandledError, UnhandledRejection } from '../bus' +import { TYPE_UNHANDLED_ERROR, TYPE_UNHANDLED_REJECTION } from '../bus' import { Dialog, DialogBody, @@ -14,7 +10,8 @@ import { import { LeftRightDialogHeader } from '../components/LeftRightDialogHeader' import { Overlay } from '../components/Overlay' import { Toast } from '../components/Toast' -import { getErrorByType, ReadyRuntimeError } from '../helpers/getErrorByType' +import type { ReadyRuntimeError } from '../helpers/getErrorByType' +import { getErrorByType } from '../helpers/getErrorByType' import { getErrorSource } from '../helpers/nodeStackFrames' import { noop as css } from '../helpers/noop-template' import { CloseIcon } from '../icons/CloseIcon' diff --git a/packages/react-dev-overlay/src/internal/container/RuntimeError.tsx b/packages/react-dev-overlay/src/internal/container/RuntimeError.tsx index f2fce9e83808d..0cbc3aaa005c3 100644 --- a/packages/react-dev-overlay/src/internal/container/RuntimeError.tsx +++ b/packages/react-dev-overlay/src/internal/container/RuntimeError.tsx @@ -1,9 +1,10 @@ import * as React from 'react' -import { StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'stacktrace-parser' import { CodeFrame } from '../components/CodeFrame' -import { ReadyRuntimeError } from '../helpers/getErrorByType' +import type { ReadyRuntimeError } from '../helpers/getErrorByType' import { noop as css } from '../helpers/noop-template' -import { getFrameSource, OriginalStackFrame } from '../helpers/stack-frame' +import type { OriginalStackFrame } from '../helpers/stack-frame' +import { getFrameSource } from '../helpers/stack-frame' export type RuntimeErrorProps = { error: ReadyRuntimeError } diff --git a/packages/react-dev-overlay/src/internal/helpers/getErrorByType.ts b/packages/react-dev-overlay/src/internal/helpers/getErrorByType.ts index 5e191b03ea1cb..619f22ba3873a 100644 --- a/packages/react-dev-overlay/src/internal/helpers/getErrorByType.ts +++ b/packages/react-dev-overlay/src/internal/helpers/getErrorByType.ts @@ -1,7 +1,8 @@ import { TYPE_UNHANDLED_ERROR, TYPE_UNHANDLED_REJECTION } from '../bus' -import { SupportedErrorEvent } from '../container/Errors' +import type { SupportedErrorEvent } from '../container/Errors' import { getErrorSource } from './nodeStackFrames' -import { getOriginalStackFrames, OriginalStackFrame } from './stack-frame' +import type { OriginalStackFrame } from './stack-frame' +import { getOriginalStackFrames } from './stack-frame' export type ReadyRuntimeError = { id: number diff --git a/packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts b/packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts index 98e09489bb58b..1fa1208e88d8a 100644 --- a/packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts +++ b/packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts @@ -1,4 +1,5 @@ -import dataUriToBuffer, { MimeBuffer } from 'data-uri-to-buffer' +import type { MimeBuffer } from 'data-uri-to-buffer' +import dataUriToBuffer from 'data-uri-to-buffer' import type { RawSourceMap } from 'source-map' import { getSourceMapUrl } from './getSourceMapUrl' diff --git a/packages/react-dev-overlay/src/internal/helpers/nodeStackFrames.ts b/packages/react-dev-overlay/src/internal/helpers/nodeStackFrames.ts index 382b33c8b4701..e63b1f5ae332c 100644 --- a/packages/react-dev-overlay/src/internal/helpers/nodeStackFrames.ts +++ b/packages/react-dev-overlay/src/internal/helpers/nodeStackFrames.ts @@ -1,4 +1,5 @@ -import { parse, StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'stacktrace-parser' +import { parse } from 'stacktrace-parser' export function getFilesystemFrame(frame: StackFrame): StackFrame { const f: StackFrame = { ...frame } diff --git a/packages/react-dev-overlay/src/internal/helpers/parseStack.ts b/packages/react-dev-overlay/src/internal/helpers/parseStack.ts index 7e6c1d1826089..c10226b3a3486 100644 --- a/packages/react-dev-overlay/src/internal/helpers/parseStack.ts +++ b/packages/react-dev-overlay/src/internal/helpers/parseStack.ts @@ -1,4 +1,5 @@ -import { parse, StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'stacktrace-parser' +import { parse } from 'stacktrace-parser' const regexNextStatic = /\/_next(\/static\/.+)/g diff --git a/packages/react-dev-overlay/src/internal/helpers/stack-frame.ts b/packages/react-dev-overlay/src/internal/helpers/stack-frame.ts index 36f326d1b54ef..1f28c4b3fe29d 100644 --- a/packages/react-dev-overlay/src/internal/helpers/stack-frame.ts +++ b/packages/react-dev-overlay/src/internal/helpers/stack-frame.ts @@ -1,5 +1,5 @@ -import { StackFrame } from 'stacktrace-parser' -import { OriginalStackFrameResponse } from '../../middleware' +import type { StackFrame } from 'stacktrace-parser' +import type { OriginalStackFrameResponse } from '../../middleware' export type OriginalStackFrame = | { diff --git a/packages/react-dev-overlay/src/middleware.ts b/packages/react-dev-overlay/src/middleware.ts index 2586015e4aba1..e52cdf9afffe6 100644 --- a/packages/react-dev-overlay/src/middleware.ts +++ b/packages/react-dev-overlay/src/middleware.ts @@ -1,10 +1,10 @@ import { codeFrameColumns } from '@babel/code-frame' import { constants as FS, promises as fs } from 'fs' -import { IncomingMessage, ServerResponse } from 'http' +import type { IncomingMessage, ServerResponse } from 'http' import path from 'path' import type { NullableMappedPosition, RawSourceMap } from 'source-map' import { SourceMapConsumer } from 'source-map' -import { StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'stacktrace-parser' import url from 'url' // @ts-ignore // eslint-disable-next-line import/no-extraneous-dependencies diff --git a/packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts b/packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts index ac80614bb23d9..7aaa4e15f23db 100644 --- a/packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts +++ b/packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts @@ -1,4 +1,4 @@ -import { +import type { Compiler as WebpackCompiler, Template as WebpackTemplate, RuntimeModule as WebpackRuntimeModule, diff --git a/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts b/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts index b362714732c9f..4146688688d67 100644 --- a/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts +++ b/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts @@ -1,4 +1,4 @@ -import { RefreshRuntimeGlobals } from '../runtime' +import type { RefreshRuntimeGlobals } from '../runtime' declare const self: Window & RefreshRuntimeGlobals diff --git a/packages/third-parties/src/google/GoogleMapsEmbed.tsx b/packages/third-parties/src/google/GoogleMapsEmbed.tsx index 047c2af146860..2ca5207610b8e 100644 --- a/packages/third-parties/src/google/GoogleMapsEmbed.tsx +++ b/packages/third-parties/src/google/GoogleMapsEmbed.tsx @@ -2,7 +2,7 @@ import React from 'react' import { GoogleMapsEmbed as TPCGoogleMapEmbed } from 'third-party-capital' import ThirdPartyScriptEmbed from '../ThirdPartyScriptEmbed' -import { GoogleMapsEmbed as GoogleMapsEmbedTypes } from '../types/google' +import type { GoogleMapsEmbed as GoogleMapsEmbedTypes } from '../types/google' export default function GoogleMapsEmbed(props: GoogleMapsEmbedTypes) { const { apiKey, ...restProps } = props diff --git a/packages/third-parties/src/google/YouTubeEmbed.tsx b/packages/third-parties/src/google/YouTubeEmbed.tsx index fec2c07d282e8..c95b083e55f36 100644 --- a/packages/third-parties/src/google/YouTubeEmbed.tsx +++ b/packages/third-parties/src/google/YouTubeEmbed.tsx @@ -1,9 +1,10 @@ import React from 'react' -import Script, { ScriptProps } from 'next/script' +import type { ScriptProps } from 'next/script' +import Script from 'next/script' import { YouTubeEmbed as TPCYouTubeEmbed } from 'third-party-capital' import ThirdPartyScriptEmbed from '../ThirdPartyScriptEmbed' -import { YouTubeEmbed as YouTubeEmbedTypes } from '../types/google' +import type { YouTubeEmbed as YouTubeEmbedTypes } from '../types/google' const scriptStrategy = { server: 'beforeInteractive',