Skip to content

Commit

Permalink
Remove experimental config from create-next-app (#49241)
Browse files Browse the repository at this point in the history
## What?

Removes `experimental.appDir` this was leftover from when I flipped the
switch.

Kept the config file as in the future we might add future flags and
such. It also helps that it has the types comment included so you always
get types.

<!-- 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 or adding/fixing 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 #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
timneutkens and ijjk authored May 5, 2023
1 parent c881224 commit 25a9547
Show file tree
Hide file tree
Showing 99 changed files with 78 additions and 344 deletions.
6 changes: 1 addition & 5 deletions packages/create-next-app/templates/app-tw/js/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
const nextConfig = {}

module.exports = nextConfig
6 changes: 1 addition & 5 deletions packages/create-next-app/templates/app-tw/ts/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
const nextConfig = {}

module.exports = nextConfig
6 changes: 1 addition & 5 deletions packages/create-next-app/templates/app/js/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
const nextConfig = {}

module.exports = nextConfig
6 changes: 1 addition & 5 deletions packages/create-next-app/templates/app/ts/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
const nextConfig = {}

module.exports = nextConfig
10 changes: 8 additions & 2 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import isError from '../lib/is-error'
import { getProjectDir } from '../lib/get-project-dir'
import { CONFIG_FILES, PHASE_DEVELOPMENT_SERVER } from '../shared/lib/constants'
import path from 'path'
import type { NextConfig, NextConfigComplete } from '../server/config-shared'
import {
defaultConfig,
NextConfig,
NextConfigComplete,
} from '../server/config-shared'
import { traceGlobals } from '../trace/shared'
import { Telemetry } from '../telemetry/storage'
import loadConfig from '../server/config'
Expand Down Expand Up @@ -239,7 +243,9 @@ const nextDev: CliCommand = async (argv) => {
const distDir = path.join(dir, rawNextConfig.distDir || '.next')
const { pagesDir, appDir } = findPagesDir(
dir,
!!rawNextConfig.experimental?.appDir
typeof rawNextConfig?.experimental?.appDir === 'undefined'
? !!defaultConfig.experimental?.appDir
: !!rawNextConfig.experimental?.appDir
)
const telemetry = new Telemetry({
distDir,
Expand Down
6 changes: 3 additions & 3 deletions packages/next/src/lib/turbopack-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function validateTurboNextConfig({
let keys: string[] = []

for (const key in obj) {
if (typeof obj[key] === 'undefined') {
if (typeof obj?.[key] === 'undefined') {
continue
}

Expand All @@ -145,9 +145,9 @@ export async function validateTurboNextConfig({
keys = keys.split('.')
}
if (keys.length === 1) {
return obj[keys[0]]
return obj?.[keys?.[0]]
}
return getDeepValue(obj[keys[0]], keys.slice(1))
return getDeepValue(obj?.[keys?.[0]], keys.slice(1))
}

const customKeys = flattenKeys(rawNextConfig)
Expand Down
18 changes: 7 additions & 11 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@ function assignDefaults(
for (const featureName of Object.keys(
value
) as (keyof ExperimentalConfig)[]) {
const featureValue = value[featureName]
if (featureName === 'appDir' && featureValue === true) {
// auto enable clientRouterFilter if not manually set
// when appDir is enabled
if (
typeof userConfig.experimental.clientRouterFilter ===
'undefined'
) {
userConfig.experimental.clientRouterFilter = true
}
}
if (
value[featureName] !== defaultConfig.experimental[featureName]
) {
Expand Down Expand Up @@ -456,6 +445,13 @@ 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
6 changes: 1 addition & 5 deletions test/.stats-app/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}

// For development: analyze the bundled chunks for stats app
if (process.env.ANALYZE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const withMDX = require('@next/mdx')()
module.exports = withMDX({
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
experimental: {
appDir: true,
mdxRs: true,
},
images: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = {
experimental: { appDir: true },
}
module.exports = {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: { appDir: true },
}
const nextConfig = {}

module.exports = nextConfig
6 changes: 1 addition & 5 deletions test/development/app-hmr/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/**
* @type {import('next').NextConfig}
*/
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
4 changes: 1 addition & 3 deletions test/development/app-render-error-log/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = {
experimental: { appDir: true },
}
module.exports = {}
6 changes: 1 addition & 5 deletions test/development/basic/node-builtins/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
4 changes: 1 addition & 3 deletions test/development/next-font/build-errors/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = {
experimental: { appDir: true },
}
module.exports = {}
6 changes: 1 addition & 5 deletions test/e2e/app-dir-legacy-edge-runtime-config/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: { appDir: true },
}
const nextConfig = {}

module.exports = nextConfig
1 change: 0 additions & 1 deletion test/e2e/app-dir/actions/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
appDir: true,
serverActions: true,
},
}
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-a11y/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-alias/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export default {
experimental: {
appDir: true,
},
}
export default {}
3 changes: 0 additions & 3 deletions test/e2e/app-dir/app-basepath/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
module.exports = {
basePath: '/base',
experimental: {
appDir: true,
},
}
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-client-cache/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
3 changes: 0 additions & 3 deletions test/e2e/app-dir/app-css-pageextensions/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const nextConfig = {
pageExtensions: ['page.jsx', 'page.js'],
experimental: {
appDir: true,
},
}

module.exports = nextConfig
1 change: 0 additions & 1 deletion test/e2e/app-dir/app-css/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const withMDX = mdx()
const nextConfig = {
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
experimental: {
appDir: true,
mdxRs: true,
},
}
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-edge/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
1 change: 0 additions & 1 deletion test/e2e/app-dir/app-external/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
reactStrictMode: true,
transpilePackages: ['untranspiled-module', 'css', 'font'],
experimental: {
appDir: true,
serverComponentsExternalPackages: ['conditional-exports-optout'],
},
}
1 change: 0 additions & 1 deletion test/e2e/app-dir/app-middleware/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
experimental: {
appDir: true,
clientRouterFilter: true,
clientRouterFilterRedirects: true,
},
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-prefetch/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-rendering/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
1 change: 0 additions & 1 deletion test/e2e/app-dir/app-routes-trailing-slash/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
const nextConfig = {
trailingSlash: true,
experimental: { appDir: true },
}

module.exports = nextConfig
3 changes: 0 additions & 3 deletions test/e2e/app-dir/app-routes/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
* @type {import('next').NextConfig}
*/
module.exports = {
experimental: {
appDir: true,
},
typescript: {
ignoreBuildErrors: true,
},
Expand Down
1 change: 0 additions & 1 deletion test/e2e/app-dir/app-static/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**@type import('next').NextConfig */
module.exports = {
experimental: {
appDir: true,
incrementalCacheHandlerPath: process.env.CUSTOM_CACHE_HANDLER
? require.resolve('./cache-handler.js')
: undefined,
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/app-dir/app-validation/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
1 change: 0 additions & 1 deletion test/e2e/app-dir/app/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
experimental: {
appDir: true,
clientRouterFilterRedirects: true,
sri: {
algorithm: 'sha256',
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/app-dir/asset-prefix/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = {
experimental: {
appDir: true,
},
assetPrefix: '/assets',
rewrites() {
return {
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/app-dir/async-component-preload/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @type {import("next").NextConfig} */
module.exports = {
reactStrictMode: true,
experimental: { appDir: true },
}
3 changes: 0 additions & 3 deletions test/e2e/app-dir/back-button-download-bug/next.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
experimental: {
appDir: true,
},
images: {
domains: ['res.cloudinary.com', 'avatars.githubusercontent.com'],
},
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/app-dir/create-next-app-template/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
})

/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
const nextConfig = {}

// module.exports = nextConfig
module.exports = withBundleAnalyzer(nextConfig)
6 changes: 1 addition & 5 deletions test/e2e/app-dir/create-root-layout/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
4 changes: 1 addition & 3 deletions test/e2e/app-dir/crypto-globally-available/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: { appDir: true },
}
const nextConfig = {}

module.exports = nextConfig
6 changes: 1 addition & 5 deletions test/e2e/app-dir/draft-mode/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {
experimental: {
appDir: true,
},
}
module.exports = {}
Loading

0 comments on commit 25a9547

Please sign in to comment.