Skip to content

Commit 44851a7

Browse files
committed
[cache components] move experimental.cacheHandlers out of experimental
1 parent 3e10a73 commit 44851a7

File tree

24 files changed

+86
-101
lines changed

24 files changed

+86
-101
lines changed

crates/next-custom-transforms/src/transforms/server_actions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3191,7 +3191,7 @@ fn emit_error(error_kind: ServerActionsErrorKind) {
31913191
span,
31923192
formatdoc! {
31933193
r#"
3194-
Unknown cache kind "{cache_kind}". Please configure a cache handler for this kind in the `experimental.cacheHandlers` object in your Next.js config.
3194+
Unknown cache kind "{cache_kind}". Please configure a cache handler for this kind in the `cacheHandlers` object in your Next.js config.
31953195
"#
31963196
},
31973197
),

crates/next-custom-transforms/tests/errors/server-actions/server-graph/16/output.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x Unknown cache kind "x". Please configure a cache handler for this kind in the `experimental.cacheHandlers` object in your Next.js config.
1+
x Unknown cache kind "x". Please configure a cache handler for this kind in the `cacheHandlers` object in your Next.js config.
22
|
33
,-[input.js:1:1]
44
1 | 'use cache: x'

crates/next-custom-transforms/tests/errors/server-actions/server-graph/17/output.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x Unknown cache kind "x". Please configure a cache handler for this kind in the `experimental.cacheHandlers` object in your Next.js config.
1+
x Unknown cache kind "x". Please configure a cache handler for this kind in the `cacheHandlers` object in your Next.js config.
22
|
33
,-[input.js:2:1]
44
1 | export async function foo() {

packages/next/errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,5 +898,6 @@
898898
"897": "Expected HTML document to start with doctype prefix",
899899
"898": "When using Cache Components, all `generateStaticParams` functions must return at least one result. This is to ensure that we can perform build-time validation that there is no other dynamic accesses that would cause a runtime error.\n\nLearn more: https://nextjs.org/docs/messages/empty-generate-static-params",
900900
"899": "Both \"%s\" and \"%s\" files are detected. Please use \"%s\" instead. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy",
901-
"900": "Both %s file \"./%s\" and %s file \"./%s\" are detected. Please use \"./%s\" only. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy"
901+
"900": "Both %s file \"./%s\" and %s file \"./%s\" are detected. Please use \"./%s\" only. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy",
902+
"901": "Invalid \"cacheHandlers\" provided, expected an object e.g. { default: '/my-handler.js' }, received %s"
902903
}

packages/next/src/build/collect-build-traces.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ export async function collectBuildTraces({
124124
})
125125
)
126126

127-
const { cacheHandler } = config
128-
const { cacheHandlers } = config.experimental
127+
const { cacheHandler, cacheHandlers } = config
129128

130129
// ensure we trace any dependencies needed for custom
131130
// incremental cache handler

