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