Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove experimental.appDir as it's stable #54785

Merged
merged 4 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/jest/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = Boolean(appDir)
const hasServerComponents = hasAppDir
const disableOptimizedLoading = true
const enableTypedRoutes = !!config.experimental.typedRoutes && hasAppDir
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 5 additions & 10 deletions packages/next/src/cli/next-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,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
Expand All @@ -190,11 +188,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,
Expand All @@ -203,8 +198,8 @@ const nextLint: CliCommand = async (argv) => {
typeCheckPreflight: false,
tsconfigPath: nextConfig.typescript.tsconfigPath,
disableStaticImages: nextConfig.images.disableStaticImages,
hasAppDir: !!appDir,
hasPagesDir: !!pagesDir,
hasAppDir: Boolean(appDir),
hasPagesDir: Boolean(pagesDir),
})

runLintCheck(baseDir, pathsToLint, hasAppDir, {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/lib/turbopack-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const supportedTurbopackNextConfigOptions = [
'swcMinify',
'transpilePackages',
'sassOptions.includePaths',
'experimental.appDir',
'experimental.serverComponentsExternalPackages',
'experimental.turbo',
'experimental.mdxRs',
Expand Down
5 changes: 2 additions & 3 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
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()
Expand Down Expand Up @@ -1925,7 +1924,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
const renderOpts: RenderOpts = {
...components,
...opts,
...(isAppPath && this.nextConfig.experimental.appDir
...(isAppPath
? {
incrementalCache,
isRevalidate: isSSG,
Expand Down
10 changes: 2 additions & 8 deletions packages/next/src/server/dev/next-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 1 addition & 4 deletions packages/next/src/server/lib/route-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions packages/next/src/server/lib/router-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/web-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class NextWebServer extends BaseServer<WebServerOptions> {
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,
Expand Down