Skip to content

Commit d2145f3

Browse files
Merge branch 'canary' into fix/build-restart-log
2 parents d6d34fb + c60ecfc commit d2145f3

File tree

338 files changed

+25156
-764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

338 files changed

+25156
-764
lines changed

.eslintrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@
213213
],
214214
"eslint-plugin/require-meta-docs-url": "error"
215215
}
216+
},
217+
{
218+
"files": ["packages/**/*.tsx", "packages/**/*.ts"],
219+
"rules": {
220+
"@typescript-eslint/consistent-type-imports": [
221+
"error",
222+
{
223+
"disallowTypeAnnotations": false
224+
}
225+
],
226+
"@typescript-eslint/no-import-type-side-effects": "error"
227+
}
216228
}
217229
],
218230
"rules": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
"react-dom-experimental-builtin": "npm:[email protected]",
200200
"react-experimental-builtin": "npm:[email protected]",
201201
"react-server-dom-turbopack": "18.3.0-canary-d900fadbf-20230929",
202-
"react-server-dom-turbopack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-d900fadbf-20230929",
202+
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-d900fadbf-20230929",
203203
"react-server-dom-webpack": "18.3.0-canary-d900fadbf-20230929",
204204
"react-server-dom-webpack-experimental": "npm:[email protected]",
205205
"react-ssr-prepass": "1.0.8",

packages/create-next-app/create-app.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import retry from 'async-retry'
33
import { red, green, cyan } from 'picocolors'
44
import fs from 'fs'
55
import path from 'path'
6+
import type { RepoInfo } from './helpers/examples'
67
import {
78
downloadAndExtractExample,
89
downloadAndExtractRepo,
910
getRepoInfo,
1011
existsInRepo,
1112
hasRepo,
12-
RepoInfo,
1313
} from './helpers/examples'
1414
import { makeDir } from './helpers/make-dir'
1515
import { tryGitInit } from './helpers/git'
@@ -19,12 +19,8 @@ import { getOnline } from './helpers/is-online'
1919
import { isWriteable } from './helpers/is-writeable'
2020
import type { PackageManager } from './helpers/get-pkg-manager'
2121

22-
import {
23-
getTemplateFile,
24-
installTemplate,
25-
TemplateMode,
26-
TemplateType,
27-
} from './templates'
22+
import type { TemplateMode, TemplateType } from './templates'
23+
import { getTemplateFile, installTemplate } from './templates'
2824

2925
export class DownloadError extends Error {}
3026

packages/font/src/google/get-proxy-agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import HttpsProxyAgent from 'next/dist/compiled/https-proxy-agent'
33
// @ts-ignore
44
import HttpProxyAgent from 'next/dist/compiled/http-proxy-agent'
5-
import { Agent } from 'https'
5+
import type { Agent } from 'https'
66

