Skip to content

Commit fff99fa

Browse files
committed
[cache components]: move flag out of experimental
1 parent b38921d commit fff99fa

File tree

168 files changed

+1219
-1423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+1219
-1423
lines changed

.github/workflows/build_and_test.yml

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,12 @@ jobs:
681681

682682
secrets: inherit
683683

684-
test-new-tests-deploy-experimental:
685-
name: Test new tests when deployed (experimental)
684+
test-new-tests-deploy-cache-components:
685+
name: Test new tests when deployed (cache components)
686686
needs:
687687
[
688688
'optimize-ci',
689-
'test-experimental-prod',
689+
'test-cache-components-prod',
690690
'test-new-tests-dev',
691691
'test-new-tests-start',
692692
]
@@ -702,15 +702,15 @@ jobs:
702702
uses: ./.github/workflows/build_reusable.yml
703703
with:
704704
afterBuild: |
705-
export __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true
705+
export __NEXT_CACHE_COMPONENTS=true
706706
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
707-
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
707+
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
708708
export NEXT_E2E_TEST_TIMEOUT=240000
709709
export GH_PR_NUMBER=${{ github.event.pull_request && github.event.pull_request.number || '' }}
710710
node scripts/test-new-tests.mjs \
711711
--mode deploy \
712712
--group ${{ matrix.group }}
713-
stepName: 'test-new-tests-deploy-experimental-${{matrix.group}}'
713+
stepName: 'test-new-tests-deploy-cache-components-${{matrix.group}}'
714714

715715
secrets: inherit
716716

@@ -921,31 +921,29 @@ jobs:
921921
stepName: 'test-firefox-safari'
922922
secrets: inherit
923923

924-
# TODO: Disable these when no more experiments are tested
925924
# Manifest generated via: https://gist.github.com/wyattjoh/2ceaebd82a5bcff4819600fd60126431
926-
test-experimental-integration:
927-
name: test experimental integration
925+
test-cache-components-integration:
926+
name: test cache components integration
928927
needs: ['optimize-ci', 'changes', 'build-native', 'build-next']
929928
if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
930929

931930
uses: ./.github/workflows/build_reusable.yml
932931
with:
933932
nodeVersion: 20.9.0
934933
afterBuild: |
935-
export __NEXT_EXPERIMENTAL_PPR=true # for compatibility with the existing tests
936-
export __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true
934+
export __NEXT_CACHE_COMPONENTS=true
937935
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
938-
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
936+
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
939937
export IS_WEBPACK_TEST=1
940938
941939
node run-tests.js \
942940
--timings \
943941
--type integration
944-
stepName: 'test-experimental-integration'
942+
stepName: 'test-cache-components-integration'
945943
secrets: inherit
946944

947-
test-experimental-dev:
948-
name: test experimental dev
945+
test-cache-components-dev:
946+
name: test cache components dev
949947
needs: ['optimize-ci', 'changes', 'build-native', 'build-next']
950948
if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
951949

@@ -956,22 +954,21 @@ jobs:
956954
uses: ./.github/workflows/build_reusable.yml
957955
with:
958956
afterBuild: |
959-
export __NEXT_EXPERIMENTAL_PPR=true # for compatibility with the existing tests
960-
export __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true
957+
export __NEXT_CACHE_COMPONENTS=true
961958
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
962-
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
959+
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
963960
export NEXT_TEST_MODE=dev
964961
export IS_WEBPACK_TEST=1
965962
966963
node run-tests.js \
967964
--timings \
968965
-g ${{ matrix.group }} \
969966
--type development
970-
stepName: 'test-experimental-dev-${{ matrix.group }}'
967+
stepName: 'test-cache-components-dev-${{ matrix.group }}'
971968
secrets: inherit
972969

973-
test-experimental-prod:
974-
name: test experimental prod
970+
test-cache-components-prod:
971+
name: test cache components prod
975972
needs: ['optimize-ci', 'changes', 'build-native', 'build-next']
976973
if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
977974

