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

fix(@angular/cli): Disable comparisons feature in uglify compression in prod #7931

Merged
merged 1 commit into from
Nov 29, 2017

Conversation

Wykks
Copy link
Contributor

@Wykks Wykks commented Oct 4, 2017

See #5804

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@Wykks
Copy link
Contributor Author

Wykks commented Oct 5, 2017

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@Wykks
Copy link
Contributor Author

Wykks commented Oct 5, 2017

Some size tests :
A small app (which use mapbox-gl) with comparisons: false

chunk {0} polyfills.d8d3d78a4deb2ab66856.bundle.js (polyfills) 66.2 kB {4} [initial] [rendered]
chunk {1} main.e0d1f68923b143f095a6.bundle.js (main) 40.9 kB {3} [initial] [rendered]
chunk {2} styles.cbb57e89e9ac6ad6f3fb.bundle.css (styles) 78.1 kB {4} [initial] [rendered]
chunk {3} vendor.4ad7ad49f3f7f165fff5.bundle.js (vendor) 1.08 MB [initial] [rendered]
chunk {4} inline.94dcaa1fbb222b2f330f.bundle.js (inline) 1.45 kB [entry] [rendered]

Without comparisons: false

chunk {0} polyfills.d8d3d78a4deb2ab66856.bundle.js (polyfills) 66.1 kB {4} [initial] [rendered]
chunk {1} main.e0d1f68923b143f095a6.bundle.js (main) 40.9 kB {3} [initial] [rendered]
chunk {2} styles.cbb57e89e9ac6ad6f3fb.bundle.css (styles) 78.1 kB {4} [initial] [rendered]
chunk {3} vendor.4ad7ad49f3f7f165fff5.bundle.js (vendor) 1.08 MB [initial] [rendered]
chunk {4} inline.94dcaa1fbb222b2f330f.bundle.js (inline) 1.45 kB [entry] [rendered]

(Using @angular/cli v1.4.4)

@filipesilva
Copy link
Contributor

@Wykks can you check out my alternative solution in #5804 (comment) please? I prefer that one if it also works.

filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 20, 2017
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix angular#5804
Supersedes angular#7931
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 20, 2017
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix angular#5804
Supersedes angular#7931
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 20, 2017
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix angular#5804
Supersedes angular#7931
filipesilva added a commit to filipesilva/angular-cli that referenced this pull request Oct 22, 2017
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix angular#5804
Supersedes angular#7931
hansl pushed a commit that referenced this pull request Oct 23, 2017
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix #5804
Supersedes #7931
hansl pushed a commit that referenced this pull request Oct 24, 2017
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix #5804
Supersedes #7931
@khanhvu161188
Copy link

the PR worked well. Hope it will be merged soon

@Wykks
Copy link
Contributor Author

Wykks commented Nov 13, 2017

