Remove experimental.newNextLinkBehavior as it's stable (#54720)

Cleans up some code that is not used anymore as this feature went stable
in Next.js 13.

<!-- 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 #

-->
This commit is contained in:
Tim Neutkens 2023-08-29 22:49:00 +02:00 committed by GitHub
parent 593ec3096e
commit dc9f30c106
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 4 additions and 25 deletions

View file

@ -132,7 +132,7 @@ const TRANSFORMER_INQUIRER_CHOICES = [
value: 'cra-to-next',
},
{
name: 'new-link: Ensures your <Link> usage is backwards compatible. Used in combination with experimental newNextLinkBehavior',
name: 'new-link: Ensures your <Link> usage is backwards compatible.',
value: 'new-link',
},
{

View file

@ -1,6 +1,3 @@
// @ts-expect-error
process.env.__NEXT_NEW_LINK_BEHAVIOR = true
// eslint-disable-next-line no-undef
self.__next_require__ = __turbopack_require__

View file

@ -25,8 +25,6 @@ import { IncrementalCache } from 'next/dist/server/lib/incremental-cache'
installRequireAndChunkLoad()
process.env.__NEXT_NEW_LINK_BEHAVIOR = 'true'
const MIME_TEXT_HTML_UTF8 = 'text/html; charset=utf-8'
startOperationStreamHandler(async (renderData: RenderData, respond) => {

View file

@ -25,8 +25,6 @@ globalThis.__next_require__ = (data) => {
}
globalThis.__next_chunk_load__ = __turbopack_load__
process.env.__NEXT_NEW_LINK_BEHAVIOR = 'true'
const appElement = document
const getCacheKey = () => {

View file

@ -1,7 +1,6 @@
import { loadEnvConfig } from '@next/env'
import { resolve, join } from 'path'
import loadConfig from '../../server/config'
import type { NextConfigComplete } from '../../server/config-shared'
import { PHASE_TEST } from '../../shared/lib/constants'
import loadJsConfig from '../load-jsconfig'
import * as Log from '../output/log'
@ -31,13 +30,9 @@ function loadClosestPackageJson(dir: string, attempts = 1): any {
}
/** Loads dotenv files and sets environment variables based on next config. */
function setUpEnv(dir: string, nextConfig: NextConfigComplete) {
function setUpEnv(dir: string) {
const dev = false
loadEnvConfig(dir, dev, Log)
if (nextConfig.experimental.newNextLinkBehavior) {
process.env.__NEXT_NEW_LINK_BEHAVIOR = 'true'
}
}
/*
@ -82,7 +77,7 @@ export default function nextJest(options: { dir?: string } = {}) {
const findPagesDirResult = findPagesDir(resolvedDir, isAppDirEnabled)
hasServerComponents = !!findPagesDirResult.appDir
pagesDir = findPagesDirResult.pagesDir
setUpEnv(resolvedDir, nextConfig)
setUpEnv(resolvedDir)
// TODO: revisit when bug in SWC is fixed that strips `.css`
const result = await loadJsConfig(resolvedDir, nextConfig)
jsConfig = result.jsConfig

View file

@ -280,9 +280,6 @@ export function getDefineEnv({
'process.env.__NEXT_MANUAL_CLIENT_BASE_PATH': JSON.stringify(
config.experimental.manualClientBasePath
),
'process.env.__NEXT_NEW_LINK_BEHAVIOR': JSON.stringify(
config.experimental.newNextLinkBehavior
),
'process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED': JSON.stringify(
config.experimental.clientRouterFilter
),

View file

@ -276,8 +276,7 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkPropsReal>(
onClick,
onMouseEnter: onMouseEnterProp,
onTouchStart: onTouchStartProp,
// @ts-expect-error this is inlined as a literal boolean not a string
legacyBehavior = process.env.__NEXT_NEW_LINK_BEHAVIOR === false,
legacyBehavior = false,
...restProps
} = props

View file

@ -358,9 +358,6 @@ const configSchema = {
enum: ['strict', 'flexible'] as any,
type: 'string',
},
newNextLinkBehavior: {
type: 'boolean',
},
nextScriptWorkers: {
type: 'boolean',
},

View file

@ -165,7 +165,6 @@ export interface ExperimentalConfig {
optimisticClientCache?: boolean
middlewarePrefetch?: 'strict' | 'flexible'
manualClientBasePath?: boolean
newNextLinkBehavior?: boolean
// custom path to a cache handler to use
incrementalCacheHandlerPath?: string
disablePostcssPresetEnv?: boolean
@ -709,7 +708,6 @@ export const defaultConfig: NextConfig = {
middlewarePrefetch: 'flexible',
optimisticClientCache: true,
manualClientBasePath: false,
newNextLinkBehavior: true,
cpus: Math.max(
1,
(Number(process.env.CIRCLE_NODE_TOTAL) ||