77
/**
88
* If the http(s)_proxy environment variables is set, return a proxy agent.

packages/next-codemod/lib/cra-to-next/global-css-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import nodePath from 'path'
2-
import { API, FileInfo, Options } from 'jscodeshift'
2+
import type { API, FileInfo, Options } from 'jscodeshift'
33

44
export const globalCssContext = {
55
cssImports: new Set<string>(),

packages/next-codemod/lib/cra-to-next/index-to-component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { API, FileInfo, JSXElement, Options } from 'jscodeshift'
1+
import type { API, FileInfo, JSXElement, Options } from 'jscodeshift'
22

33
export const indexContext = {
44
multipleRenderRoots: false,

packages/next-codemod/transforms/add-missing-react-import.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { API, Collection, FileInfo, JSCodeshift, Options } from 'jscodeshift'
1+
import type {
2+
API,
3+
Collection,
4+
FileInfo,
5+
JSCodeshift,
6+
Options,
7+
} from 'jscodeshift'
28

39
function addReactImport(j: JSCodeshift, root: Collection) {
410
// We create an import specifier, this is the value of an import, eg:

packages/next-codemod/transforms/name-default-component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
API,
33
ArrowFunctionExpression,
44
ASTPath,

packages/next-codemod/transforms/new-link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { API, FileInfo } from 'jscodeshift'
1+
import type { API, FileInfo } from 'jscodeshift'
22

33
export default function transformer(file: FileInfo, api: API) {
44
const j = api.jscodeshift.withParser('tsx')

packages/next/src/build/analysis/get-page-static-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Middleware, RouteHas } from '../../lib/load-custom-routes'
44
import { promises as fs } from 'fs'
55
import LRUCache from 'next/dist/compiled/lru-cache'
66
import { matcher } from 'next/dist/compiled/micromatch'
7-
import { ServerRuntime } from 'next/types'
7+
import type { ServerRuntime } from 'next/types'
88
import {
99
extractExportedConstValue,
1010
UnsupportedValueError,

packages/next/src/build/babel/loader/get-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import JSON5 from 'next/dist/compiled/json5'
44
import { createConfigItem, loadOptions } from 'next/dist/compiled/babel/core'
55
import loadConfig from 'next/dist/compiled/babel/core-lib-config'
66

7-
import { NextBabelLoaderOptions, NextJsLoaderContext } from './types'
7+
import type { NextBabelLoaderOptions, NextJsLoaderContext } from './types'
88
import { consumeIterator } from './util'
99
import * as Log from '../../output/log'
1010

packages/next/src/build/babel/loader/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Span } from '../../../trace'
1+
import type { Span } from '../../../trace'
22
import transform from './transform'
3-
import { NextJsLoaderContext } from './types'
3+
import type { NextJsLoaderContext } from './types'
44

55
async function nextBabelLoader(
66
this: NextJsLoaderContext,

packages/next/src/build/babel/loader/transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import PluginPass from 'next/dist/compiled/babel/core-lib-plugin-pass'
1111

1212
import getConfig from './get-config'
1313
import { consumeIterator } from './util'
14-
import { Span } from '../../../trace'
15-
import { NextJsLoaderContext } from './types'
14+
import type { Span } from '../../../trace'
15+
import type { NextJsLoaderContext } from './types'
1616

1717
function getTraversalParams(file: any, pluginPairs: any[]) {
1818
const passPairs = []

packages/next/src/build/babel/loader/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { webpack } from 'next/dist/compiled/webpack/webpack'
2-
import { Span } from '../../../trace'
1+
import type { webpack } from 'next/dist/compiled/webpack/webpack'
2+
import type { Span } from '../../../trace'
33

44
export interface NextJsLoaderContext extends webpack.LoaderContext<{}> {
55
currentTraceSpan: Span

packages/next/src/build/babel/plugins/amp-attributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core'
1+
import type { NodePath, types, PluginObj } from 'next/dist/compiled/babel/core'
22

33
export default function AmpAttributePatcher(): PluginObj {
44
return {

packages/next/src/build/babel/plugins/commonjs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core'
1+
import type { NodePath, types } from 'next/dist/compiled/babel/core'
2+
import type { PluginObj } from 'next/dist/compiled/babel/core'
23
import commonjsPlugin from 'next/dist/compiled/babel/plugin-transform-modules-commonjs'
34

45
// Handle module.exports in user code

packages/next/src/build/babel/plugins/jsx-pragma.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {
1+
import type {
22
NodePath,
3-
PluginObj,
43
types as BabelTypes,
54
} from 'next/dist/compiled/babel/core'
5+
import type { PluginObj } from 'next/dist/compiled/babel/core'
66
import jsx from 'next/dist/compiled/babel/plugin-syntax-jsx'
77

88
export default function ({

packages/next/src/build/babel/plugins/next-font-unsupported.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core'
1+
import type { NodePath, types } from 'next/dist/compiled/babel/core'
2+
import type { PluginObj } from 'next/dist/compiled/babel/core'
23

34
export default function NextPageDisallowReExportAllExports(): PluginObj<any> {
45
return {

packages/next/src/build/babel/plugins/next-page-config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {
2-
NodePath,
1+
import { types as BabelTypes } from 'next/dist/compiled/babel/core'
2+
import type {
33
PluginObj,
44
PluginPass,
5-
types as BabelTypes,
65
Visitor,
6+
NodePath,
77
} from 'next/dist/compiled/babel/core'
8-
import { PageConfig } from 'next/types'
8+
import type { PageConfig } from 'next/types'
99
import { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants'
1010

1111
const CONFIG_KEY = 'config'

packages/next/src/build/babel/plugins/next-page-disallow-re-export-all-exports.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NodePath, PluginObj, types } from 'next/dist/compiled/babel/core'
1+
import type { NodePath, types } from 'next/dist/compiled/babel/core'
2+
import type { PluginObj } from 'next/dist/compiled/babel/core'
23

34
export default function NextPageDisallowReExportAllExports(): PluginObj<any> {
45
return {

packages/next/src/build/babel/plugins/next-ssg-transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {
1+
import type {
22
NodePath,
3-
PluginObj,
43
types as BabelTypes,
54
} from 'next/dist/compiled/babel/core'
5+
import type { PluginObj } from 'next/dist/compiled/babel/core'
66
import { SERVER_PROPS_SSG_CONFLICT } from '../../../lib/constants'
77
import { SERVER_PROPS_ID, STATIC_PROPS_ID } from '../../../shared/lib/constants'
88

packages/next/src/build/babel/plugins/optimize-hook-destructuring.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import {
1+
import type {
22
NodePath,
3-
PluginObj,
43
types as BabelTypes,
54
} from 'next/dist/compiled/babel/core'
6-
5+
import type { PluginObj } from 'next/dist/compiled/babel/core'
76
// matches any hook-like (the default)
87
const isHook = /^use[A-Z]/
98

packages/next/src/build/babel/plugins/react-loadable-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
2323
// Modified to put `webpack` and `modules` under `loadableGenerated` to be backwards compatible with next/dynamic which has a `modules` key
2424
// Modified to support `dynamic(import('something'))` and `dynamic(import('something'), options)
2525

26-
import {
26+
import type {
2727
NodePath,
28-
PluginObj,
2928
types as BabelTypes,
3029
} from 'next/dist/compiled/babel/core'
30+
import type { PluginObj } from 'next/dist/compiled/babel/core'
3131

3232
import { relative as relativePath } from 'path'
3333

packages/next/src/build/babel/preset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PluginItem } from 'next/dist/compiled/babel/core'
1+
import type { PluginItem } from 'next/dist/compiled/babel/core'
22
import { dirname } from 'path'
33

44
const isLoadIntentTest = process.env.NODE_ENV === 'test'

packages/next/src/build/collect-build-traces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414

1515
import path from 'path'
1616
import fs from 'fs/promises'
17-
import { PageInfo } from './utils'
17+
import type { PageInfo } from './utils'
1818
import { loadBindings } from './swc'
1919
import { nonNullable } from '../lib/non-nullable'
2020
import * as ciEnvironment from '../telemetry/ci-info'

packages/next/src/build/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { webpack } from 'next/dist/compiled/webpack/webpack'
2-
import { Span } from '../trace'
2+
import type { Span } from '../trace'
33

44
export type CompilerResult = {
55
errors: webpack.StatsError[]

packages/next/src/build/entries.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import {
3232
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
3333
CLIENT_STATIC_FILES_RUNTIME_POLYFILLS,
3434
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,
35-
CompilerNameValues,
3635
COMPILER_NAMES,
3736
EDGE_RUNTIME_WEBPACK,
3837
} from '../shared/lib/constants'
39-
import { __ApiPreviewProps } from '../server/api-utils'
38+
import type { CompilerNameValues } from '../shared/lib/constants'
39+
import type { __ApiPreviewProps } from '../server/api-utils'
4040
import { warn } from './output/log'
4141
import {
4242
isMiddlewareFile,
@@ -46,10 +46,10 @@ import {
4646
import { getPageStaticInfo } from './analysis/get-page-static-info'
4747
import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'
4848
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
49-
import { ServerRuntime } from '../../types'
49+
import type { ServerRuntime } from '../../types'
5050
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
5151
import { encodeMatchers } from './webpack/loaders/next-middleware-loader'
52-
import { EdgeFunctionLoaderOptions } from './webpack/loaders/next-edge-function-loader'
52+
import type { EdgeFunctionLoaderOptions } from './webpack/loaders/next-edge-function-loader'
5353
import { isAppRouteRoute } from '../lib/is-app-route-route'
5454
import { normalizeMetadataRoute } from '../lib/metadata/get-metadata-route'
5555
import { getRouteLoaderEntry } from './webpack/loaders/next-route-loader'

packages/next/src/build/handle-externals.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { WebpackLayerName, WEBPACK_LAYERS } from '../lib/constants'
1+
import { WEBPACK_LAYERS } from '../lib/constants'
2+
import type { WebpackLayerName } from '../lib/constants'
23
import { defaultOverrides } from '../server/require-hook'
34
import { BARREL_OPTIMIZATION_PREFIX } from '../shared/lib/constants'
45
import path from '../shared/lib/isomorphic/path'
@@ -9,7 +10,7 @@ import {
910
NODE_RESOLVE_OPTIONS,
1011
} from './webpack-config'
1112
import { isWebpackAppLayer, isWebpackServerLayer } from './worker'
12-
import { NextConfigComplete } from '../server/config-shared'
13+
import type { NextConfigComplete } from '../server/config-shared'
1314
const reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\/)/
1415

1516
const pathSeparators = '[/\\\\]'

packages/next/src/build/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ import {
3535
import { FileType, fileExists } from '../lib/file-exists'
3636
import { findPagesDir } from '../lib/find-pages-dir'
3737
import loadCustomRoutes, {
38+
normalizeRouteRegex,
39+
} from '../lib/load-custom-routes'
40+
import type {
3841
CustomRoutes,
3942
Header,
40-
normalizeRouteRegex,
4143
Redirect,
4244
Rewrite,
4345
RouteHas,
@@ -76,9 +78,9 @@ import {
7678
FUNCTIONS_CONFIG_MANIFEST,
7779
} from '../shared/lib/constants'
7880
import { getSortedRoutes, isDynamicRoute } from '../shared/lib/router/utils'
79-
import { __ApiPreviewProps } from '../server/api-utils'
81+
import type { __ApiPreviewProps } from '../server/api-utils'
8082
import loadConfig from '../server/config'
81-
import { BuildManifest } from '../server/get-page-files'
83+
import type { BuildManifest } from '../server/get-page-files'
8284
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
8385
import { getPagePath } from '../server/require'
8486
import * as ciEnvironment from '../telemetry/ci-info'
@@ -88,10 +90,10 @@ import {
8890
eventBuildFeatureUsage,
8991
eventNextPlugins,
9092
EVENT_BUILD_FEATURE_USAGE,
91-
EventBuildFeatureUsage,
9293
eventPackageUsedInGetServerSideProps,
9394
eventBuildCompleted,
9495
} from '../telemetry/events'
96+
import type { EventBuildFeatureUsage } from '../telemetry/events'
9597
import { Telemetry } from '../telemetry/storage'
9698
import {
9799
isDynamicMetadataRoute,
@@ -107,17 +109,17 @@ import {
107109
detectConflictingPaths,
108110
computeFromManifest,
109111
getJsPageSizeInKb,
110-
PageInfo,
111112
printCustomRoutes,
112113
printTreeView,
113114
copyTracedFiles,
114115
isReservedPage,
115-
AppConfig,
116116
isAppBuiltinNotFoundPage,
117117
} from './utils'
118+
import type { PageInfo, AppConfig } from './utils'
118119
import { writeBuildId } from './write-build-id'
119120
import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path'
120-
import isError, { NextError } from '../lib/is-error'
121+
import isError from '../lib/is-error'
122+
import type { NextError } from '../lib/is-error'
121123
import { isEdgeRuntime } from '../lib/is-edge-runtime'
122124
import { recursiveCopy } from '../lib/recursive-copy'
123125
import { recursiveReadDir } from '../lib/recursive-readdir'
@@ -153,7 +155,7 @@ import { buildDataRoute } from '../server/lib/router-utils/build-data-route'
153155
import { initialize as initializeIncrementalCache } from '../server/lib/incremental-cache-server'
154156
import { nodeFs } from '../server/lib/node-fs-methods'
155157
import { collectBuildTraces } from './collect-build-traces'
156-
import { BuildTraceContext } from './webpack/plugins/next-trace-entrypoints-plugin'
158+
import type { BuildTraceContext } from './webpack/plugins/next-trace-entrypoints-plugin'
157159
import { formatManifest } from './manifests/formatter/format-manifest'
158160

159161
interface ExperimentalBypassForInfo {

packages/next/src/build/load-jsconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
22
import fs from 'fs'
3-
import { NextConfigComplete } from '../server/config-shared'
3+
import type { NextConfigComplete } from '../server/config-shared'
44
import * as Log from './output/log'
55
import { getTypeScriptConfiguration } from '../lib/typescript/getTypeScriptConfiguration'
66
import { readFileSync } from 'fs'

packages/next/src/build/output/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import stripAnsi from 'next/dist/compiled/strip-ansi'
33
import textTable from 'next/dist/compiled/text-table'
44
import createStore from 'next/dist/compiled/unistore'
55
import formatWebpackMessages from '../../client/dev/error-overlay/format-webpack-messages'
6-
import { OutputState, store as consoleStore } from './store'
6+
import { store as consoleStore } from './store'
7+
import type { OutputState } from './store'
78
import type { webpack } from 'next/dist/compiled/webpack/webpack'
8-
import { CompilerNameValues, COMPILER_NAMES } from '../../shared/lib/constants'
9+
import { COMPILER_NAMES } from '../../shared/lib/constants'
10+
import type { CompilerNameValues } from '../../shared/lib/constants'
911

1012
export function startedDevelopmentServer(appUrl: string, bindAddr: string) {
1113
consoleStore.setState({ appUrl, bindAddr })

0 commit comments

Comments
 (0)