packages/next/src/build/entries.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,7 @@ export function getEdgeServerEntry(opts: {
616616
middlewareConfig: Buffer.from(
617617
JSON.stringify(opts.middlewareConfig || {})
618618
).toString('base64'),
619-
cacheHandlers: JSON.stringify(
620-
opts.config.experimental.cacheHandlers || {}
621-
),
619+
cacheHandlers: JSON.stringify(opts.config.cacheHandlers || {}),
622620
}
623621

624622
return {
@@ -685,7 +683,7 @@ export function getEdgeServerEntry(opts: {
685683
JSON.stringify(opts.middlewareConfig || {})
686684
).toString('base64'),
687685
serverActions: opts.config.experimental.serverActions,
688-
cacheHandlers: JSON.stringify(opts.config.experimental.cacheHandlers || {}),
686+
cacheHandlers: JSON.stringify(opts.config.cacheHandlers || {}),
689687
}
690688

691689
return {

packages/next/src/build/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ export default async function build(
22232223
cacheComponents: isAppCacheComponentsEnabled,
22242224
authInterrupts: isAuthInterruptsEnabled,
22252225
cacheHandler: config.cacheHandler,
2226-
cacheHandlers: config.experimental.cacheHandlers,
2226+
cacheHandlers: config.cacheHandlers,
22272227
isrFlushToDisk: ciEnvironment.hasNextSupport
22282228
? false
22292229
: config.experimental.isrFlushToDisk,
@@ -2518,7 +2518,7 @@ export default async function build(
25182518
const normalizedCacheHandlers: Record<string, string> = {}
25192519

25202520
for (const [key, value] of Object.entries(
2521-
config.experimental.cacheHandlers || {}
2521+
config.cacheHandlers || {}
25222522
)) {
25232523
if (key && value) {
25242524
normalizedCacheHandlers[key] = path.relative(distDir, value)
@@ -2538,9 +2538,9 @@ export default async function build(
25382538
cacheHandler: cacheHandler
25392539
? path.relative(distDir, cacheHandler)
25402540
: config.cacheHandler,
2541+
cacheHandlers: normalizedCacheHandlers,
25412542
experimental: {
25422543
...config.experimental,
2543-
cacheHandlers: normalizedCacheHandlers,
25442544
trustHostHeader: ciEnvironment.hasNextSupport,
25452545
isExperimentalCompile: isCompileMode,
25462546
},

packages/next/src/build/static-paths/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ export async function buildAppStaticPaths({
747747
isrFlushToDisk?: boolean
748748
fetchCacheKeyPrefix?: string
749749
cacheHandler?: string
750-
cacheHandlers?: NextConfigComplete['experimental']['cacheHandlers']
750+
cacheHandlers?: NextConfigComplete['cacheHandlers']
751751
cacheLifeProfiles?: {
752752
[profile: string]: import('../../server/use-cache/cache-life').CacheLife
753753
}

packages/next/src/build/swc/index.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -859,26 +859,20 @@ function bindingToApi(
859859
? path.relative(projectPath, nextConfigSerializable.cacheHandler)
860860
: nextConfigSerializable.cacheHandler)
861861
}
862-
if (nextConfigSerializable.experimental?.cacheHandlers) {
863-
nextConfigSerializable.experimental = {
864-
...nextConfigSerializable.experimental,
865-
cacheHandlers: Object.fromEntries(
866-
Object.entries(
867-
nextConfigSerializable.experimental.cacheHandlers as Record<
868-
string,
869-
string
870-
>
871-
)
872-
.filter(([_, value]) => value != null)
873-
.map(([key, value]) => [
874-
key,
875-
'./' +
876-
(path.isAbsolute(value)
877-
? path.relative(projectPath, value)
878-
: value),
879-
])
880-
),
881-
}
862+
if (nextConfigSerializable.cacheHandlers) {
863+
nextConfigSerializable.cacheHandlers = Object.fromEntries(
864+
Object.entries(
865+
nextConfigSerializable.cacheHandlers as Record<string, string>
866+
)
867+
.filter(([_, value]) => value != null)
868+
.map(([key, value]) => [
869+
key,
870+
'./' +
871+
(path.isAbsolute(value)
872+
? path.relative(projectPath, value)
873+
: value),
874+
])
875+
)
882876
}
883877

884878
if (nextConfigSerializable.turbopack != null) {

packages/next/src/build/swc/options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function getBaseSWCOptions({
9292
serverReferenceHashSalt: string
9393
bundleLayer?: WebpackLayerName
9494
isCacheComponents?: boolean
95-
cacheHandlers?: ExperimentalConfig['cacheHandlers']
95+
cacheHandlers?: NextConfig['cacheHandlers']
9696
useCacheEnabled?: boolean
9797
trackDynamicImports?: boolean
9898
}) {
@@ -412,7 +412,7 @@ export function getLoaderSWCOptions({
412412
serverComponents?: boolean
413413
serverReferenceHashSalt: string
414414
bundleLayer?: WebpackLayerName
415-
cacheHandlers: ExperimentalConfig['cacheHandlers']
415+
cacheHandlers: NextConfig['cacheHandlers']
416416
useCacheEnabled?: boolean
417417
trackDynamicImports?: boolean
418418
}) {

0 commit comments

Comments
 (0)