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

Replace featureFlags inline by their values when minifying #41

Merged
merged 1 commit into from
May 29, 2017

Conversation

alexBaizeau
Copy link
Contributor

This is a redundant operation for uglifyJS but it makes this library
compatible with babili's dead code eliminitation logic.

when minification is enabled
MY_FEATURE_FLAG=false

if (MY_FEATURE_FLAG) {
  return x;
} else {
  return y;
}

becomes

if (false) {
  return x;
} else {
  return y;
}

Then babili's/uglifyJS DCE logic turns this code into

  return y;

I add to pin a package to one of my commit while wssgcg1213/babel-plugin-inline-replace-variables#8 merges

This is a redundant operation for uglifyJS but it makes this library
compatible with babili's dead code eliminitation logic.

when minification is enabled
MY_FEATURE_FLAG=false

```
if (MY_FEATURE_FLAG) {
  return x;
} else {
  return y;
}
```
becomes
```
if (false) {
  return x;
} else {
  return y;
}
```
Then babili's/uglifyJS DCE logic turns this code into

```
  return y;
```
@minichate
Copy link
Owner

@alexBaizeau Is this backwards compatible with Uglify users?

@alexBaizeau
Copy link
Contributor Author

@minichate Yes it is, it just make this line useless https://github.com/minichate/ember-cli-conditional-compile/blob/master/index.js#L30

The Global values are inlined and uglifyJS dead code elimination will kick in as well

@minichate
Copy link
Owner

💯

@minichate minichate merged commit a1efea5 into minichate:master May 29, 2017
@minichate
Copy link
Owner

@alexBaizeau Released as ember-cli-conditional-compile@1.0.3

@@ -47,6 +47,8 @@
"loader.js": "4.2.3"
},
"dependencies": {
"babel-plugin-inline-replace-variables": "https://github.com/alexBaizeau/babel-plugin-inline-replace-variables.git#8d55becd00acca84b6f301ad346aeed9507949a3",
Copy link
Owner

Choose a reason for hiding this comment

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

I believe we can use 1.3.1 now :)

@tehmaestro tehmaestro mentioned this pull request Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants