Skip to content

Commit

Permalink
refactor: deprecate future directory (#66432)
Browse files Browse the repository at this point in the history
This removes the previous `server/future` directory and moves everything
into the `server` or `server/lib` directories. This is aimed to start to
flatten the server application structure.
# Conflicts:
#	packages/next/src/build/create-compiler-aliases.ts
#	packages/next/src/build/utils.ts
#	packages/next/src/build/webpack/loaders/next-edge-ssr-loader/index.ts
#	packages/next/src/export/routes/app-route.ts
#	packages/next/src/server/app-render/action-handler.ts
#	packages/next/src/server/base-server.ts
#	packages/next/src/server/future/route-modules/app-page/vendored/contexts/entrypoints.ts
#	packages/next/src/server/future/route-modules/app-page/vendored/rsc/react-compiler-runtime.ts
#	packages/next/src/server/future/route-modules/app-page/vendored/ssr/react-compiler-runtime.ts
#	packages/next/src/server/load-components.ts
#	packages/next/src/server/load-default-error-components.ts
#	packages/next/src/server/normalizers/request/prefetch-rsc.test.ts
#	packages/next/src/server/route-modules/app-page/module.ts
#	packages/next/src/server/route-modules/app-page/vendored/contexts/html-context.ts
#	packages/next/src/server/route-modules/app-page/vendored/contexts/loadable-context.ts
#	packages/next/src/server/route-modules/app-page/vendored/contexts/loadable.ts
#	packages/next/src/server/route-modules/app-page/vendored/rsc/react-compiler-runtime.ts
#	packages/next/src/server/route-modules/app-page/vendored/ssr/react-compiler-runtime.ts
#	packages/next/src/server/route-modules/app-route/helpers/is-static-gen-enabled.ts
#	packages/next/src/server/route-modules/app-route/module.ts
#	packages/next/src/server/route-modules/pages-api/module.ts
#	packages/next/src/server/route-modules/pages/module.ts
#	packages/next/src/shared/lib/router/utils/route-regex.ts
#	test/turbopack-dev-tests-manifest.json
  • Loading branch information
ForsakenHarmony committed Aug 15, 2024
1 parent a118265 commit f0905a4
Show file tree
Hide file tree
Showing 209 changed files with 1,848 additions and 1,312 deletions.
32 changes: 16 additions & 16 deletions packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,26 +684,26 @@ async fn rsc_aliases(
match ty {
ServerContextType::AppSSR { .. } => {
alias.extend(indexmap! {
"react/jsx-runtime" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react-jsx-runtime"),
"react/jsx-dev-runtime" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime"),
"react/compiler-runtime" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react-compiler-runtime"),
"react" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react"),
"react-dom" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react-dom"),
"react-server-dom-webpack/client.edge" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client-edge"),
"react-server-dom-turbopack/client.edge" => format!("next/dist/server/future/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client-edge"),
"react/jsx-runtime" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-runtime"),
"react/jsx-dev-runtime" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime"),
"react/compiler-runtime" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react-compiler-runtime"),
"react" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react"),
"react-dom" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react-dom"),
"react-server-dom-webpack/client.edge" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client-edge"),
"react-server-dom-turbopack/client.edge" => format!("next/dist/server/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client-edge"),
})
}
ServerContextType::AppRSC { .. } | ServerContextType::AppRoute { .. } => {
alias.extend(indexmap! {
"react/jsx-runtime" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-jsx-runtime"),
"react/jsx-dev-runtime" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-jsx-dev-runtime"),
"react/compiler-runtime" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-compiler-runtime"),
"react" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react"),
"react-dom" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-dom"),
"react-server-dom-webpack/server.edge" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-edge"),
"react-server-dom-webpack/server.node" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-node"),
"react-server-dom-turbopack/server.edge" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-edge"),
"react-server-dom-turbopack/server.node" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-node"),
"react/jsx-runtime" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-jsx-runtime"),
"react/jsx-dev-runtime" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-jsx-dev-runtime"),
"react/compiler-runtime" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-compiler-runtime"),
"react" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react"),
"react-dom" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-dom"),
"react-server-dom-webpack/server.edge" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-edge"),
"react-server-dom-webpack/server.node" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-node"),
"react-server-dom-turbopack/server.edge" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-edge"),
"react-server-dom-turbopack/server.node" => format!("next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-node"),
"next/navigation" => format!("next/dist/api/navigation.react-server"),

// Needed to make `react-dom/server` work.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl AfterResolvePlugin for NextNodeSharedRuntimeResolvePlugin {
let stem = stem.replace(".shared-runtime", "");

let resource_request = format!(
"next/dist/server/future/route-modules/{}/vendored/contexts/{}.js",
"next/dist/server/route-modules/{}/vendored/contexts/{}.js",
match self.context {
ServerContextType::Pages { .. } => "pages",
ServerContextType::AppRoute { .. } => "app-route",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export async function collectBuildTraces({

for (const type of moduleTypes) {
const modulePath = require.resolve(
`next/dist/server/future/route-modules/${type}/module.compiled`
`next/dist/server/route-modules/${type}/module.compiled`
)
const relativeModulePath = path.relative(root, modulePath)

Expand Down
65 changes: 34 additions & 31 deletions packages/next/src/build/create-compiler-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export function createWebpackAliases({
}
: undefined),

next: NEXT_PROJECT_ROOT,

'styled-jsx/style$': defaultOverrides['styled-jsx/style'],
'styled-jsx$': defaultOverrides['styled-jsx'],

Expand Down Expand Up @@ -254,6 +252,7 @@ export function createRSCAliases(
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}`,
'react/jsx-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime`,
'react/compiler-runtime$': `next/dist/compiled/react${bundledReactChannel}/compiler-runtime`,
'react-dom/client$': `next/dist/compiled/react-dom${bundledReactChannel}/client`,
'react-dom/server$': `next/dist/compiled/react-dom${bundledReactChannel}/server`,
'react-dom/static$': `next/dist/compiled/react-dom-experimental/static`,
Expand All @@ -272,49 +271,53 @@ export function createRSCAliases(
if (!isEdgeServer) {
if (layer === WEBPACK_LAYERS.serverSideRendering) {
alias = Object.assign(alias, {
'react/jsx-runtime$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-jsx-dev-runtime`,
react$: `next/dist/server/future/route-modules/app-page/vendored/${layer}/react`,
'react-dom$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-dom`,
'react-server-dom-webpack/client.edge$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-client-edge`,
'react/jsx-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-jsx-dev-runtime`,
'react/compiler-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-compiler-runtime`,
react$: `next/dist/server/route-modules/app-page/vendored/${layer}/react`,
'react-dom$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-dom`,
'react-server-dom-webpack/client.edge$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-client-edge`,
})
} else if (layer === WEBPACK_LAYERS.reactServerComponents) {
alias = Object.assign(alias, {
'react/jsx-runtime$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-jsx-dev-runtime`,
react$: `next/dist/server/future/route-modules/app-page/vendored/${layer}/react`,
'react-dom$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-dom`,
'react-server-dom-webpack/server.edge$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-server-edge`,
'react-server-dom-webpack/server.node$': `next/dist/server/future/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-server-node`,
'react/jsx-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-jsx-dev-runtime`,
'react/compiler-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-compiler-runtime`,
react$: `next/dist/server/route-modules/app-page/vendored/${layer}/react`,
'react-dom$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-dom`,
'react-server-dom-webpack/server.edge$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-server-edge`,
'react-server-dom-webpack/server.node$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-server-node`,
})
}
}

if (isEdgeServer) {
if (layer === WEBPACK_LAYERS.reactServerComponents) {
alias[
'react$'
] = `next/dist/compiled/react${bundledReactChannel}/react.react-server`
alias[
'react-dom$'
] = `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`
} else {
// x-ref: https://github.com/facebook/react/pull/25436
alias[
'react-dom$'
] = `next/dist/compiled/react-dom${bundledReactChannel}/server-rendering-stub`
alias = Object.assign(alias, {
react$: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
'next/dist/compiled/react$': `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
'next/dist/compiled/react-experimental$': `next/dist/compiled/react-experimental/react.react-server`,
'react/jsx-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server`,
'react/compiler-runtime$': `next/dist/compiled/react${bundledReactChannel}/compiler-runtime`,
'next/dist/compiled/react/jsx-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server`,
'next/dist/compiled/react-experimental/jsx-runtime$': `next/dist/compiled/react-experimental/jsx-runtime.react-server`,
'react/jsx-dev-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server`,
'next/dist/compiled/react/jsx-dev-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server`,
'next/dist/compiled/react-experimental/jsx-dev-runtime$': `next/dist/compiled/react-experimental/jsx-dev-runtime.react-server`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
'next/dist/compiled/react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
'next/dist/compiled/react-dom-experimental$': `next/dist/compiled/react-dom-experimental/react-dom.react-server`,
})
}
}

if (reactProductionProfiling) {
alias[
'react-dom$'
] = `next/dist/compiled/react-dom${bundledReactChannel}/profiling`
alias['react-dom/client$'] =
`next/dist/compiled/react-dom${bundledReactChannel}/profiling`
}

alias[
'@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client.ts'
] = `next/dist/client/dev/noop-turbopack-hmr`
alias['@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client.ts'] =
`next/dist/client/dev/noop-turbopack-hmr`

return alias
}
Expand Down Expand Up @@ -375,6 +378,6 @@ function getBarrelOptimizationAliases(packages: string[]): CompilerAliases {
}
function getReactProfilingInProduction(): CompilerAliases {
return {
'react-dom$': 'react-dom/profiling',
'react-dom/client$': 'react-dom/profiling',
}
}
2 changes: 1 addition & 1 deletion packages/next/src/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import {
isNonRoutePagesPage,
} from '../lib/is-internal-component'
import { isStaticMetadataRouteFile } from '../lib/metadata/is-metadata-route'
import { RouteKind } from '../server/future/route-kind'
import { RouteKind } from '../server/route-kind'
import { encodeToBase64 } from './webpack/loaders/utils'
import { normalizeCatchAllRoutes } from './normalize-catchall-routes'
import type { PageExtensions } from './page-extensions-type'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ import type { NextEnabledDirectories } from '../server/base-server'
import { hasCustomExportOutput } from '../export/utils'
import { interopDefault } from '../lib/interop-default'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'
import { isInterceptionRouteAppPath } from '../server/lib/interception-routes'
import {
getTurbopackJsConfig,
handleEntrypoints,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/normalize-catchall-routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'
import { AppPathnameNormalizer } from '../server/future/normalizers/built/app/app-pathname-normalizer'
import { isInterceptionRouteAppPath } from '../server/lib/interception-routes'
import { AppPathnameNormalizer } from '../server/normalizers/built/app/app-pathname-normalizer'

/**
* This function will transform the appPaths in order to support catch-all routes and parallel routes.
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/app-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { LoaderTree } from '../../server/lib/app-dir-module'
import { AppPageRouteModule } from '../../server/future/route-modules/app-page/module.compiled' with { 'turbopack-transition': 'next-ssr' }
import { RouteKind } from '../../server/future/route-kind'
import { AppPageRouteModule } from '../../server/route-modules/app-page/module.compiled' with { 'turbopack-transition': 'next-ssr' }
import { RouteKind } from '../../server/route-kind'

// These are injected by the loader afterwards.

Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/app-route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
AppRouteRouteModule,
type AppRouteRouteModuleOptions,
} from '../../server/future/route-modules/app-route/module.compiled'
import { RouteKind } from '../../server/future/route-kind'
} from '../../server/route-modules/app-route/module.compiled'
import { RouteKind } from '../../server/route-kind'
import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'

import * as userland from 'VAR_USERLAND'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/templates/edge-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare const incrementalCacheHandler: any
// const renderToHTML = undefined

import { renderToHTML } from '../../server/render'
import RouteModule from '../../server/future/route-modules/pages/module'
import RouteModule from '../../server/route-modules/pages/module'

import type { RequestData } from '../../server/web/types'
import type { BuildManifest } from '../../server/get-page-files'
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/pages-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PagesAPIRouteModule } from '../../server/future/route-modules/pages-api/module.compiled'
import { RouteKind } from '../../server/future/route-kind'
import { PagesAPIRouteModule } from '../../server/route-modules/pages-api/module.compiled'
import { RouteKind } from '../../server/route-kind'

import { hoist } from './helpers'

Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/pages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PagesRouteModule } from '../../server/future/route-modules/pages/module.compiled'
import { RouteKind } from '../../server/future/route-kind'
import { PagesRouteModule } from '../../server/route-modules/pages/module.compiled'
import { RouteKind } from '../../server/route-kind'
import { hoist } from './helpers'

// Import the app and document modules.
Expand Down
Loading

0 comments on commit f0905a4

Please sign in to comment.