Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --minify option to the bundle CLI command #16456

Closed
wants to merge 2 commits into from

Conversation

swansontec
Copy link

@swansontec swansontec commented Oct 18, 2017

If specified, this flag will override the --dev flag. Otherwise, the existing behavior remains the same.

Motivation

Some of our upstream dependencies break under minification. Therefore, we need to produce release builds with minification turned off. Adding this flag allows us to manually create builds with the configuration --dev false --minify false, which was previously impossible from the CLI.

Test Plan

In a fresh react-native project, just run these commands:

# existing behavior remains:
react-native bundle --entry-file index.ios.js --bundle-output dev.js --dev
react-native bundle --entry-file index.ios.js --bundle-output prod.js --dev false

# new combinations are possible:
react-native bundle --entry-file index.ios.js --bundle-output dev-min.js --dev --minify
react-native bundle --entry-file index.ios.js --bundle-output prod-non-min.js --dev false --minify false

If you check the output, you will see:

  • dev.js - non-minified (current behavior)
  • prod.js - minified (current behavior)
  • dev-min.js - minified (new feature)
  • prod-non-min.js - non-minified (new feature)

Release Notes

[CLI] [FEATURE] [local-cli/bundle] - Added a --minify option to the bundle command

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 18, 2017
@@ -85,7 +85,7 @@ function buildBundle(
entryFile: args.entryFile,
sourceMapUrl,
dev: args.dev,
minify: !args.dev,
minify: args.minify != null ? args.minify : !args.dev,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property minify Property cannot be accessed on any member of intersection type intersection

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Just pushed a fixed version.

If specified, this flag will override the `--dev` flag. Otherwise, the existing behavior remains the default.
@swansontec
Copy link
Author

I'm not sure why the CircileCI tests are failing - it doesn't appear to be related to anything in this change. Somehow, one of the tests can't create an Android VM, so it fails to even get off the ground.

@@ -25,6 +25,10 @@ module.exports = [
parse: (val) => val === 'false' ? false : true,
default: true,
}, {
command: '--minify [boolean]',
description: 'Enables or disables minification, overriding "--dev"',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'overriding "--dev"'? May be better something like '(default: false for development build, otherwise true)'
Also "--dev" option description needs to be clarified...

@facebook-github-bot
Copy link
Contributor

@swansontec I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@stale
Copy link

stale bot commented Jan 28, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 28, 2018
@stale stale bot closed this Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants