Browse files

Add minify flag to react-native bundle command

We have found that it is useful to work with production rather than dev bundles when working on e.g. performance and animation tuning.

For a larger app, `react-native bundle` with `--dev false` can get very slow due to minification - in our case, this was especially true of library code (e.g. the AWS SDK taking nearly 15 secs to minify on a top-spec MBP 15"). This is fine when just building every now and then, but when making frequent changes and rebuilding, it becomes quite painful.

Currently there is no way to perform a release (non-dev) build, with minification disabled. This PR adds an optional `--minify` flag to enable developers to disable minification, reducing build times significantly for our use case.

Checked output bundle size, to ensure behaviour stays the same as the existing default when `--minify` is not specified, and that the `minify` flag gets passed through to Metro bundler correctly if specified.


[GENERAL] [ENHANCEMENT] [Bundler] - Added optional --minify flag to bundler
Closes #17702

Differential Revision: D6806356

Pulled By: shergin

fbshipit-source-id: c466a2dea692561f8b2002118662c3affc71b991
  • Loading branch information...
tomduncalf authored and facebook-github-bot committed Jan 30, 2018
1 parent 8ffc16c commit 3f969cb1db3a39dd8a4fd622abbb7e4270a84216
Showing with 8 additions and 1 deletion.
  1. +2 −1 local-cli/bundle/buildBundle.js
  2. +6 −0 local-cli/bundle/bundleCommandLineArgs.js
@@ -54,6 +54,7 @@ async function buildBundle(
maxWorkers: number,
resetCache: boolean,
transformer: string,
minify: boolean,
config: ConfigT,
output = outputBundle,
@@ -71,7 +72,7 @@ async function buildBundle(
entryFile: args.entryFile,
minify: !,
minify: args.minify !== undefined ? args.minify : !,
platform: args.platform,
@@ -24,6 +24,12 @@ module.exports = [
description: 'If false, warnings are disabled and the bundle is minified',
parse: (val) => val === 'false' ? false : true,
default: true,
}, {
command: '--minify [boolean]',
description: 'Allows overriding whether bundle is minified. This defaults to ' +
'false if dev is true, and true if dev is false. Disabling minification ' +
'can be useful for speeding up production builds for testing purposes.',
parse: (val) => val === 'false' ? false : true,
}, {
command: '--bundle-output <string>',
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',

0 comments on commit 3f969cb

Please sign in to comment.