Unverified Commit a51f3556 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

Remove turbopackMemoryLimit it is dead (#94483)

This feature has never worked, and we should just drop it
parent 0d0dbb6c
...@@ -272,8 +272,6 @@ pub struct NapiDefineEnv { ...@@ -272,8 +272,6 @@ pub struct NapiDefineEnv {
#[napi(object)] #[napi(object)]
pub struct NapiTurboEngineOptions { pub struct NapiTurboEngineOptions {
/// 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. /// Track dependencies between tasks. If false, any change during build will error.
pub dependency_tracking: Option<bool>, pub dependency_tracking: Option<bool>,
/// Whether the project is running in a CI environment. /// Whether the project is running in a CI environment.
...@@ -555,10 +553,6 @@ pub fn project_new( ...@@ -555,10 +553,6 @@ pub fn project_new(
env.spawn_future( env.spawn_future(
async move { async move {
let memory_limit = turbo_engine_options
.memory_limit
.map(|m| m as usize)
.unwrap_or(usize::MAX);
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);
...@@ -568,7 +562,6 @@ pub fn project_new( ...@@ -568,7 +562,6 @@ pub fn project_new(
PathBuf::from(&options.dist_dir), PathBuf::from(&options.dist_dir),
&options.next_version, &options.next_version,
options.is_persistent_caching_enabled, options.is_persistent_caching_enabled,
memory_limit,
dependency_tracking, dependency_tracking,
is_ci, is_ci,
is_short_session, is_short_session,
......
...@@ -248,7 +248,6 @@ pub fn create_turbo_tasks( ...@@ -248,7 +248,6 @@ pub fn create_turbo_tasks(
output_path: PathBuf, output_path: PathBuf,
next_version: &str, next_version: &str,
persistent_caching: bool, persistent_caching: bool,
_memory_limit: usize,
dependency_tracking: bool, dependency_tracking: bool,
is_ci: bool, is_ci: bool,
is_short_session: bool, is_short_session: bool,
......
...@@ -3,7 +3,6 @@ const config = { ...@@ -3,7 +3,6 @@ const config = {
experimental: { experimental: {
serverActions: true, serverActions: true,
typedRoutes: false, typedRoutes: false,
turbopackMemoryLimit: 4096,
turbopackMinify: true, turbopackMinify: true,
turbopackTreeShaking: false, turbopackTreeShaking: false,
turbopackSourceMaps: true turbopackSourceMaps: true
......
...@@ -2,7 +2,6 @@ export default { ...@@ -2,7 +2,6 @@ export default {
experimental: { experimental: {
serverActions: true, serverActions: true,
typedRoutes: false, typedRoutes: false,
turbopackMemoryLimit: 4096,
turbopackMinify: true, turbopackMinify: true,
turbopackTreeShaking: false, turbopackTreeShaking: false,
turbopackSourceMaps: true turbopackSourceMaps: true
......
...@@ -2,7 +2,6 @@ module.exports = { ...@@ -2,7 +2,6 @@ module.exports = {
experimental: { experimental: {
serverActions: true, serverActions: true,
typedRoutes: false, typedRoutes: false,
turbopackMemoryLimit: 4096,
turbopackMinify: true, turbopackMinify: true,
turbopackTreeShaking: false, turbopackTreeShaking: false,
turbopackSourceMaps: true turbopackSourceMaps: true
......
...@@ -5,8 +5,8 @@ const config = { ...@@ -5,8 +5,8 @@ const config = {
resolveAlias: { resolveAlias: {
underscore: 'lodash', underscore: 'lodash',
}, },
memoryLimit: 4096,
}, },
turbopackMemoryLimit: 4096,
typedRoutes: true, typedRoutes: true,
}, },
}; };
......
// CommonJS configuration with variable declaration and modification // CommonJS configuration with variable declaration and modification
const config = { const config = {
experimental: { experimental: {
typedRoutes: true, typedRoutes: true
turbopackMemoryLimit: 4096,
}, },
turbopack: { turbopack: {
......
...@@ -14,6 +14,7 @@ const config = { ...@@ -14,6 +14,7 @@ const config = {
config.experimental.turbo.resolveAlias.foo = 'bar'; config.experimental.turbo.resolveAlias.foo = 'bar';
config.experimental.turbo.minify = true; config.experimental.turbo.minify = true;
config.experimental.turbo.memoryLimit = 4096; config.experimental.turbo.memoryLimit = 4096;
config.experimental.turbopackMemoryLimit = 4096;
// Add regular property // Add regular property
config.images = { config.images = {
......
...@@ -14,7 +14,6 @@ const config = { ...@@ -14,7 +14,6 @@ const config = {
// Add properties to the turbo object // Add properties to the turbo object
config.turbopack.resolveAlias.foo = 'bar'; config.turbopack.resolveAlias.foo = 'bar';
config.experimental.turbopackMinify = true; config.experimental.turbopackMinify = true;
config.experimental.turbopackMemoryLimit = 4096;
// Add regular property // Add regular property
config.images = { config.images = {
......
...@@ -3,7 +3,6 @@ import type { NextConfig } from 'next'; ...@@ -3,7 +3,6 @@ import type { NextConfig } from 'next';
const config = { const config = {
experimental: { experimental: {
typedRoutes: true, typedRoutes: true,
turbopackMemoryLimit: 4096,
turbopackMinify: true, turbopackMinify: true,
turbopackTreeShaking: false, turbopackTreeShaking: false,
turbopackSourceMaps: true turbopackSourceMaps: true
......
...@@ -5,7 +5,6 @@ const config: NextConfig = { ...@@ -5,7 +5,6 @@ const config: NextConfig = {
// Removed serverActions due to TypeScript compatibility // Removed serverActions due to TypeScript compatibility
typedRoutes: true, typedRoutes: true,
turbopackMemoryLimit: 4096,
turbopackMinify: true, turbopackMinify: true,
turbopackTreeShaking: false, turbopackTreeShaking: false,
turbopackSourceMaps: true turbopackSourceMaps: true
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
const nextConfig = { const nextConfig = {
experimental: { experimental: {
typedRoutes: true, typedRoutes: true,
turbopackMemoryLimit: 4096,
turbopackMinify: true, turbopackMinify: true,
turbopackTreeShaking: false, turbopackTreeShaking: false,
turbopackSourceMaps: true turbopackSourceMaps: true
......
...@@ -3,8 +3,12 @@ ...@@ -3,8 +3,12 @@
* the new top-level `turbopack` configuration. * the new top-level `turbopack` configuration.
* *
* It moves most properties from experimental.turbo to the top-level turbopack * It moves most properties from experimental.turbo to the top-level turbopack
* property, with special handling for certain properties like memoryLimit, minify, * property, with special handling for certain properties like minify,
* treeShaking, and sourceMaps which become experimental.turbopack* properties instead. * treeShaking, and sourceMaps which become experimental.turbopack* properties instead.
*
* The `memoryLimit` option is no longer supported, so it is removed entirely in
* both its old location (`experimental.turbo.memoryLimit`) and the location the
* previous version of this codemod produced (`experimental.turbopackMemoryLimit`).
*/ */
import type { import type {
...@@ -23,12 +27,17 @@ import { isNextConfigFile } from './lib/utils' ...@@ -23,12 +27,17 @@ import { isNextConfigFile } from './lib/utils'
// Properties that need to be moved to experimental.turbopack* // Properties that need to be moved to experimental.turbopack*
const RENAMED_EXPERIMENTAL_PROPERTIES = { const RENAMED_EXPERIMENTAL_PROPERTIES = {
memoryLimit: 'turbopackMemoryLimit',
minify: 'turbopackMinify', minify: 'turbopackMinify',
treeShaking: 'turbopackTreeShaking', treeShaking: 'turbopackTreeShaking',
sourceMaps: 'turbopackSourceMaps', sourceMaps: 'turbopackSourceMaps',
} }
// `memoryLimit` is no longer supported and is removed entirely. We drop it under
// both its old `experimental.turbo.*` name and the `experimental.*` name produced
// by the previous version of this codemod.
const REMOVED_TURBO_PROPERTY = 'memoryLimit'
const REMOVED_EXPERIMENTAL_PROPERTY = 'turbopackMemoryLimit'
export default function transformer( export default function transformer(
file: FileInfo, file: FileInfo,
_api: JSCodeShiftAPI, _api: JSCodeShiftAPI,
...@@ -87,6 +96,16 @@ export default function transformer( ...@@ -87,6 +96,16 @@ export default function transformer(
const specialProps = [] const specialProps = []
turboObj.properties.forEach((prop) => { turboObj.properties.forEach((prop) => {
if (
isStaticProperty(prop) &&
prop.key &&
prop.key.type === 'Identifier' &&
prop.key.name === REMOVED_TURBO_PROPERTY
) {
// Drop: `memoryLimit` is no longer supported.
return
}
if ( if (
isStaticProperty(prop) && isStaticProperty(prop) &&
prop.key && prop.key &&
...@@ -112,7 +131,10 @@ export default function transformer( ...@@ -112,7 +131,10 @@ export default function transformer(
isStaticProperty(prop) && isStaticProperty(prop) &&
prop.key && prop.key &&
prop.key.type === 'Identifier' && prop.key.type === 'Identifier' &&
prop.key.name === 'turbo' // Drop the `turbo` object (moved above) and a pre-existing
// `turbopackMemoryLimit` (no longer supported).
(prop.key.name === 'turbo' ||
prop.key.name === REMOVED_EXPERIMENTAL_PROPERTY)
) )
) )
...@@ -193,7 +215,14 @@ export default function transformer( ...@@ -193,7 +215,14 @@ export default function transformer(
return return
} }
// For special properties like memoryLimit, minify, etc. // `memoryLimit` is no longer supported: remove the assignment entirely.
if (propName === REMOVED_TURBO_PROPERTY) {
j(path).remove()
hasChanges = true
return
}
// For special properties like minify, treeShaking, etc.
if (propName && RENAMED_EXPERIMENTAL_PROPERTIES[propName]) { if (propName && RENAMED_EXPERIMENTAL_PROPERTIES[propName]) {
const newAssignment = j.assignmentExpression( const newAssignment = j.assignmentExpression(
'=', '=',
...@@ -298,6 +327,27 @@ export default function transformer( ...@@ -298,6 +327,27 @@ export default function transformer(
} }
}) })
// Remove `config.experimental.turbopackMemoryLimit = value` assignments left
// behind by the previous version of this codemod (no longer supported).
root
.find(j.AssignmentExpression, {
left: {
type: 'MemberExpression',
object: {
type: 'MemberExpression',
property: { type: 'Identifier', name: 'experimental' },
},
property: {
type: 'Identifier',
name: REMOVED_EXPERIMENTAL_PROPERTY,
},
},
})
.forEach((path) => {
j(path).remove()
hasChanges = true
})
// Only return a string if we changed the AST, otherwise return the original source // Only return a string if we changed the AST, otherwise return the original source
return hasChanges ? root.toSource(options) : file.source return hasChanges ? root.toSource(options) : file.source
} }
......
...@@ -309,8 +309,6 @@ export interface NapiDefineEnv { ...@@ -309,8 +309,6 @@ export interface NapiDefineEnv {
nodejs: Array<NapiOptionEnvVar> nodejs: Array<NapiOptionEnvVar>
} }
export interface NapiTurboEngineOptions { export interface NapiTurboEngineOptions {
/** 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. */ /** Track dependencies between tasks. If false, any change during build will error. */
dependencyTracking?: boolean dependencyTracking?: boolean
/** Whether the project is running in a CI environment. */ /** Whether the project is running in a CI environment. */
......
...@@ -364,7 +364,6 @@ export const experimentalSchema = { ...@@ -364,7 +364,6 @@ export const experimentalSchema = {
typedRoutes: z.boolean().optional(), typedRoutes: z.boolean().optional(),
webpackBuildWorker: z.boolean().optional(), webpackBuildWorker: z.boolean().optional(),
webpackMemoryOptimizations: z.boolean().optional(), webpackMemoryOptimizations: z.boolean().optional(),
turbopackMemoryLimit: z.number().optional(),
turbopackMemoryEviction: z turbopackMemoryEviction: z
.union([z.literal(false), z.literal('full')]) .union([z.literal(false), z.literal('full')])
.optional(), .optional(),
......
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