Skip to content

Commit

Permalink
Remove experimental.appDir as it's stable (#54785)
Browse files Browse the repository at this point in the history
Removes the experimental option as it has been shipped.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
  • Loading branch information
timneutkens authored Aug 30, 2023
1 parent f567aaf commit 3fbbfeb
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 45 deletions.
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 = !!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
16 changes: 4 additions & 12 deletions packages/next/src/cli/next-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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,
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

0 comments on commit 3fbbfeb

Please sign in to comment.