diff --git a/packages/cli/src/bundle/metro.ts b/packages/cli/src/bundle/metro.ts index 169331433c..c064289860 100644 --- a/packages/cli/src/bundle/metro.ts +++ b/packages/cli/src/bundle/metro.ts @@ -32,11 +32,18 @@ export async function metroBundle( ): Promise { info(`Bundling ${bundleConfig.platform}...`); - customizeMetroConfig(metroConfig, { - ...bundleConfig, - treeShake: !dev && bundleConfig.treeShake, - minify, - }); + if (!dev && bundleConfig.treeShake) { + if (minify !== undefined) { + bundleConfig.treeShake = + typeof bundleConfig.treeShake === "object" + ? { ...bundleConfig.treeShake, minify } + : { minify }; + } + } else { + bundleConfig.treeShake = false; + } + + customizeMetroConfig(metroConfig, bundleConfig); const metroBundleArgs: MetroBundleArgs = { ...bundleConfig, diff --git a/packages/cli/src/metro-config.ts b/packages/cli/src/metro-config.ts index 6c3d484990..eeb79e1f80 100644 --- a/packages/cli/src/metro-config.ts +++ b/packages/cli/src/metro-config.ts @@ -20,7 +20,6 @@ type MetroExtraParams = Pick< | "typescriptValidation" | "plugins" | "treeShake" - | "minify" >; function resolvePlugin(name: string): string { @@ -165,19 +164,12 @@ export function customizeMetroConfig( "`serializer.customSerializer` in `metro.config.js` will be overwritten to enable tree shaking" ); } - let buildOptions = - extraParams.treeShake instanceof Object - ? extraParams.treeShake - : undefined; - - if (extraParams.minify !== undefined) { - buildOptions ||= {}; - buildOptions.minify = extraParams.minify; - } metroConfig.serializer.customSerializer = MetroSerializerEsbuild( metroPlugins, - buildOptions + extraParams.treeShake instanceof Object + ? extraParams.treeShake + : undefined ); Object.assign(metroConfig.transformer, esbuildTransformerConfig); } else if (metroPlugins.length > 0) { diff --git a/packages/config/src/bundleConfig.ts b/packages/config/src/bundleConfig.ts index 0eec387dca..354099882b 100644 --- a/packages/config/src/bundleConfig.ts +++ b/packages/config/src/bundleConfig.ts @@ -119,13 +119,6 @@ export type BundleParameters = BundlerPlugins & { */ treeShake?: boolean | EsbuildOptions; - /** - * Choose whether to enable tree minification. - * - * Only applies to `rnx-bundle` command. - */ - minify?: boolean; - /** * Whether to run the Hermes compiler on the output bundle. *