@@ -982,18 +979,17 @@ jobs:
982979
uses: ./.github/workflows/build_reusable.yml
983980
with:
984981
afterBuild: |
985-
export __NEXT_EXPERIMENTAL_PPR=true # for compatibility with the existing tests
986-
export __NEXT_EXPERIMENTAL_CACHE_COMPONENTS=true
982+
export __NEXT_CACHE_COMPONENTS=true
987983
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
988-
export NEXT_EXTERNAL_TESTS_FILTERS="test/experimental-tests-manifest.json"
984+
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
989985
export NEXT_TEST_MODE=start
990986
export IS_WEBPACK_TEST=1
991987
992988
node run-tests.js \
993989
--timings \
994990
-g ${{ matrix.group }} \
995991
--type production
996-
stepName: 'test-experimental-prod-${{ matrix.group }}'
992+
stepName: 'test-cache-components-prod-${{ matrix.group }}'
997993
secrets: inherit
998994

999995
tests-pass:
@@ -1011,9 +1007,9 @@ jobs:
10111007
'test-prod',
10121008
'test-integration',
10131009
'test-firefox-safari',
1014-
'test-experimental-dev',
1015-
'test-experimental-prod',
1016-
'test-experimental-integration',
1010+
'test-cache-components-dev',
1011+
'test-cache-components-prod',
1012+
'test-cache-components-integration',
10171013
'test-cargo-unit',
10181014
'rust-check',
10191015
'rustdoc-check',
@@ -1023,7 +1019,7 @@ jobs:
10231019
'test-new-tests-dev',
10241020
'test-new-tests-start',
10251021
'test-new-tests-deploy',
1026-
'test-new-tests-deploy-experimental',
1022+
'test-new-tests-deploy-cache-components',
10271023
'test-turbopack-production',
10281024
'test-turbopack-production-integration',
10291025
'test-unit-windows',

crates/next-core/src/next_config.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ pub struct NextConfig {
154154
target: Option<String>,
155155
typescript: TypeScriptConfig,
156156
use_file_system_public_routes: bool,
157+
cache_components: Option<bool>,
157158
webpack: Option<serde_json::Value>,
158159
}
159160

