Skip to content

Commit

Permalink
move swrDelta to experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianha committed Feb 19, 2024
1 parent 62e6a70 commit 2fefae4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@ export async function exportAppImpl(
: {}),
strictNextHead: !!nextConfig.experimental.strictNextHead,
deploymentId: nextConfig.experimental.deploymentId,
swrDelta: nextConfig.swrDelta,
experimental: {
ppr: nextConfig.experimental.ppr === true,
missingSuspenseWithCSRBailout:
nextConfig.experimental.missingSuspenseWithCSRBailout === true,
swrDelta: nextConfig.experimental.swrDelta,
},
}

Expand Down
7 changes: 6 additions & 1 deletion packages/next/src/server/app-render/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'
import type { ParsedUrlQuery } from 'querystring'
import type { AppPageModule } from '../future/route-modules/app-page/module'
import type { SwrDelta } from '../lib/revalidate'

import s from 'next/dist/compiled/superstruct'

Expand Down Expand Up @@ -143,7 +144,11 @@ export interface RenderOptsPartial {
}
params?: ParsedUrlQuery
isPrefetch?: boolean
experimental: { ppr: boolean; missingSuspenseWithCSRBailout: boolean }
experimental: {
ppr: boolean
missingSuspenseWithCSRBailout: boolean
swrDelta: SwrDelta | undefined
}
postponed?: string
}

Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,13 @@ export default abstract class Server<ServerOptions extends Options = Options> {

// @ts-expect-error internal field not publicly exposed
isExperimentalCompile: this.nextConfig.experimental.isExperimentalCompile,
swrDelta: this.nextConfig.swrDelta,
experimental: {
ppr:
this.enabledDirectories.app &&
this.nextConfig.experimental.ppr === true,
missingSuspenseWithCSRBailout:
this.nextConfig.experimental.missingSuspenseWithCSRBailout === true,
swrDelta: this.nextConfig.experimental.swrDelta,
},
}

Expand Down Expand Up @@ -1561,7 +1561,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
generateEtags,
poweredByHeader,
revalidate,
swrDelta: this.nextConfig.swrDelta,
swrDelta: this.nextConfig.experimental.swrDelta,
})
res.statusCode = originalStatus
}
Expand Down Expand Up @@ -2720,7 +2720,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
'Cache-Control',
formatRevalidate({
revalidate: cacheEntry.revalidate,
swrDelta: this.nextConfig.swrDelta,
swrDelta: this.nextConfig.experimental.swrDelta,
})
)
}
Expand All @@ -2742,7 +2742,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
'Cache-Control',
formatRevalidate({
revalidate: cacheEntry.revalidate,
swrDelta: this.nextConfig.swrDelta,
swrDelta: this.nextConfig.experimental.swrDelta,
})
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
basePath: z.string().optional(),
cacheHandler: z.string().min(1).optional(),
cacheMaxMemorySize: z.number().optional(),
swrDelta: z.number().optional(),
cleanDistDir: z.boolean().optional(),
compiler: z
.strictObject({
Expand Down Expand Up @@ -268,6 +267,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
externalMiddlewareRewritesResolve: z.boolean().optional(),
fallbackNodePolyfills: z.literal(false).optional(),
fetchCacheKeyPrefix: z.string().optional(),
swrDelta: z.number().optional(),
forceSwcTransforms: z.boolean().optional(),
fullySpecified: z.boolean().optional(),
gzipSize: z.boolean().optional(),
Expand Down
11 changes: 5 additions & 6 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ export interface ExperimentalConfig {
allowedRevalidateHeaderKeys?: string[]
fetchCacheKeyPrefix?: string
optimisticClientCache?: boolean
/**
* period (in seconds) where the server allow to serve stale cache
*/
swrDelta?: SwrDelta
middlewarePrefetch?: 'strict' | 'flexible'
manualClientBasePath?: boolean
/**
Expand Down Expand Up @@ -529,11 +533,6 @@ export interface NextConfig extends Record<string, any> {
*/
cacheMaxMemorySize?: number

/**
* period (in seconds) where the server allow to serve stale cache
*/
swrDelta?: SwrDelta | undefined

/**
* By default, `Next` will serve each file in the `pages` folder under a pathname matching the filename.
* To disable this behavior and prevent routing based set this to `true`.
Expand Down Expand Up @@ -786,7 +785,6 @@ export const defaultConfig: NextConfig = {
cacheHandler: undefined,
// default to 50MB limit
cacheMaxMemorySize: 50 * 1024 * 1024,
swrDelta: undefined,
configOrigin: 'default',
useFileSystemPublicRoutes: true,
generateBuildId: () => null,
Expand Down Expand Up @@ -840,6 +838,7 @@ export const defaultConfig: NextConfig = {
fetchCacheKeyPrefix: '',
middlewarePrefetch: 'flexible',
optimisticClientCache: true,
swrDelta: undefined,
manualClientBasePath: false,
cpus: Math.max(
1,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export default class NextNodeServer extends BaseServer {
generateEtags: options.generateEtags,
poweredByHeader: options.poweredByHeader,
revalidate: options.revalidate,
swrDelta: this.nextConfig.swrDelta,
swrDelta: options.swrDelta,
})
}

Expand Down

0 comments on commit 2fefae4

Please sign in to comment.