diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index c9925716d8a9b..3bc1c9eaef520 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -405,7 +405,7 @@ export default async function build( setGlobal('telemetry', telemetry) const publicDir = path.join(dir, 'public') - const isAppDirEnabled = !!config.experimental.appDir + const isAppDirEnabled = true const { pagesDir, appDir } = findPagesDir(dir, isAppDirEnabled) NextBuildContext.pagesDir = pagesDir NextBuildContext.appDir = appDir diff --git a/packages/next/src/build/jest/jest.ts b/packages/next/src/build/jest/jest.ts index db3c1a9c440cd..5bb279c17ebaa 100644 --- a/packages/next/src/build/jest/jest.ts +++ b/packages/next/src/build/jest/jest.ts @@ -73,7 +73,7 @@ export default function nextJest(options: { dir?: string } = {}) { isEsmProject = packageConfig.type === 'module' nextConfig = await getConfig(resolvedDir) - const isAppDirEnabled = !!nextConfig.experimental.appDir + const isAppDirEnabled = true const findPagesDirResult = findPagesDir(resolvedDir, isAppDirEnabled) hasServerComponents = !!findPagesDirResult.appDir pagesDir = findPagesDirResult.pagesDir diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 21cf63283dc2d..f2bf6bd7923ff 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -293,12 +293,8 @@ export function getDefineEnv({ config.reactStrictMode === null ? false : config.reactStrictMode ), 'process.env.__NEXT_STRICT_MODE_APP': JSON.stringify( - // When next.config.js does not have reactStrictMode enabling appDir will enable it. - config.reactStrictMode === null - ? config.experimental.appDir - ? true - : false - : config.reactStrictMode + // When next.config.js does not have reactStrictMode it's enabled by default. + config.reactStrictMode === null ? true : config.reactStrictMode ), 'process.env.__NEXT_OPTIMIZE_FONTS': JSON.stringify( !dev && config.optimizeFonts @@ -791,7 +787,7 @@ export default async function getBaseWebpackConfig( rewrites.afterFiles.length > 0 || rewrites.fallback.length > 0 - const hasAppDir = !!config.experimental.appDir && !!appDir + const hasAppDir = !!appDir const hasServerComponents = hasAppDir const disableOptimizedLoading = true const enableTypedRoutes = !!config.experimental.typedRoutes && hasAppDir @@ -2710,7 +2706,6 @@ export default async function getBaseWebpackConfig( } const configVars = JSON.stringify({ - appDir: config.experimental.appDir, crossOrigin: config.crossOrigin, pageExtensions: pageExtensions, trailingSlash: config.trailingSlash, diff --git a/packages/next/src/cli/next-lint.ts b/packages/next/src/cli/next-lint.ts index e4832fc3c6f9d..3370cfc53397e 100755 --- a/packages/next/src/cli/next-lint.ts +++ b/packages/next/src/cli/next-lint.ts @@ -5,10 +5,7 @@ import { join } from 'path' import chalk from 'next/dist/compiled/chalk' import { CliCommand } from '../lib/commands' -import { - ESLINT_DEFAULT_DIRS, - ESLINT_DEFAULT_DIRS_WITH_APP, -} from '../lib/constants' +import { ESLINT_DEFAULT_DIRS_WITH_APP } from '../lib/constants' import { runLintCheck } from '../lib/eslint/runLintCheck' import { printAndExit } from '../server/lib/utils' import { Telemetry } from '../telemetry/storage' @@ -169,9 +166,7 @@ const nextLint: CliCommand = async (argv) => { const filesToLint = [...(dirs ?? []), ...files] // Remove that when the `appDir` will be stable. - const directoriesToLint = !!nextConfig.experimental.appDir - ? ESLINT_DEFAULT_DIRS_WITH_APP - : ESLINT_DEFAULT_DIRS + const directoriesToLint = ESLINT_DEFAULT_DIRS_WITH_APP const pathsToLint = ( filesToLint.length ? filesToLint : directoriesToLint @@ -190,11 +185,8 @@ const nextLint: CliCommand = async (argv) => { const distDir = join(baseDir, nextConfig.distDir) const defaultCacheLocation = join(distDir, 'cache', 'eslint/') - const hasAppDir = !!nextConfig.experimental.appDir - const { pagesDir, appDir } = findPagesDir( - baseDir, - !!nextConfig.experimental.appDir - ) + const hasAppDir = true + const { pagesDir, appDir } = findPagesDir(baseDir, hasAppDir) await verifyTypeScriptSetup({ dir: baseDir, diff --git a/packages/next/src/export/index.ts b/packages/next/src/export/index.ts index 37801f74bb6df..7e6c2f355c0c8 100644 --- a/packages/next/src/export/index.ts +++ b/packages/next/src/export/index.ts @@ -721,7 +721,7 @@ export default async function exportApp( httpAgentOptions: nextConfig.httpAgentOptions, debugOutput: options.debugOutput, isrMemoryCacheSize: nextConfig.experimental.isrMemoryCacheSize, - fetchCache: nextConfig.experimental.appDir, + fetchCache: true, fetchCacheKeyPrefix: nextConfig.experimental.fetchCacheKeyPrefix, incrementalCacheHandlerPath: nextConfig.experimental.incrementalCacheHandlerPath, diff --git a/packages/next/src/lib/turbopack-warning.ts b/packages/next/src/lib/turbopack-warning.ts index a7202f3208dcc..a54f6e732ebe8 100644 --- a/packages/next/src/lib/turbopack-warning.ts +++ b/packages/next/src/lib/turbopack-warning.ts @@ -20,7 +20,6 @@ const supportedTurbopackNextConfigOptions = [ 'swcMinify', 'transpilePackages', 'sassOptions.includePaths', - 'experimental.appDir', 'experimental.serverComponentsExternalPackages', 'experimental.turbo', 'experimental.mdxRs', diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index 5baafaa487ae4..2229e95293b94 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -426,8 +426,7 @@ export default abstract class Server { this.buildId = this.getBuildId() this.minimalMode = minimalMode || !!process.env.NEXT_PRIVATE_MINIMAL_MODE - this.hasAppDir = - !!this.nextConfig.experimental.appDir && this.getHasAppDir(dev) + this.hasAppDir = this.getHasAppDir(dev) const serverComponents = this.hasAppDir this.nextFontManifest = this.getNextFontManifest() @@ -1925,7 +1924,7 @@ export default abstract class Server { const renderOpts: RenderOpts = { ...components, ...opts, - ...(isAppPath && this.nextConfig.experimental.appDir + ...(isAppPath ? { incrementalCache, isRevalidate: isSSG, diff --git a/packages/next/src/server/dev/next-dev-server.ts b/packages/next/src/server/dev/next-dev-server.ts index 985d283931bdf..a5860b9ef0fa1 100644 --- a/packages/next/src/server/dev/next-dev-server.ts +++ b/packages/next/src/server/dev/next-dev-server.ts @@ -180,19 +180,13 @@ export default class DevServer extends Server { }) } - const { pagesDir, appDir } = findPagesDir( - this.dir, - !!this.nextConfig.experimental.appDir - ) + const { pagesDir, appDir } = findPagesDir(this.dir, true) this.pagesDir = pagesDir this.appDir = appDir } protected getRouteMatchers(): RouteMatcherManager { - const { pagesDir, appDir } = findPagesDir( - this.dir, - !!this.nextConfig.experimental.appDir - ) + const { pagesDir, appDir } = findPagesDir(this.dir, true) const ensurer: RouteEnsurer = { ensure: async (match) => { diff --git a/packages/next/src/server/lib/route-resolver.ts b/packages/next/src/server/lib/route-resolver.ts index 3334faee33393..83e122f2cc70a 100644 --- a/packages/next/src/server/lib/route-resolver.ts +++ b/packages/next/src/server/lib/route-resolver.ts @@ -66,10 +66,7 @@ export async function makeResolver( minimalMode: false, config: nextConfig, }) - const { appDir, pagesDir } = findPagesDir( - dir, - !!nextConfig.experimental.appDir - ) + const { appDir, pagesDir } = findPagesDir(dir, true) // we format the hostname so that it can be fetched const fetchHostname = formatHostname(hostname) diff --git a/packages/next/src/server/lib/router-server.ts b/packages/next/src/server/lib/router-server.ts index 4ee410d449672..44e73f698613f 100644 --- a/packages/next/src/server/lib/router-server.ts +++ b/packages/next/src/server/lib/router-server.ts @@ -104,10 +104,7 @@ export async function initialize(opts: { const telemetry = new Telemetry({ distDir: path.join(opts.dir, config.distDir), }) - const { pagesDir, appDir } = findPagesDir( - opts.dir, - !!config.experimental.appDir - ) + const { pagesDir, appDir } = findPagesDir(opts.dir, true) const { setupDev } = (await require('./router-utils/setup-dev')) as typeof import('./router-utils/setup-dev') diff --git a/packages/next/src/server/next-server.ts b/packages/next/src/server/next-server.ts index 9bbfef0786a06..eef8514491d82 100644 --- a/packages/next/src/server/next-server.ts +++ b/packages/next/src/server/next-server.ts @@ -300,7 +300,7 @@ export default class NextNodeServer extends BaseServer { this.nextConfig.experimental.allowedRevalidateHeaderKeys, minimalMode: this.minimalMode, serverDistDir: this.serverDistDir, - fetchCache: this.nextConfig.experimental.appDir, + fetchCache: true, fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix, maxMemoryCacheSize: this.nextConfig.experimental.isrMemoryCacheSize, flushToDisk: diff --git a/packages/next/src/server/web-server.ts b/packages/next/src/server/web-server.ts index b347467d9ed43..525aa6b2c0c49 100644 --- a/packages/next/src/server/web-server.ts +++ b/packages/next/src/server/web-server.ts @@ -68,7 +68,7 @@ export default class NextWebServer extends BaseServer { allowedRevalidateHeaderKeys: this.nextConfig.experimental.allowedRevalidateHeaderKeys, minimalMode: this.minimalMode, - fetchCache: this.nextConfig.experimental.appDir, + fetchCache: true, fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix, maxMemoryCacheSize: this.nextConfig.experimental.isrMemoryCacheSize, flushToDisk: false,