Unverified Commit 71cdce68 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

[refactor] group the built-in conventions (#80957)

Group all the built-in conventions into `src/client/components/builtin` with the actual same name of the conventions they represent.

e.g. 
The default `not-found.js` is `next/dist/client/compoents/builtin/not-found.js`;
The default `global-error.js` is `next/dist/client/compoents/builtin/global-error.js`;

This give us an easier way to track all the builtin conventions. This is also the preparation work for #80961 where we display the builtin conventions in the segment explorer.
parent ee5c6eb7
...@@ -910,7 +910,7 @@ async fn directory_tree_to_loader_tree_internal( ...@@ -910,7 +910,7 @@ async fn directory_tree_to_loader_tree_internal(
if modules.not_found.is_none() { if modules.not_found.is_none() {
modules.not_found = Some( modules.not_found = Some(
get_next_package(app_dir) get_next_package(app_dir)
.join(rcstr!("dist/client/components/not-found-error.js")) .join(rcstr!("dist/client/components/builtin/not-found.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -918,7 +918,7 @@ async fn directory_tree_to_loader_tree_internal( ...@@ -918,7 +918,7 @@ async fn directory_tree_to_loader_tree_internal(
if modules.forbidden.is_none() { if modules.forbidden.is_none() {
modules.forbidden = Some( modules.forbidden = Some(
get_next_package(app_dir) get_next_package(app_dir)
.join(rcstr!("dist/client/components/forbidden-error.js")) .join(rcstr!("dist/client/components/builtin/forbidden.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -926,7 +926,7 @@ async fn directory_tree_to_loader_tree_internal( ...@@ -926,7 +926,7 @@ async fn directory_tree_to_loader_tree_internal(
if modules.unauthorized.is_none() { if modules.unauthorized.is_none() {
modules.unauthorized = Some( modules.unauthorized = Some(
get_next_package(app_dir) get_next_package(app_dir)
.join(rcstr!("dist/client/components/unauthorized-error.js")) .join(rcstr!("dist/client/components/builtin/unauthorized.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -1130,7 +1130,7 @@ async fn default_route_tree( ...@@ -1130,7 +1130,7 @@ async fn default_route_tree(
AppDirModules { AppDirModules {
default: Some( default: Some(
get_next_package(app_dir) get_next_package(app_dir)
.join(rcstr!("dist/client/components/parallel-route-default.js")) .join(rcstr!("dist/client/components/builtin/default.js"))
.to_resolved() .to_resolved()
.await?, .await?,
), ),
...@@ -1275,7 +1275,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( ...@@ -1275,7 +1275,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
if modules.layout.is_none() { if modules.layout.is_none() {
modules.layout = Some( modules.layout = Some(
get_next_package(*app_dir) get_next_package(*app_dir)
.join(rcstr!("dist/client/components/default-layout.js")) .join(rcstr!("dist/client/components/builtin/layout.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -1284,7 +1284,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( ...@@ -1284,7 +1284,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
if modules.not_found.is_none() { if modules.not_found.is_none() {
modules.not_found = Some( modules.not_found = Some(
get_next_package(*app_dir) get_next_package(*app_dir)
.join(rcstr!("dist/client/components/not-found-error.js")) .join(rcstr!("dist/client/components/builtin/not-found.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -1292,7 +1292,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( ...@@ -1292,7 +1292,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
if modules.forbidden.is_none() { if modules.forbidden.is_none() {
modules.forbidden = Some( modules.forbidden = Some(
get_next_package(*app_dir) get_next_package(*app_dir)
.join(rcstr!("dist/client/components/forbidden-error.js")) .join(rcstr!("dist/client/components/builtin/forbidden.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -1300,7 +1300,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( ...@@ -1300,7 +1300,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
if modules.unauthorized.is_none() { if modules.unauthorized.is_none() {
modules.unauthorized = Some( modules.unauthorized = Some(
get_next_package(*app_dir) get_next_package(*app_dir)
.join(rcstr!("dist/client/components/unauthorized-error.js")) .join(rcstr!("dist/client/components/builtin/unauthorized.js"))
.to_resolved() .to_resolved()
.await?, .await?,
); );
...@@ -1335,7 +1335,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( ...@@ -1335,7 +1335,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
page: match modules.global_not_found { page: match modules.global_not_found {
Some(v) => Some(v), Some(v) => Some(v),
None => Some(get_next_package(*app_dir) None => Some(get_next_package(*app_dir)
.join(rcstr!("dist/client/components/global-not-found.js")) .join(rcstr!("dist/client/components/builtin/global-not-found.js"))
.to_resolved() .to_resolved()
.await?), .await?),
}, },
...@@ -1348,7 +1348,7 @@ async fn directory_tree_to_entrypoints_internal_untraced( ...@@ -1348,7 +1348,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
page: match modules.not_found { page: match modules.not_found {
Some(v) => Some(v), Some(v) => Some(v),
None => Some(get_next_package(*app_dir) None => Some(get_next_package(*app_dir)
.join(rcstr!("dist/client/components/not-found-error.js")) .join(rcstr!("dist/client/components/builtin/not-found.js"))
.to_resolved() .to_resolved()
.await?), .await?),
}, },
......
...@@ -88,7 +88,7 @@ pub async fn get_app_page_entry( ...@@ -88,7 +88,7 @@ pub async fn get_app_page_entry(
"VAR_MODULE_GLOBAL_ERROR" => if inner_assets.contains_key(GLOBAL_ERROR) { "VAR_MODULE_GLOBAL_ERROR" => if inner_assets.contains_key(GLOBAL_ERROR) {
GLOBAL_ERROR.into() GLOBAL_ERROR.into()
} else { } else {
"next/dist/client/components/global-error".into() "next/dist/client/components/builtin/global-error".into()
}, },
}, },
fxindexmap! { fxindexmap! {
......
...@@ -305,7 +305,7 @@ export async function createPagesMapping({ ...@@ -305,7 +305,7 @@ export async function createPagesMapping({
// If there's any custom /_not-found page, it will override the default one. // If there's any custom /_not-found page, it will override the default one.
...(hasAppPages && { ...(hasAppPages && {
[UNDERSCORE_NOT_FOUND_ROUTE_ENTRY]: require.resolve( [UNDERSCORE_NOT_FOUND_ROUTE_ENTRY]: require.resolve(
'next/dist/client/components/global-not-found' 'next/dist/client/components/builtin/global-not-found'
), ),
}), }),
...pages, ...pages,
......
...@@ -1884,7 +1884,7 @@ export default async function build( ...@@ -1884,7 +1884,7 @@ export default async function build(
const pageFilePath = isAppBuiltinNotFoundPage(pagePath) const pageFilePath = isAppBuiltinNotFoundPage(pagePath)
? require.resolve( ? require.resolve(
'next/dist/client/components/not-found-error' 'next/dist/client/components/builtin/not-found'
) )
: path.join( : path.join(
(pageType === 'pages' ? pagesDir : appDir) || '', (pageType === 'pages' ? pagesDir : appDir) || '',
......
...@@ -1756,7 +1756,7 @@ export function isReservedPage(page: string) { ...@@ -1756,7 +1756,7 @@ export function isReservedPage(page: string) {
} }
export function isAppBuiltinNotFoundPage(page: string) { export function isAppBuiltinNotFoundPage(page: string) {
return /next[\\/]dist[\\/]client[\\/]components[\\/](not-found-error|global-not-found)/.test( return /next[\\/]dist[\\/]client[\\/]components[\\/]builtin[\\/](not-found|global-not-found)/.test(
page page
) )
} }
......
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
} from '../../../../shared/lib/segment' } from '../../../../shared/lib/segment'
import { getFilesInDir } from '../../../../lib/get-files-in-dir' import { getFilesInDir } from '../../../../lib/get-files-in-dir'
import type { PageExtensions } from '../../../page-extensions-type' import type { PageExtensions } from '../../../page-extensions-type'
import { PARALLEL_ROUTE_DEFAULT_PATH } from '../../../../client/components/parallel-route-default' import { PARALLEL_ROUTE_DEFAULT_PATH } from '../../../../client/components/builtin/default'
import type { Compilation } from 'webpack' import type { Compilation } from 'webpack'
import { createAppRouteCode } from './create-app-route-code' import { createAppRouteCode } from './create-app-route-code'
...@@ -59,9 +59,9 @@ const HTTP_ACCESS_FALLBACKS = { ...@@ -59,9 +59,9 @@ const HTTP_ACCESS_FALLBACKS = {
unauthorized: 'unauthorized', unauthorized: 'unauthorized',
} as const } as const
const defaultHTTPAccessFallbackPaths = { const defaultHTTPAccessFallbackPaths = {
'not-found': 'next/dist/client/components/not-found-error', 'not-found': 'next/dist/client/components/builtin/not-found.js',
forbidden: 'next/dist/client/components/forbidden-error', forbidden: 'next/dist/client/components/builtin/forbidden.js',
unauthorized: 'next/dist/client/components/unauthorized-error', unauthorized: 'next/dist/client/components/builtin/unauthorized.js',
} as const } as const
const FILE_TYPES = { const FILE_TYPES = {
...@@ -79,11 +79,12 @@ const GLOBAL_NOT_FOUND_FILE_TYPE = 'global-not-found' ...@@ -79,11 +79,12 @@ const GLOBAL_NOT_FOUND_FILE_TYPE = 'global-not-found'
const PAGE_SEGMENT = 'page$' const PAGE_SEGMENT = 'page$'
const PARALLEL_CHILDREN_SEGMENT = 'children$' const PARALLEL_CHILDREN_SEGMENT = 'children$'
const defaultGlobalErrorPath = 'next/dist/client/components/global-error.js' const defaultGlobalErrorPath =
const defaultNotFoundPath = 'next/dist/client/components/not-found-error.js' 'next/dist/client/components/builtin/global-error.js'
const defaultLayoutPath = 'next/dist/client/components/default-layout.js' const defaultNotFoundPath = 'next/dist/client/components/builtin/not-found.js'
const defaultLayoutPath = 'next/dist/client/components/builtin/layout.js'
const defaultGlobalNotFoundPath = const defaultGlobalNotFoundPath =
'next/dist/client/components/global-not-found.js' 'next/dist/client/components/builtin/global-not-found.js'
type DirResolver = (pathToResolve: string) => string type DirResolver = (pathToResolve: string) => string
type PathResolver = ( type PathResolver = (
......
...@@ -27,7 +27,7 @@ import type { ...@@ -27,7 +27,7 @@ import type {
import { setLinkForCurrentNavigation, type LinkInstance } from './links' import { setLinkForCurrentNavigation, type LinkInstance } from './links'
import type { FlightRouterState } from '../../server/app-render/types' import type { FlightRouterState } from '../../server/app-render/types'
import type { ClientInstrumentationHooks } from '../app-index' import type { ClientInstrumentationHooks } from '../app-index'
import type { GlobalErrorComponent } from './global-error' import type { GlobalErrorComponent } from './builtin/global-error'
export type DispatchStatePromise = React.Dispatch<ReducerState> export type DispatchStatePromise = React.Dispatch<ReducerState>
......
...@@ -23,7 +23,7 @@ import { ...@@ -23,7 +23,7 @@ import {
} from '../../shared/lib/hooks-client-context.shared-runtime' } from '../../shared/lib/hooks-client-context.shared-runtime'
import { dispatchAppRouterAction, useActionQueue } from './use-action-queue' import { dispatchAppRouterAction, useActionQueue } from './use-action-queue'
import { ErrorBoundary } from './error-boundary' import { ErrorBoundary } from './error-boundary'
import DefaultGlobalError from '../../client/components/global-error' import DefaultGlobalError from './builtin/global-error'
import { isBot } from '../../shared/lib/router/utils/is-bot' import { isBot } from '../../shared/lib/router/utils/is-bot'
import { addBasePath } from '../add-base-path' import { addBasePath } from '../add-base-path'
import { AppRouterAnnouncer } from './app-router-announcer' import { AppRouterAnnouncer } from './app-router-announcer'
......
import { notFound } from './not-found' import { notFound } from '../not-found'
export const PARALLEL_ROUTE_DEFAULT_PATH = export const PARALLEL_ROUTE_DEFAULT_PATH =
'next/dist/client/components/parallel-route-default.js' 'next/dist/client/components/builtin/default.js'
export default function ParallelRouteDefault() { export default function ParallelRouteDefault() {
notFound() notFound()
......
import { HTTPAccessErrorFallback } from './http-access-fallback/error-fallback' import { HTTPAccessErrorFallback } from '../http-access-fallback/error-fallback'
export default function Forbidden() { export default function Forbidden() {
return ( return (
......
'use client' 'use client'
import { HandleISRError } from './handle-isr-error' import { HandleISRError } from '../handle-isr-error'
const styles = { const styles = {
error: { error: {
......
import { HTTPAccessErrorFallback } from './http-access-fallback/error-fallback' import { HTTPAccessErrorFallback } from '../http-access-fallback/error-fallback'
function GlobalNotFound() { function GlobalNotFound() {
return ( return (
......
import { HTTPAccessErrorFallback } from './http-access-fallback/error-fallback' import { HTTPAccessErrorFallback } from '../http-access-fallback/error-fallback'
export default function NotFound() { export default function NotFound() {
return ( return (
......
import { HTTPAccessErrorFallback } from './http-access-fallback/error-fallback' import { HTTPAccessErrorFallback } from '../http-access-fallback/error-fallback'
export default function Unauthorized() { export default function Unauthorized() {
return ( return (
......
...@@ -12,7 +12,7 @@ import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-cs ...@@ -12,7 +12,7 @@ import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-cs
import { reportGlobalError } from './report-global-error' import { reportGlobalError } from './report-global-error'
import { originConsoleError } from '../../next-devtools/userspace/app/errors/intercept-console-error' import { originConsoleError } from '../../next-devtools/userspace/app/errors/intercept-console-error'
import { ErrorBoundaryHandler } from '../components/error-boundary' import { ErrorBoundaryHandler } from '../components/error-boundary'
import DefaultErrorBoundary from '../components/global-error' import DefaultErrorBoundary from '../components/builtin/global-error'
export function onCaughtError( export function onCaughtError(
thrownValue: unknown, thrownValue: unknown,
......
...@@ -2,7 +2,7 @@ import { PureComponent } from 'react' ...@@ -2,7 +2,7 @@ import { PureComponent } from 'react'
import { dispatcher } from 'next/dist/compiled/next-devtools' import { dispatcher } from 'next/dist/compiled/next-devtools'
import { RuntimeErrorHandler } from '../../../client/dev/runtime-error-handler' import { RuntimeErrorHandler } from '../../../client/dev/runtime-error-handler'
import { ErrorBoundary } from '../../../client/components/error-boundary' import { ErrorBoundary } from '../../../client/components/error-boundary'
import DefaultGlobalError from '../../../client/components/global-error' import DefaultGlobalError from '../../../client/components/builtin/global-error'
import type { GlobalErrorState } from '../../../client/components/app-router-instance' import type { GlobalErrorState } from '../../../client/components/app-router-instance'
type AppDevOverlayErrorBoundaryProps = { type AppDevOverlayErrorBoundaryProps = {
......
import React from 'react' import React from 'react'
import { getSocketUrl } from '../../../client/dev/hot-reloader/get-socket-url' import { getSocketUrl } from '../../../client/dev/hot-reloader/get-socket-url'
import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../server/dev/hot-reloader-types' import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../server/dev/hot-reloader-types'
import DefaultGlobalError from '../../../client/components/global-error' import DefaultGlobalError from '../../../client/components/builtin/global-error'
import { AppDevOverlayErrorBoundary } from './app-dev-overlay-error-boundary' import { AppDevOverlayErrorBoundary } from './app-dev-overlay-error-boundary'
// if an error is thrown while rendering an RSC stream, this will catch it in dev // if an error is thrown while rendering an RSC stream, this will catch it in dev
......
...@@ -199,7 +199,7 @@ import { ...@@ -199,7 +199,7 @@ import {
trackPendingModules, trackPendingModules,
} from './module-loading/track-module-loading.external' } from './module-loading/track-module-loading.external'
import { isReactLargeShellError } from './react-large-shell-error' import { isReactLargeShellError } from './react-large-shell-error'
import type { GlobalErrorComponent } from '../../client/components/global-error' import type { GlobalErrorComponent } from '../../client/components/builtin/global-error'
export type GetDynamicParamFromSegment = ( export type GetDynamicParamFromSegment = (
// [slug] / [[slug]] / [...slug] // [slug] / [[slug]] / [...slug]
......
...@@ -13,7 +13,7 @@ import { createComponentStylesAndScripts } from './create-component-styles-and-s ...@@ -13,7 +13,7 @@ import { createComponentStylesAndScripts } from './create-component-styles-and-s
import { getLayerAssets } from './get-layer-assets' import { getLayerAssets } from './get-layer-assets'
import { hasLoadingComponentInTree } from './has-loading-component-in-tree' import { hasLoadingComponentInTree } from './has-loading-component-in-tree'
import { validateRevalidate } from '../lib/patch-fetch' import { validateRevalidate } from '../lib/patch-fetch'
import { PARALLEL_ROUTE_DEFAULT_PATH } from '../../client/components/parallel-route-default' import { PARALLEL_ROUTE_DEFAULT_PATH } from '../../client/components/builtin/default'
import { getTracer } from '../lib/trace/tracer' import { getTracer } from '../lib/trace/tracer'
import { NextNodeServerSpan } from '../lib/trace/constants' import { NextNodeServerSpan } from '../lib/trace/constants'
import { StaticGenBailoutError } from '../../client/components/static-generation-bailout' import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'
...@@ -1109,7 +1109,7 @@ export function normalizeConventionFilePath( ...@@ -1109,7 +1109,7 @@ export function normalizeConventionFilePath(
) { ) {
const cwd = process.env.NEXT_RUNTIME === 'edge' ? '' : process.cwd() const cwd = process.env.NEXT_RUNTIME === 'edge' ? '' : process.cwd()
const nextInternalPrefixRegex = const nextInternalPrefixRegex =
/^(.*[\\/])?next[\\/]dist[\\/]client[\\/]components[\\/]/ /^(.*[\\/])?next[\\/]dist[\\/]client[\\/]components[\\/]builtin[\\/]/
let relativePath = (conventionPath || '') let relativePath = (conventionPath || '')
// remove turbopack [project] prefix // remove turbopack [project] prefix
......
...@@ -33,7 +33,7 @@ import { patchFetch as _patchFetch } from '../lib/patch-fetch' ...@@ -33,7 +33,7 @@ import { patchFetch as _patchFetch } from '../lib/patch-fetch'
// * ErrorBoundary -> client/components/error-boundary // * ErrorBoundary -> client/components/error-boundary
// * GlobalError -> client/components/global-error // * GlobalError -> client/components/global-error
import '../../client/components/error-boundary' import '../../client/components/error-boundary'
import '../../client/components/global-error' import '../../client/components/builtin/global-error'
import { import {
MetadataBoundary, MetadataBoundary,
ViewportBoundary, ViewportBoundary,
......
...@@ -473,7 +473,7 @@ export async function findPagePathData( ...@@ -473,7 +473,7 @@ export async function findPagePathData(
// If they're not presented, then fallback to global-not-found // If they're not presented, then fallback to global-not-found
return { return {
filename: require.resolve( filename: require.resolve(
'next/dist/client/components/global-not-found' 'next/dist/client/components/builtin/global-not-found'
), ),
bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`, bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,
page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY, page: UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,
......
...@@ -120,7 +120,7 @@ describe('segment-explorer', () => { ...@@ -120,7 +120,7 @@ describe('segment-explorer', () => {
expect(await getSegmentExplorerContent(browser)).toMatchInlineSnapshot(` expect(await getSegmentExplorerContent(browser)).toMatchInlineSnapshot(`
"app/ "app/
layout.tsx layout.tsx
not-found-error.js" not-found.js"
`) `)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment