Skip to content

Commit a2ee2d5

Browse files
authored
Turbpopack: fix is_persistent_caching_enabled (#89533)
The next config setting was renamed, so this was always false. So far, this was only used for telemetry.
1 parent 6aeef8e commit a2ee2d5

File tree

9 files changed

+33
-20
lines changed

9 files changed

+33
-20
lines changed

crates/next-api/src/project.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ pub struct ProjectOptions {
275275
/// Debug build paths for selective builds.
276276
/// When set, only routes matching these paths will be included in the build.
277277
pub debug_build_paths: Option<DebugBuildPaths>,
278+
279+
/// Whether to enable persistent caching
280+
pub is_persistent_caching_enabled: bool,
278281
}
279282

280283
pub struct PartialProjectOptions {
@@ -677,6 +680,7 @@ impl ProjectContainer {
677680
let write_routes_hashes_manifest;
678681
let current_node_js_version;
679682
let debug_build_paths;
683+
let is_persistent_caching_enabled;
680684
{
681685
let options = self.options_state.get();
682686
let options = options
@@ -702,6 +706,7 @@ impl ProjectContainer {
702706
write_routes_hashes_manifest = options.write_routes_hashes_manifest;
703707
current_node_js_version = options.current_node_js_version.clone();
704708
debug_build_paths = options.debug_build_paths.clone();
709+
is_persistent_caching_enabled = options.is_persistent_caching_enabled;
705710
}
706711

707712
let dist_dir = next_config.dist_dir().owned().await?;
@@ -729,6 +734,7 @@ impl ProjectContainer {
729734
write_routes_hashes_manifest,
730735
current_node_js_version,
731736
debug_build_paths,
737+
is_persistent_caching_enabled,
732738
}
733739
.cell())
734740
}
@@ -823,6 +829,9 @@ pub struct Project {
823829
/// Debug build paths for selective builds.
824830
/// When set, only routes matching these paths will be included in the build.
825831
debug_build_paths: Option<DebugBuildPaths>,
832+
833+
/// Whether to enable persistent caching
834+
is_persistent_caching_enabled: bool,
826835
}
827836

828837
#[turbo_tasks::value]
@@ -1032,6 +1041,11 @@ impl Project {
10321041
*self.next_config
10331042
}
10341043

1044+
#[turbo_tasks::function]
1045+
pub(super) fn is_persistent_caching_enabled(&self) -> Vc<bool> {
1046+
Vc::cell(self.is_persistent_caching_enabled)
1047+
}
1048+
10351049
#[turbo_tasks::function]
10361050
pub(super) fn next_mode(&self) -> Vc<NextMode> {
10371051
*self.mode
@@ -1499,7 +1513,7 @@ impl Project {
14991513
);
15001514
emit_event(
15011515
"persistentCaching",
1502-
*config.persistent_caching_enabled().await?,
1516+
*self.is_persistent_caching_enabled().await?,
15031517
);
15041518

15051519
emit_event(

crates/next-build-test/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ fn main() {
185185
write_routes_hashes_manifest: false,
186186
current_node_js_version: rcstr!("18.0.0"),
187187
debug_build_paths: None,
188+
is_persistent_caching_enabled: false,
188189
};
189190

190191
let json = serde_json::to_string_pretty(&options).unwrap();

crates/next-core/src/next_config.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,6 @@ pub struct ExperimentalConfig {
10721072

10731073
turbopack_minify: Option<bool>,
10741074
turbopack_module_ids: Option<ModuleIds>,
1075-
turbopack_persistent_caching: Option<bool>,
10761075
turbopack_source_maps: Option<bool>,
10771076
turbopack_input_source_maps: Option<bool>,
10781077
turbopack_tree_shaking: Option<bool>,
@@ -1099,6 +1098,9 @@ pub struct ExperimentalConfig {
10991098
devtool_segment_explorer: Option<bool>,
11001099
/// Whether to report inlined system environment variables as warnings or errors.
11011100
report_system_env_inlining: Option<String>,
1101+
// Use project.is_persistent_caching() instead
1102+
// turbopack_file_system_cache_for_dev: Option<bool>,
1103+
// turbopack_file_system_cache_for_build: Option<bool>,
11021104
}
11031105

11041106
#[derive(
@@ -1635,15 +1637,6 @@ impl NextConfig {
16351637
Ok(Vc::cell(rules))
16361638
}
16371639

1638-
#[turbo_tasks::function]
1639-
pub fn persistent_caching_enabled(&self) -> Result<Vc<bool>> {
1640-
Ok(Vc::cell(
1641-
self.experimental
1642-
.turbopack_persistent_caching
1643-
.unwrap_or_default(),
1644-
))
1645-
}
1646-
16471640
#[turbo_tasks::function]
16481641
pub fn resolve_alias_options(&self) -> Result<Vc<ResolveAliasMap>> {
16491642
let Some(resolve_alias) = self

crates/next-napi-bindings/src/next_api/project.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ pub struct NapiProjectOptions {
190190
/// Debug build paths for selective builds.
191191
/// When set, only routes matching these paths will be included in the build.
192192
pub debug_build_paths: Option<NapiDebugBuildPaths>,
193+
194+
// Whether persistent caching is enabled
195+
pub is_persistent_caching_enabled: bool,
193196
}
194197

195198
/// [NapiProjectOptions] with all fields optional.
@@ -252,8 +255,6 @@ pub struct NapiDefineEnv {
252255

253256
#[napi(object)]
254257
pub struct NapiTurboEngineOptions {
255-
/// Use the new backend with filesystem cache enabled.
256-
pub persistent_caching: Option<bool>,
257258
/// An upper bound of memory that turbopack will attempt to stay under.
258259
pub memory_limit: Option<f64>,
259260
/// Track dependencies between tasks. If false, any change during build will error.
@@ -296,6 +297,7 @@ impl From<NapiProjectOptions> for ProjectOptions {
296297
write_routes_hashes_manifest,
297298
current_node_js_version,
298299
debug_build_paths,
300+
is_persistent_caching_enabled,
299301
} = val;
300302
ProjectOptions {
301303
root_path,
@@ -316,6 +318,7 @@ impl From<NapiProjectOptions> for ProjectOptions {
316318
app: p.app,
317319
pages: p.pages,
318320
}),
321+
is_persistent_caching_enabled,
319322
}
320323
}
321324
}
@@ -506,13 +509,12 @@ pub fn project_new(
506509
.memory_limit
507510
.map(|m| m as usize)
508511
.unwrap_or(usize::MAX);
509-
let persistent_caching = turbo_engine_options.persistent_caching.unwrap_or_default();
510512
let dependency_tracking = turbo_engine_options.dependency_tracking.unwrap_or(true);
511513
let is_ci = turbo_engine_options.is_ci.unwrap_or(false);
512514
let is_short_session = turbo_engine_options.is_short_session.unwrap_or(false);
513515
let turbo_tasks = create_turbo_tasks(
514516
PathBuf::from(&options.dist_dir),
515-
persistent_caching,
517+
options.is_persistent_caching_enabled,
516518
memory_limit,
517519
dependency_tracking,
518520
is_ci,

packages/next/src/build/swc/generated-native.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export interface NapiProjectOptions {
166166
* When set, only routes matching these paths will be included in the build.
167167
*/
168168
debugBuildPaths?: NapiDebugBuildPaths
169+
isPersistentCachingEnabled: boolean
169170
}
170171
/** [NapiProjectOptions] with all fields optional. */
171172
export interface NapiPartialProjectOptions {
@@ -217,8 +218,6 @@ export interface NapiDefineEnv {
217218
nodejs: Array<NapiOptionEnvVar>
218219
}
219220
export interface NapiTurboEngineOptions {
220-
/** Use the new backend with filesystem cache enabled. */
221-
persistentCaching?: boolean
222221
/** An upper bound of memory that turbopack will attempt to stay under. */
223222
memoryLimit?: number
224223
/** Track dependencies between tasks. If false, any change during build will error. */

packages/next/src/build/turbopack-analyze/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ export async function turbopackAnalyze(
7979
noMangling,
8080
writeRoutesHashesManifest: false,
8181
currentNodeJsVersion,
82+
isPersistentCachingEnabled: persistentCaching,
8283
},
8384
{
84-
persistentCaching,
8585
memoryLimit: config.experimental?.turbopackMemoryLimit,
8686
dependencyTracking: persistentCaching,
8787
isCi: isCI,

packages/next/src/build/turbopack-build/impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ export async function turbopackBuild(): Promise<{
216216
writeRoutesHashesManifest:
217217
!!process.env.NEXT_TURBOPACK_WRITE_ROUTES_HASHES_MANIFEST,
218218
currentNodeJsVersion,
219+
isPersistentCachingEnabled: persistentCaching,
219220
}
220221

221222
const sharedTurboOptions = {
222-
persistentCaching,
223223
memoryLimit: config.experimental?.turbopackMemoryLimit,
224224
dependencyTracking: persistentCaching,
225225
isCi: isCI,

packages/next/src/server/dev/hot-reloader-turbopack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ export async function createHotReloaderTurbopack(
282282
noMangling: false,
283283
writeRoutesHashesManifest: false,
284284
currentNodeJsVersion,
285+
isPersistentCachingEnabled: isFileSystemCacheEnabledForDev(
286+
opts.nextConfig
287+
),
285288
},
286289
{
287-
persistentCaching: isFileSystemCacheEnabledForDev(opts.nextConfig),
288290
memoryLimit: opts.nextConfig.experimental?.turbopackMemoryLimit,
289291
isShortSession: false,
290292
}

test/development/basic/next-rs-api.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ async function main() {
231231
noMangling: false,
232232
writeRoutesHashesManifest: false,
233233
currentNodeJsVersion: '18.0.0',
234+
isPersistentCachingEnabled: false,
234235
});
235236
236237
const entrypointsSubscription = project.entrypointsSubscribe();
@@ -389,6 +390,7 @@ describe('next.rs api', () => {
389390
noMangling: false,
390391
writeRoutesHashesManifest: false,
391392
currentNodeJsVersion: '18.0.0',
393+
isPersistentCachingEnabled: false,
392394
})
393395
projectUpdateSubscription = filterMapAsyncIterator(
394396
project.updateInfoSubscribe(1000),

0 commit comments

Comments
 (0)