mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 23:28:12 +00:00
Add minify flag to react-native bundle command
Summary: 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. N/A [GENERAL] [ENHANCEMENT] [Bundler] - Added optional --minify flag to bundler Closes https://github.com/facebook/react-native/pull/17702 Differential Revision: D6806356 Pulled By: shergin fbshipit-source-id: c466a2dea692561f8b2002118662c3affc71b991
This commit is contained in:
parent
8ffc16c6e7
commit
3f969cb1db
@ -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,
|
||||
sourceMapUrl,
|
||||
dev: args.dev,
|
||||
minify: !args.dev,
|
||||
minify: args.minify !== undefined ? args.minify : !args.dev,
|
||||
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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user