You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ng build ---prod with "optimization: true" causes browser error. #10658
changed the title [-]The "optimization" property with "true" value causes build issue and browser error.[/-][+]ng build ---prod with "optimization: true" causes browser error.[/+]on May 5, 2018
With the greatest respect, this is the second breaking problem with ES6 output by the CLI in as many months (there was also a build optimizer issue having to do with WebPack - see #9495). It would seem that ES6 is not one of the test cases when bringing the CLI to GA. If my summation is correct, may I humbly suggest that a test case be added so that seemingly obvious issues such as this are caught prior to developers undertaking the work of upgrading?
And may I add, fine work overall; Angular's trajectory is fantastic - it's just frustrating having to deal with ES6 output issues again.
Reacted by Anastassios Martakos, CDDelta, rafaelfgx, yokots, Fergal Moran, VangelisAlSghir, Lars, Annie-Huang and Arghya Chakrabarty
I have configured the tsconfig.json in my Angular 6 project as follow:
{
..."target": "es5",
...
}
I'm experiencing this problem too, even with ES5. So this problem is not exclusive to ES6. (I mean tsconfig.json is the right file, correct? I dont know of any other.)
The build optimizer currently does not fully support ES2015+. There is ongoing work to provide this support. Current recommendation is to disable it unless using ES5.
Disabling the buildOptimizer worked for me. I'm on the latest version and also targeting es5. Having the buildOptimizer set to true is literally stripping out a portion of code from a library I'm using. This causes undefined errors to be thrown. It's microsoft's own msal npm package and the portion that's being stripped out is their AuthorityType enum.
After a few days of wasting time I found that my angular elements webcomponent that should work in IE11 is getting "Function Expected" error because of angular cli optimization: true.
Without optimization i'm starting to see it kinda working.
The webcomponent went from 600kb to 2.6mb. i will try external minification for now.
I'm using Angular 7.0.2
Reacted by Max Riegler
angular-automatic-lock-bot commented on Sep 8, 2019
Activity
[-]The "optimization" property with "true" value causes build issue and browser error.[/-][+]ng build ---prod with "optimization: true" causes browser error.[/+]yokots commentedon May 5, 2018
@rafaelfgx see here
rafaelfgx commentedon May 5, 2018
@yokots With build target es2017 or esnext the same error occurs.
aripp commentedon May 6, 2018
See also here
HitkoDev commentedon May 7, 2018
Related webpack issue: webpack-contrib/uglifyjs-webpack-plugin#269
TimUnderhay commentedon May 7, 2018
Also seeing this issue with Angular 6. Confirmed that setting optimization to false in angular.cli works around the problem.
Though this has increased my main bundle size from 2M to 6.9M, so it's not a practical workaround.
TimUnderhay commentedon May 7, 2018
Targeting ES5 also works around the problem for me. I was targeting ES6 previously.
TimUnderhay commentedon May 7, 2018
With the greatest respect, this is the second breaking problem with ES6 output by the CLI in as many months (there was also a build optimizer issue having to do with WebPack - see #9495). It would seem that ES6 is not one of the test cases when bringing the CLI to GA. If my summation is correct, may I humbly suggest that a test case be added so that seemingly obvious issues such as this are caught prior to developers undertaking the work of upgrading?
And may I add, fine work overall; Angular's trajectory is fantastic - it's just frustrating having to deal with ES6 output issues again.
realmar commentedon May 7, 2018
I have configured the
tsconfig.jsonin my Angular 6 project as follow:{ ... "target": "es5", ... }I'm experiencing this problem too, even with ES5. So this problem is not exclusive to ES6. (I mean
tsconfig.jsonis the right file, correct? I dont know of any other.)aripp commentedon May 8, 2018
Setting "buildOptimizer": false in angular.json did fix the problem for me. The bundle size is as small as before the upgrade to Angular 6.
clydin commentedon May 8, 2018
The build optimizer currently does not fully support ES2015+. There is ongoing work to provide this support. Current recommendation is to disable it unless using ES5.
Duplicate of angular/devkit#816
disabling build optimizer
bh3605 commentedon Aug 31, 2018
Disabling the buildOptimizer worked for me. I'm on the latest version and also targeting es5. Having the buildOptimizer set to true is literally stripping out a portion of code from a library I'm using. This causes undefined errors to be thrown. It's microsoft's own msal npm package and the portion that's being stripped out is their AuthorityType enum.
sparebytes commentedon Oct 3, 2018
Updating to Angular 7 rc0 fixed this for me. See my comment on another thread
liorwohl commentedon Nov 7, 2018
After a few days of wasting time I found that my angular elements webcomponent that should work in IE11 is getting "Function Expected" error because of angular cli optimization: true.
Without optimization i'm starting to see it kinda working.
The webcomponent went from 600kb to 2.6mb. i will try external minification for now.
I'm using Angular 7.0.2
angular-automatic-lock-bot commentedon Sep 8, 2019
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.