@@ -810,6 +811,8 @@ pub struct ExperimentalConfig {
810811
web_vitals_attribution: Option<Vec<RcStr>>,
811812
server_actions: Option<ServerActionsOrLegacyBool>,
812813
sri: Option<SubResourceIntegrity>,
814+
/// @deprecated - use top-level cache_components instead.
815+
/// This field is kept for backwards compatibility during migration.
813816
cache_components: Option<bool>,
814817
use_cache: Option<bool>,
815818
root_params: Option<bool>,
@@ -1733,7 +1736,7 @@ impl NextConfig {
17331736

17341737
#[turbo_tasks::function]
17351738
pub fn enable_cache_components(&self) -> Vc<bool> {
1736-
Vc::cell(self.experimental.cache_components.unwrap_or(false))
1739+
Vc::cell(self.cache_components.unwrap_or(false))
17371740
}
17381741

17391742
#[turbo_tasks::function]
@@ -1744,7 +1747,7 @@ impl NextConfig {
17441747
// "use cache" was originally implicitly enabled with the
17451748
// cacheComponents flag, so we transfer the value for cacheComponents to the
17461749
// explicit useCache flag to ensure backwards compatibility.
1747-
.unwrap_or(self.experimental.cache_components.unwrap_or(false)),
1750+
.unwrap_or(self.cache_components.unwrap_or(false)),
17481751
)
17491752
}
17501753

@@ -1754,7 +1757,7 @@ impl NextConfig {
17541757
self.experimental
17551758
.root_params
17561759
// rootParams should be enabled implicitly in cacheComponents.
1757-
.unwrap_or(self.experimental.cache_components.unwrap_or(false)),
1760+
.unwrap_or(self.cache_components.unwrap_or(false)),
17581761
)
17591762
}
17601763

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ enum NextConfigProperty {
101101
impl Display for NextConfigProperty {
102102
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
103103
match self {
104-
NextConfigProperty::CacheComponents => write!(f, "experimental.cacheComponents"),
104+
NextConfigProperty::CacheComponents => write!(f, "cacheComponents"),
105105
NextConfigProperty::UseCache => write!(f, "experimental.useCache"),
106106
}
107107
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ enum ServerActionsErrorKind {
120120
span: Span,
121121
cache_kind: RcStr,
122122
},
123-
UseCacheWithoutExperimentalFlag {
123+
UseCacheWithoutCacheComponents {
124124
span: Span,
125125
directive: String,
126126
},
@@ -2753,7 +2753,7 @@ impl DirectiveVisitor<'_> {
27532753
});
27542754
} else if self.is_allowed_position {
27552755
if !self.config.use_cache_enabled {
2756-
emit_error(ServerActionsErrorKind::UseCacheWithoutExperimentalFlag {
2756+
emit_error(ServerActionsErrorKind::UseCacheWithoutCacheComponents {
27572757
span: *span,
27582758
directive: value.to_string(),
27592759
});
@@ -3195,11 +3195,11 @@ fn emit_error(error_kind: ServerActionsErrorKind) {
31953195
"#
31963196
},
31973197
),
3198-
ServerActionsErrorKind::UseCacheWithoutExperimentalFlag { span, directive } => (
3198+
ServerActionsErrorKind::UseCacheWithoutCacheComponents { span, directive } => (
31993199
span,
32003200
formatdoc! {
32013201
r#"
3202-
To use "{directive}", please enable the feature flag `experimental.cacheComponents` in your Next.js config.
3202+
To use "{directive}", please enable the feature flag `cacheComponents` in your Next.js config.
32033203
32043204
Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
32053205
"#

crates/next-custom-transforms/tests/errors/react-server-components/server-graph/cache-components/output.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
x Route segment config "runtime" is not compatible with `nextConfig.experimental.cacheComponents`. Please remove it.
1+
x Route segment config "runtime" is not compatible with `nextConfig.cacheComponents`. Please remove it.
22
,-[input.js:1:1]
33
1 | export const runtime = 'edge'
44
: ^^^^^^^
55
2 | export const dynamic = 'force-dynamic'
66
`----
7-
x Route segment config "dynamic" is not compatible with `nextConfig.experimental.cacheComponents`. Please remove it.
7+
x Route segment config "dynamic" is not compatible with `nextConfig.cacheComponents`. Please remove it.
88
,-[input.js:2:1]
99
1 | export const runtime = 'edge'
1010
2 | export const dynamic = 'force-dynamic'
1111
: ^^^^^^^
1212
3 | export const dynamicParams = false
1313
`----
14-
x Route segment config "dynamicParams" is not compatible with `nextConfig.experimental.cacheComponents`. Please remove it.
14+
x Route segment config "dynamicParams" is not compatible with `nextConfig.cacheComponents`. Please remove it.
1515
,-[input.js:3:1]
1616
2 | export const dynamic = 'force-dynamic'
1717
3 | export const dynamicParams = false
1818
: ^^^^^^^^^^^^^
1919
4 | export const fetchCache = 'force-no-store'
2020
`----
21-
x Route segment config "fetchCache" is not compatible with `nextConfig.experimental.cacheComponents`. Please remove it.
21+
x Route segment config "fetchCache" is not compatible with `nextConfig.cacheComponents`. Please remove it.
2222
,-[input.js:4:1]
2323
3 | export const dynamicParams = false
2424
4 | export const fetchCache = 'force-no-store'
2525
: ^^^^^^^^^^
2626
5 | export const revalidate = 1
2727
`----
28-
x Route segment config "revalidate" is not compatible with `nextConfig.experimental.cacheComponents`. Please remove it.
28+
x Route segment config "revalidate" is not compatible with `nextConfig.cacheComponents`. Please remove it.
2929
,-[input.js:5:1]
3030
4 | export const fetchCache = 'force-no-store'
3131
5 | export const revalidate = 1

crates/next-custom-transforms/tests/errors/use-cache-not-allowed/1/output.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x To use "use cache", please enable the feature flag `experimental.cacheComponents` in your Next.js config.
1+
x To use "use cache", please enable the feature flag `cacheComponents` in your Next.js config.
22
|
33
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
44
|

crates/next-custom-transforms/tests/errors/use-cache-not-allowed/2/output.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x To use "use cache: x", please enable the feature flag `experimental.cacheComponents` in your Next.js config.
1+
x To use "use cache: x", please enable the feature flag `cacheComponents` in your Next.js config.
22
|
33
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
44
|

docs/01-app/02-guides/memory-usage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Generating source maps consumes extra memory during the build process.
125125

126126
You can disable source map generation by adding `productionBrowserSourceMaps: false` and `experimental.serverSourceMaps: false` to your Next.js configuration.
127127

128-
When using the `experimental.cacheComponents` feature, Next.js will use source maps by default during the prerender phase of `next build`.
128+
When using the `cacheComponents` feature, Next.js will use source maps by default during the prerender phase of `next build`.
129129
If you consistently encounter memory issues during that phase (after "Generating static pages"),
130130
you can try disabling source maps in that phase by adding `enablePrerenderSourceMaps: false` to your Next.js configuration.
131131

docs/01-app/03-api-reference/01-directives/use-cache.mdx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ The `use cache` directive allows you to mark a route, React component, or a func
1717

1818
## Usage
1919

20-
`use cache` is currently an experimental feature. To enable it, add the [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) option to your `next.config.ts` file:
20+
`use cache` is a Cache Components feature. To enable it, add the [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) option to your `next.config.ts` file:
2121

2222
```ts filename="next.config.ts" switcher
2323
import type { NextConfig } from 'next'
2424

2525
const nextConfig: NextConfig = {
26-
experimental: {
27-
cacheComponents: true,
28-
},
26+
cacheComponents: true,
2927
}
3028

3129
export default nextConfig
@@ -34,9 +32,7 @@ export default nextConfig
3432
```js filename="next.config.js" switcher
3533
/** @type {import('next').NextConfig} */
3634
const nextConfig = {
37-
experimental: {
38-
cacheComponents: true,
39-
},
35+
cacheComponents: true,
4036
}
4137

4238
module.exports = nextConfig
@@ -367,6 +363,7 @@ Learn how to [configure caching](/docs/app/guides/self-hosting#caching-and-isr)
367363

368364
## Version History
369365

370-
| Version | Changes |
371-
| --------- | ------------------------------------------------------- |
372-
| `v15.0.0` | `"use cache"` is introduced as an experimental feature. |
366+
| Version | Changes |
367+
| --------- | ----------------------------------------------------------- |
368+
| `v16.0.0` | `"use cache"` is enabled with the Cache Components feature. |
369+
| `v15.0.0` | `"use cache"` is introduced as an experimental feature. |

docs/01-app/03-api-reference/04-functions/cacheLife.mdx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@ To use `cacheLife`, enable the [`cacheComponents` flag](/docs/app/api-reference/
2222
import type { NextConfig } from 'next'
2323

2424
const nextConfig: NextConfig = {
25-
experimental: {
26-
cacheComponents: true,
27-
},
25+
cacheComponents: true,
2826
}
2927

3028
export default nextConfig
3129
```
3230

3331
```js filename="next.config.js" switcher
3432
const nextConfig = {
35-
experimental: {
36-
cacheComponents: true,
37-
},
33+
cacheComponents: true,
3834
}
3935

4036
export default nextConfig
@@ -116,8 +112,8 @@ You can create a reusable cache profile by defining them in your `next.config.ts
116112
import type { NextConfig } from 'next'
117113

118114
const nextConfig: NextConfig = {
115+
cacheComponents: true,
119116
experimental: {
120-
cacheComponents: true,
121117
cacheLife: {
122118
biweekly: {
123119
stale: 60 * 60 * 24 * 14, // 14 days
@@ -133,8 +129,8 @@ module.exports = nextConfig
133129

134130
```js filename="next.config.js" switcher
135131
const nextConfig = {
132+
cacheComponents: true,
136133
experimental: {
137-
cacheComponents: true,
138134
cacheLife: {
139135
biweekly: {
140136
stale: 60 * 60 * 24 * 14, // 14 days
@@ -170,8 +166,8 @@ The example below shows how to override the default “days” cache profile:
170166

171167
```ts filename="next.config.ts"
172168
const nextConfig = {
169+
cacheComponents: true,
173170
experimental: {
174-
cacheComponents: true,
175171
cacheLife: {
176172
days: {
177173
stale: 3600, // 1 hour

0 commit comments

Comments
 (0)