Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AAHAbbas committed Oct 9, 2023
1 parent 818c824 commit b59d455
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
17 changes: 12 additions & 5 deletions packages/cli/src/bundle/metro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ export async function metroBundle(
): Promise<void> {
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,
Expand Down
14 changes: 3 additions & 11 deletions packages/cli/src/metro-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type MetroExtraParams = Pick<
| "typescriptValidation"
| "plugins"
| "treeShake"
| "minify"
>;

function resolvePlugin(name: string): string {
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions packages/config/src/bundleConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit b59d455

Please sign in to comment.