Unverified Commit a2ee2d58 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

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.
parent 6aeef8eb
...@@ -275,6 +275,9 @@ pub struct ProjectOptions { ...@@ -275,6 +275,9 @@ pub struct ProjectOptions {
/// Debug build paths for selective builds. /// Debug build paths for selective builds.
/// When set, only routes matching these paths will be included in the build. /// When set, only routes matching these paths will be included in the build.
pub debug_build_paths: Option<DebugBuildPaths>, pub debug_build_paths: Option<DebugBuildPaths>,
/// Whether to enable persistent caching
pub is_persistent_caching_enabled: bool,
} }
pub struct PartialProjectOptions { pub struct PartialProjectOptions {
...@@ -677,6 +680,7 @@ impl ProjectContainer { ...@@ -677,6 +680,7 @@ impl ProjectContainer {
let write_routes_hashes_manifest; let write_routes_hashes_manifest;
let current_node_js_version; let current_node_js_version;
let debug_build_paths; let debug_build_paths;
let is_persistent_caching_enabled;
{ {
let options = self.options_state.get(); let options = self.options_state.get();
let options = options let options = options
...@@ -702,6 +706,7 @@ impl ProjectContainer { ...@@ -702,6 +706,7 @@ impl ProjectContainer {
write_routes_hashes_manifest = options.write_routes_hashes_manifest; write_routes_hashes_manifest = options.write_routes_hashes_manifest;
current_node_js_version = options.current_node_js_version.clone(); current_node_js_version = options.current_node_js_version.clone();
debug_build_paths = options.debug_build_paths.clone(); debug_build_paths = options.debug_build_paths.clone();
is_persistent_caching_enabled = options.is_persistent_caching_enabled;
} }
let dist_dir = next_config.dist_dir().owned().await?; let dist_dir = next_config.dist_dir().owned().await?;
...@@ -729,6 +734,7 @@ impl ProjectContainer { ...@@ -729,6 +734,7 @@ impl ProjectContainer {
write_routes_hashes_manifest, write_routes_hashes_manifest,
current_node_js_version, current_node_js_version,
debug_build_paths, debug_build_paths,
is_persistent_caching_enabled,
} }
.cell()) .cell())
} }
...@@ -823,6 +829,9 @@ pub struct Project { ...@@ -823,6 +829,9 @@ pub struct Project {
/// Debug build paths for selective builds. /// Debug build paths for selective builds.
/// When set, only routes matching these paths will be included in the build. /// When set, only routes matching these paths will be included in the build.
debug_build_paths: Option<DebugBuildPaths>, debug_build_paths: Option<DebugBuildPaths>,
/// Whether to enable persistent caching
is_persistent_caching_enabled: bool,
} }
#[turbo_tasks::value] #[turbo_tasks::value]
...@@ -1032,6 +1041,11 @@ impl Project { ...@@ -1032,6 +1041,11 @@ impl Project {
*self.next_config *self.next_config
} }
#[turbo_tasks::function]
pub(super) fn is_persistent_caching_enabled(&self) -> Vc<bool> {
Vc::cell(self.is_persistent_caching_enabled)
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn next_mode(&self) -> Vc<NextMode> { pub(super) fn next_mode(&self) -> Vc<NextMode> {
*self.mode *self.mode
...@@ -1499,7 +1513,7 @@ impl Project { ...@@ -1499,7 +1513,7 @@ impl Project {
); );
emit_event( emit_event(
"persistentCaching", "persistentCaching",
*config.persistent_caching_enabled().await?, *self.is_persistent_caching_enabled().await?,
); );
emit_event( emit_event(
......
...@@ -185,6 +185,7 @@ fn main() { ...@@ -185,6 +185,7 @@ fn main() {
write_routes_hashes_manifest: false, write_routes_hashes_manifest: false,
current_node_js_version: rcstr!("18.0.0"), current_node_js_version: rcstr!("18.0.0"),
debug_build_paths: None, debug_build_paths: None,
is_persistent_caching_enabled: false,
}; };
let json = serde_json::to_string_pretty(&options).unwrap(); let json = serde_json::to_string_pretty(&options).unwrap();
......
...@@ -1072,7 +1072,6 @@ pub struct ExperimentalConfig { ...@@ -1072,7 +1072,6 @@ pub struct ExperimentalConfig {
turbopack_minify: Option<bool>, turbopack_minify: Option<bool>,
turbopack_module_ids: Option<ModuleIds>, turbopack_module_ids: Option<ModuleIds>,
turbopack_persistent_caching: Option<bool>,
turbopack_source_maps: Option<bool>, turbopack_source_maps: Option<bool>,
turbopack_input_source_maps: Option<bool>, turbopack_input_source_maps: Option<bool>,
turbopack_tree_shaking: Option<bool>, turbopack_tree_shaking: Option<bool>,
...@@ -1099,6 +1098,9 @@ pub struct ExperimentalConfig { ...@@ -1099,6 +1098,9 @@ pub struct ExperimentalConfig {
devtool_segment_explorer: Option<bool>, devtool_segment_explorer: Option<bool>,
/// Whether to report inlined system environment variables as warnings or errors. /// Whether to report inlined system environment variables as warnings or errors.
report_system_env_inlining: Option<String>, report_system_env_inlining: Option<String>,
// Use project.is_persistent_caching() instead
// turbopack_file_system_cache_for_dev: Option<bool>,
// turbopack_file_system_cache_for_build: Option<bool>,
} }
#[derive( #[derive(
...@@ -1635,15 +1637,6 @@ impl NextConfig { ...@@ -1635,15 +1637,6 @@ impl NextConfig {
Ok(Vc::cell(rules)) Ok(Vc::cell(rules))
} }
#[turbo_tasks::function]
pub fn persistent_caching_enabled(&self) -> Result<Vc<bool>> {
Ok(Vc::cell(
self.experimental
.turbopack_persistent_caching
.unwrap_or_default(),
))
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn resolve_alias_options(&self) -> Result<Vc<ResolveAliasMap>> { pub fn resolve_alias_options(&self) -> Result<Vc<ResolveAliasMap>> {
let Some(resolve_alias) = self let Some(resolve_alias) = self
......
...@@ -190,6 +190,9 @@ pub struct NapiProjectOptions { ...@@ -190,6 +190,9 @@ pub struct NapiProjectOptions {
/// Debug build paths for selective builds. /// Debug build paths for selective builds.
/// When set, only routes matching these paths will be included in the build. /// When set, only routes matching these paths will be included in the build.
pub debug_build_paths: Option<NapiDebugBuildPaths>, pub debug_build_paths: Option<NapiDebugBuildPaths>,
// Whether persistent caching is enabled
pub is_persistent_caching_enabled: bool,
} }
/// [NapiProjectOptions] with all fields optional. /// [NapiProjectOptions] with all fields optional.
...@@ -252,8 +255,6 @@ pub struct NapiDefineEnv { ...@@ -252,8 +255,6 @@ pub struct NapiDefineEnv {
#[napi(object)] #[napi(object)]
pub struct NapiTurboEngineOptions { pub struct NapiTurboEngineOptions {
/// Use the new backend with filesystem cache enabled.
pub persistent_caching: Option<bool>,
/// An upper bound of memory that turbopack will attempt to stay under. /// An upper bound of memory that turbopack will attempt to stay under.
pub memory_limit: Option<f64>, pub memory_limit: Option<f64>,
/// Track dependencies between tasks. If false, any change during build will error. /// Track dependencies between tasks. If false, any change during build will error.
...@@ -296,6 +297,7 @@ impl From<NapiProjectOptions> for ProjectOptions { ...@@ -296,6 +297,7 @@ impl From<NapiProjectOptions> for ProjectOptions {
write_routes_hashes_manifest, write_routes_hashes_manifest,
current_node_js_version, current_node_js_version,
debug_build_paths, debug_build_paths,
is_persistent_caching_enabled,
} = val; } = val;
ProjectOptions { ProjectOptions {
root_path, root_path,
...@@ -316,6 +318,7 @@ impl From<NapiProjectOptions> for ProjectOptions { ...@@ -316,6 +318,7 @@ impl From<NapiProjectOptions> for ProjectOptions {
app: p.app, app: p.app,
pages: p.pages, pages: p.pages,
}), }),
is_persistent_caching_enabled,
} }
} }
} }
...@@ -506,13 +509,12 @@ pub fn project_new( ...@@ -506,13 +509,12 @@ pub fn project_new(
.memory_limit .memory_limit
.map(|m| m as usize) .map(|m| m as usize)
.unwrap_or(usize::MAX); .unwrap_or(usize::MAX);
let persistent_caching = turbo_engine_options.persistent_caching.unwrap_or_default();
let dependency_tracking = turbo_engine_options.dependency_tracking.unwrap_or(true); let dependency_tracking = turbo_engine_options.dependency_tracking.unwrap_or(true);
let is_ci = turbo_engine_options.is_ci.unwrap_or(false); let is_ci = turbo_engine_options.is_ci.unwrap_or(false);
let is_short_session = turbo_engine_options.is_short_session.unwrap_or(false); let is_short_session = turbo_engine_options.is_short_session.unwrap_or(false);
let turbo_tasks = create_turbo_tasks( let turbo_tasks = create_turbo_tasks(
PathBuf::from(&options.dist_dir), PathBuf::from(&options.dist_dir),
persistent_caching, options.is_persistent_caching_enabled,
memory_limit, memory_limit,
dependency_tracking, dependency_tracking,
is_ci, is_ci,
......
...@@ -166,6 +166,7 @@ export interface NapiProjectOptions { ...@@ -166,6 +166,7 @@ export interface NapiProjectOptions {
* When set, only routes matching these paths will be included in the build. * When set, only routes matching these paths will be included in the build.
*/ */
debugBuildPaths?: NapiDebugBuildPaths debugBuildPaths?: NapiDebugBuildPaths
isPersistentCachingEnabled: boolean
} }
/** [NapiProjectOptions] with all fields optional. */ /** [NapiProjectOptions] with all fields optional. */
export interface NapiPartialProjectOptions { export interface NapiPartialProjectOptions {
...@@ -217,8 +218,6 @@ export interface NapiDefineEnv { ...@@ -217,8 +218,6 @@ export interface NapiDefineEnv {
nodejs: Array<NapiOptionEnvVar> nodejs: Array<NapiOptionEnvVar>
} }
export interface NapiTurboEngineOptions { export interface NapiTurboEngineOptions {
/** Use the new backend with filesystem cache enabled. */
persistentCaching?: boolean
/** An upper bound of memory that turbopack will attempt to stay under. */ /** An upper bound of memory that turbopack will attempt to stay under. */
memoryLimit?: number memoryLimit?: number
/** Track dependencies between tasks. If false, any change during build will error. */ /** Track dependencies between tasks. If false, any change during build will error. */
......
...@@ -79,9 +79,9 @@ export async function turbopackAnalyze( ...@@ -79,9 +79,9 @@ export async function turbopackAnalyze(
noMangling, noMangling,
writeRoutesHashesManifest: false, writeRoutesHashesManifest: false,
currentNodeJsVersion, currentNodeJsVersion,
isPersistentCachingEnabled: persistentCaching,
}, },
{ {
persistentCaching,
memoryLimit: config.experimental?.turbopackMemoryLimit, memoryLimit: config.experimental?.turbopackMemoryLimit,
dependencyTracking: persistentCaching, dependencyTracking: persistentCaching,
isCi: isCI, isCi: isCI,
......
...@@ -216,10 +216,10 @@ export async function turbopackBuild(): Promise<{ ...@@ -216,10 +216,10 @@ export async function turbopackBuild(): Promise<{
writeRoutesHashesManifest: writeRoutesHashesManifest:
!!process.env.NEXT_TURBOPACK_WRITE_ROUTES_HASHES_MANIFEST, !!process.env.NEXT_TURBOPACK_WRITE_ROUTES_HASHES_MANIFEST,
currentNodeJsVersion, currentNodeJsVersion,
isPersistentCachingEnabled: persistentCaching,
} }
const sharedTurboOptions = { const sharedTurboOptions = {
persistentCaching,
memoryLimit: config.experimental?.turbopackMemoryLimit, memoryLimit: config.experimental?.turbopackMemoryLimit,
dependencyTracking: persistentCaching, dependencyTracking: persistentCaching,
isCi: isCI, isCi: isCI,
......
...@@ -282,9 +282,11 @@ export async function createHotReloaderTurbopack( ...@@ -282,9 +282,11 @@ export async function createHotReloaderTurbopack(
noMangling: false, noMangling: false,
writeRoutesHashesManifest: false, writeRoutesHashesManifest: false,
currentNodeJsVersion, currentNodeJsVersion,
isPersistentCachingEnabled: isFileSystemCacheEnabledForDev(
opts.nextConfig
),
}, },
{ {
persistentCaching: isFileSystemCacheEnabledForDev(opts.nextConfig),
memoryLimit: opts.nextConfig.experimental?.turbopackMemoryLimit, memoryLimit: opts.nextConfig.experimental?.turbopackMemoryLimit,
isShortSession: false, isShortSession: false,
} }
......
...@@ -231,6 +231,7 @@ async function main() { ...@@ -231,6 +231,7 @@ async function main() {
noMangling: false, noMangling: false,
writeRoutesHashesManifest: false, writeRoutesHashesManifest: false,
currentNodeJsVersion: '18.0.0', currentNodeJsVersion: '18.0.0',
isPersistentCachingEnabled: false,
}); });
const entrypointsSubscription = project.entrypointsSubscribe(); const entrypointsSubscription = project.entrypointsSubscribe();
...@@ -389,6 +390,7 @@ describe('next.rs api', () => { ...@@ -389,6 +390,7 @@ describe('next.rs api', () => {
noMangling: false, noMangling: false,
writeRoutesHashesManifest: false, writeRoutesHashesManifest: false,
currentNodeJsVersion: '18.0.0', currentNodeJsVersion: '18.0.0',
isPersistentCachingEnabled: false,
}) })
projectUpdateSubscription = filterMapAsyncIterator( projectUpdateSubscription = filterMapAsyncIterator(
project.updateInfoSubscribe(1000), project.updateInfoSubscribe(1000),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment