Move errorOnce imports into statements guarded by process.env.NODE_ENV === 'development' (#94782)

See https://github.com/vercel/next.js/pull/94781; cc @icyJoseph
This commit is contained in:
Sam Poder
2026-06-15 15:03:38 -07:00
committed by GitHub
parent e51bc264fa
commit 6d5dc2633d
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -22,7 +22,6 @@ import {
FetchStrategy,
type PrefetchTaskFetchStrategy,
} from '../components/segment-cache/types'
import { errorOnce } from '../../shared/lib/utils/error-once'
type Url = string | UrlObject
type RequiredKeys<T> = {
@@ -767,6 +766,8 @@ export default function LinkComponent(
if (legacyBehavior) {
if (process.env.NODE_ENV === 'development') {
const { errorOnce } =
require('../../shared/lib/utils/error-once') as typeof import('../../shared/lib/utils/error-once')
errorOnce(
'`legacyBehavior` is deprecated and will be removed in a future ' +
'release. A codemod is available to upgrade your components:\n\n' +
+2 -1
View File
@@ -18,7 +18,6 @@ import { useIntersection } from './use-intersection'
import { getDomainLocale } from './get-domain-locale'
import { addBasePath } from './add-base-path'
import { useMergedRef } from './use-merged-ref'
import { errorOnce } from '../shared/lib/utils/error-once'
type Url = string | UrlObject
type RequiredKeys<T> = {
@@ -707,6 +706,8 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkPropsReal>(
if (legacyBehavior) {
if (process.env.NODE_ENV === 'development') {
const { errorOnce } =
require('../shared/lib/utils/error-once') as typeof import('../shared/lib/utils/error-once')
errorOnce(
'`legacyBehavior` is deprecated and will be removed in a future ' +
'release. A codemod is available to upgrade your components:\n\n' +