Tests with a slightly bigger project (angular/cli 1.5 & angular 5):
Without comparisons: false, prod buid (mapbox-gl doesn't works):

chunk {0} 0.7120f44b0b35c3f30ca3.chunk.js (common) 87.6 kB  [rendered]
chunk {1} 1.806b6d85871e191d087d.chunk.js () 334 kB  [rendered]
chunk {2} 2.84d2c2f503211e36c6b2.chunk.js () 633 kB  [rendered]
chunk {3} 3.8f203f13ef09c83a1cb4.chunk.js () 16.9 kB  [rendered]
chunk {4} 4.ee3dc3a237fdadde98e5.chunk.js () 38.2 kB  [rendered]
chunk {5} 5.c209b3bdcd81230bfdb7.chunk.js () 6.28 kB  [rendered]
chunk {6} 6.dd49bbc2f4e2cf3d3930.chunk.js () 72.1 kB  [rendered]
chunk {7} main.93622f1b31e94850762f.bundle.js (main) 2.69 MB [initial] [rendered]
chunk {8} polyfills.8f464027c5f775c4b960.bundle.js (polyfills) 66.5 kB [initial] [rendered]
chunk {9} styles.9487a01f65ac7a4f3242.bundle.css (styles) 179 kB [initial] [rendered]
chunk {10} inline.3d54bd4262d98168f168.bundle.js (inline) 1.63 kB [entry] [rendered]

With comparisons: false, prod build (mapbox-gl works):

chunk {0} 0.7120f44b0b35c3f30ca3.chunk.js (common) 87.6 kB  [rendered]
chunk {1} 1.806b6d85871e191d087d.chunk.js () 334 kB  [rendered]
chunk {2} 2.84d2c2f503211e36c6b2.chunk.js () 633 kB  [rendered]
chunk {3} 3.8f203f13ef09c83a1cb4.chunk.js () 16.9 kB  [rendered]
chunk {4} 4.ee3dc3a237fdadde98e5.chunk.js () 38.2 kB  [rendered]
chunk {5} 5.c209b3bdcd81230bfdb7.chunk.js () 6.28 kB  [rendered]
chunk {6} 6.dd49bbc2f4e2cf3d3930.chunk.js () 72.1 kB  [rendered]
chunk {7} main.93622f1b31e94850762f.bundle.js (main) 2.69 MB [initial] [rendered]
chunk {8} polyfills.8f464027c5f775c4b960.bundle.js (polyfills) 66.5 kB [initial] [rendered]
chunk {9} styles.9487a01f65ac7a4f3242.bundle.css (styles) 179 kB [initial] [rendered]
chunk {10} inline.3d54bd4262d98168f168.bundle.js (inline) 1.63 kB [entry] [rendered]

Yup, same size. I don't think there's any good reason to not disable comparisons at this point.

@SublimeProphets
Copy link

The PR works perfect for me.
I'm running angular 5.0.1 and angular-cli 1.5.0

@khanhvuNOIS
Copy link

The PR worked well

@filipesilva filipesilva merged commit 8821520 into angular:master Nov 29, 2017
@filipesilva
Copy link
Contributor

Heya, will be merging this into the next 1.6 release.

@kzc
Copy link

kzc commented Nov 29, 2017

@filipesilva While I disagree with the root cause of this issue, if mapbox-gl will not address it then it would be better to disable the more specific uglify compress option typeofs rather than disabling comparisons.

There's a few optimizations unrelated to mapbox-gl that would be negatively affected with comparisons disabled.

Example code with default compress options:

$ echo 'function f(global){ var o = {}; console.log(o == o, typeof global === "undefined"); }' | bin/uglifyjs -c
function f(global){console.log(true,void 0===global)}

Same code with comparisons disabled:

$ echo 'function f(global){ var o = {}; console.log(o == o, typeof global === "undefined"); }' | bin/uglifyjs -c comparisons=false
function f(global){var o={};console.log(o==o,"undefined"===typeof global)}

And again the same code with typeofs disabled:

$ echo 'function f(global){ var o = {}; console.log(o == o, typeof global === "undefined"); }' | bin/uglifyjs -c typeofs=false
function f(global){console.log(true,"undefined"==typeof global)}

You'll notice that the contentious webpacked mapbox-gl "undefined"==typeof global is undisturbed while the other comparisons optimization is still performed.

Not a big deal in the grand scheme of things, but sometimes the comparisons transform can be used to eliminate unnecessary code.

@@ -103,7 +103,13 @@ export function getProdConfig(wco: WebpackConfigOptions) {
}));
}

const uglifyCompressOptions: any = {};
const uglifyCompressOptions: any = {
// Disabled because of an issue with Uglify breaking seemingly valid code:
Copy link

Choose a reason for hiding this comment

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

That statement is inaccurate. See mishoo/UglifyJS#2520 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not too proficient in english, but it's written "an issue with Uglify", and not "an issue in Uglify". It's two different things, no ?

Copy link

Choose a reason for hiding this comment

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

It's a mapbox-gl issue.

@filipesilva
Copy link
Contributor

@kzc I was unaware that there was a better way to target the specific problem, and agree that it would be better. Would you be willing to put up a similar PR to makes it more specific?

For the record our intention to address this class of problems is to wholly disable the node global in webpack for browser apps in CLI 2.0. Merging this fix was an interim compromise to support mapbox-gl users.

@kzc
Copy link

kzc commented Nov 30, 2017

@filipesilva Since this project is one of the bigger users of uglify-es, I scan the issues occasionally and happened across this. I'll leave it to you whether or not to act on this information.

@filipesilva
Copy link
Contributor

@kzc we really appreciate that of you, your insight is very useful for keeping our Uglify usage correct and bug free.

I put up a PR with your suggested improvement: #8694

dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this pull request Apr 23, 2018
The node only `global` object had been left in because it used to cause a build size regression with Angular.

This doesn't seem to be the case anymore so it should be removed because it causes problematic interactions with some libraries.

Fix angular#5804
Supersedes angular#7931
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this pull request Apr 23, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants