Revert "Add experimental config for navigation raf test (#62668)" (#62834)

Reverting this experimental flag as it should not be used and we are
going to investigate experimenting with this further upstream so that it
can be done properly.

This reverts commit 2bdcaa0fda.

x-ref: https://github.com/vercel/next.js/pull/62668



Closes NEXT-2689
This commit is contained in:
JJ Kasper 2024-03-04 12:39:41 -08:00 committed by GitHub
parent 6e89226615
commit 5717b9a14d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 63 deletions

View file

@ -194,9 +194,6 @@ export function getDefineEnv({
'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE': JSON.stringify(
config.skipMiddlewareUrlNormalize
),
'process.env.__NEXT_NAVIGATION_RAF': JSON.stringify(
config.experimental.navigationRAF
),
'process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE': JSON.stringify(
config.experimental.externalMiddlewareRewritesResolve
),

View file

@ -225,28 +225,6 @@ function useChangeByServerResponse(
function useNavigate(dispatch: React.Dispatch<ReducerActions>): RouterNavigate {
return useCallback(
(href, navigateType, shouldScroll) => {
const navigateWrapper = process.env.__NEXT_NAVIGATION_RAF
? (cb: () => void) => {
let finished = false
// if the frame is hidden or requestAnimationFrame
// is delayed too long add upper bound timeout
setTimeout(() => {
if (!finished) {
finished = true
cb()
}
}, 1000)
requestAnimationFrame(() => {
setTimeout(() => {
finished = true
cb()
}, 1)
})
}
: (cb: () => void) => cb()
navigateWrapper(() => {
const url = new URL(addBasePath(href), location.href)
return dispatch({
@ -257,7 +235,6 @@ function useNavigate(dispatch: React.Dispatch<ReducerActions>): RouterNavigate {
shouldScroll: shouldScroll ?? true,
navigateType,
})
})
},
[dispatch]
)

View file

@ -277,7 +277,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
manualClientBasePath: z.boolean().optional(),
middlewarePrefetch: z.enum(['strict', 'flexible']).optional(),
mergeCssChunks: z.boolean().optional(),
navigationRAF: z.boolean().optional(),
nextScriptWorkers: z.boolean().optional(),
// The critter option is unknown, use z.any() here
optimizeCss: z.union([z.boolean(), z.any()]).optional(),

View file

@ -167,7 +167,6 @@ export interface NextJsWebpackConfig {
}
export interface ExperimentalConfig {
navigationRAF?: boolean
prerenderEarlyExit?: boolean
linkNoTouchStart?: boolean
caseSensitiveRoutes?: boolean
@ -844,7 +843,6 @@ export const defaultConfig: NextConfig = {
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
modularizeImports: undefined,
experimental: {
navigationRAF: false,
prerenderEarlyExit: false,
serverMinification: true,
serverSourceMaps: false,

View file

@ -1498,8 +1498,7 @@ export default class Router implements BaseRouter {
const isErrorRoute = this.pathname === '/404' || this.pathname === '/_error'
try {
let [routeInfo] = await Promise.all([
this.getRouteInfo({
let routeInfo = await this.getRouteInfo({
route,
pathname,
query,
@ -1512,18 +1511,7 @@ export default class Router implements BaseRouter {
unstable_skipClientCache: options.unstable_skipClientCache,
isQueryUpdating: isQueryUpdating && !this.isFallback,
isMiddlewareRewrite,
}),
process.env.__NEXT_NAVIGATION_RAF
? new Promise((resolve) => {
// if the frame is hidden or requestAnimationFrame
// is delayed too long add upper bound timeout
setTimeout(resolve, 1000)
requestAnimationFrame(() => {
setTimeout(resolve, 1)
})
})
: Promise.resolve(),
])
if (!isQueryUpdating && !options.shallow) {
await this._bfl(