Skip to content

Commit

Permalink
Remove additional appDir checks (#54788)
Browse files Browse the repository at this point in the history
Followup to #54785 removing additional places where `.appDir` was used. 


<!-- 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 1aab5ee commit 0e1c85c
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub async fn get_app_entries(
server_compile_time_info: Vc<CompileTimeInfo>,
next_config: Vc<NextConfig>,
) -> Result<Vc<AppEntries>> {
let app_dir = find_app_dir_if_enabled(project_root, next_config);
let app_dir = find_app_dir_if_enabled(project_root);

let Some(&app_dir) = app_dir.await?.as_ref() else {
return Ok(AppEntries::cell(AppEntries {
Expand Down
8 changes: 1 addition & 7 deletions packages/next-swc/crates/next-core/src/app_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,7 @@ pub async fn find_app_dir(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionA
/// Finds and returns the [DirectoryTree] of the app directory if enabled and
/// existing.
#[turbo_tasks::function]
pub async fn find_app_dir_if_enabled(
project_path: Vc<FileSystemPath>,
next_config: Vc<NextConfig>,
) -> Result<Vc<OptionAppDir>> {
if !*next_config.app_dir().await? {
return Ok(Vc::cell(None));
}
pub async fn find_app_dir_if_enabled(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionAppDir>> {
Ok(find_app_dir(project_path))
}

Expand Down
13 changes: 0 additions & 13 deletions packages/next-swc/crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ pub enum LoaderItem {
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, TraceRawVcs)]
#[serde(rename_all = "camelCase")]
pub struct ExperimentalConfig {
pub app_dir: Option<bool>,
pub server_components_external_packages: Option<Vec<String>>,
pub turbo: Option<ExperimentalTurboConfig>,
pub allowed_revalidate_header_keys: Option<Vec<String>>,
Expand Down Expand Up @@ -527,18 +526,6 @@ impl NextConfig {
))
}

#[turbo_tasks::function]
pub async fn app_dir(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(
self.await?
.experimental
.app_dir
.as_ref()
.cloned()
.unwrap_or_default(),
))
}

#[turbo_tasks::function]
pub async fn env(self: Vc<Self>) -> Result<Vc<EnvMap>> {
// The value expected for env is Record<String, String>, but config itself
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/next-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ async fn source(
next_config,
server_addr,
);
let app_dir = find_app_dir_if_enabled(project_path, next_config);
let app_dir = find_app_dir_if_enabled(project_path);
let app_source = create_app_source(
app_dir,
project_path,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ startServer({
port: currentPort,
allowRetry: false,
keepAliveTimeout,
useWorkers: !!nextConfig.experimental?.appDir,
useWorkers: true,
}).catch((err) => {
console.error(err);
process.exit(1);
Expand Down
9 changes: 2 additions & 7 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CliCommand } from '../lib/commands'
import { getProjectDir } from '../lib/get-project-dir'
import { CONFIG_FILES, PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants'
import path from 'path'
import { defaultConfig, NextConfigComplete } from '../server/config-shared'
import { NextConfigComplete } from '../server/config-shared'
import { traceGlobals } from '../trace/shared'
import { Telemetry } from '../telemetry/storage'
import loadConfig from '../server/config'
Expand Down Expand Up @@ -352,12 +352,7 @@ const nextDev: CliCommand = async (argv) => {
})

const distDir = path.join(dir, rawNextConfig.distDir || '.next')
const { pagesDir, appDir } = findPagesDir(
dir,
typeof rawNextConfig?.experimental?.appDir === 'undefined'
? !!defaultConfig.experimental?.appDir
: !!rawNextConfig.experimental?.appDir
)
const { pagesDir, appDir } = findPagesDir(dir, true)
const telemetry = new Telemetry({
distDir,
})
Expand Down
3 changes: 0 additions & 3 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ const configSchema = {
},
] as any,
},
appDir: {
type: 'boolean',
},
serverActions: {
type: 'boolean',
},
Expand Down
8 changes: 1 addition & 7 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ export interface ExperimentalConfig {
nextScriptWorkers?: boolean
scrollRestoration?: boolean
externalDir?: boolean
/**
* The App Router (app directory) enables support for layouts, Server Components, streaming, and colocated data fetching.
* @see https://nextjs.org/docs/app/api-reference/next-config-js/appDir
*/
appDir?: boolean
amp?: {
optimizer?: any
validator?: string
Expand Down Expand Up @@ -702,7 +697,7 @@ export const defaultConfig: NextConfig = {
deploymentId: undefined,
useDeploymentIdServerActions: false,
appDocumentPreloading: undefined,
clientRouterFilter: false,
clientRouterFilter: true,
clientRouterFilterRedirects: false,
fetchCacheKeyPrefix: '',
middlewarePrefetch: 'flexible',
Expand All @@ -727,7 +722,6 @@ export const defaultConfig: NextConfig = {
gzipSize: true,
craCompat: false,
esmExternals: true,
appDir: true,
// default to 50MB limit
isrMemoryCacheSize: 50 * 1024 * 1024,
incrementalCacheHandlerPath: undefined,
Expand Down
7 changes: 0 additions & 7 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,6 @@ function assignDefaults(
silent
)

if (
typeof userConfig.experimental?.clientRouterFilter === 'undefined' &&
result.experimental?.appDir
) {
result.experimental.clientRouterFilter = true
}

if (
result.experimental?.outputFileTracingRoot &&
!isAbsolute(result.experimental.outputFileTracingRoot)
Expand Down

0 comments on commit 0e1c85c

Please sign in to comment.